Skip to content

Replica Set

  • Replication controller (RC) is the old tech while Replica Set (RS) is the new one.
  • A ReplicaSet's purpose is to maintain a stable set of replica Pods running at any given time. As such, it is often used to guarantee the availability of a specified number of identical Pods.
  • A ReplicaSet then fulfills its purpose by creating and deleting Pods as needed to reach the desired number. When a ReplicaSet needs to create new Pods, it uses its Pod template.

Using Deployment and RS together

ReplicaSet ensures that a specified number of pod replicas are running at any given time. However, a Deployment is a higher-level concept that manages ReplicaSets and provides declarative updates to Pods along with a lot of other useful features.

Imperative create

k create -f RS-FILE.YAML

# or use this one
k apply -f RS-FILE.YAML

A sample file is given below

apiVersion: apps/v1
kind: ReplicaSet
  name: frontend
    app: guestbook
    tier: frontend
  # modify replicas according to your case
  replicas: 3
      tier: frontend
        tier: frontend
      - name: php-redis

Scaling an RS

# Get the values from the file
k replace -f RS-FILE.YAML

# the file will be used while replicas will be replaced by the number you specify
k scale --replicas=6 -f RS-FILE.YAML

# this one is recommended if already existing
k scale --replicas=6 rs RS-NAME