Kubernetes Replica Sets

A ReplicaSet is outlined with fields, together with a selector that specifies the way to establish Pods it will acquire, variety of replicas indicating what number Pods it ought to be maintaining, and a pod template specifying the information of recent Pods it ought to produce to satisfy the quantity of replicas criteria. A ReplicaSet then fulfills its purpose by making and deleting Pods as required achieving the required range. Once a ReplicaSet has to produce new Pods, it uses its own defined Pod template.

Replica Set

Example

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: frontend
  labels:
    app: guestbook
    tier: frontend
spec:
  # modify replicas according to your case
  replicas: 3
  selector:
    matchLabels:
      tier: frontend
  template:
    metadata:
      labels:
        tier: frontend
    spec:
      containers:
      - name: php-redis
        image: gcr.io/google_samples/gb-frontend:v3

Saving this manifest into frontend.yaml and submitting it to a Kubernetes cluster will create the defined ReplicaSet and the Pods that it manages.

kubectl apply -f https://kubernetes.io/examples/controllers/frontend.yaml

You can then get the current ReplicaSets deployed:

kubectl get rs
NAME       DESIRED   CURRENT   READY   AGE
frontend   3         3         3       6s
Subscribe Now