☸️ReplicaSet

Describe about What is ReplicaSet ?

It is the component that replica the pod for availability and load balance .

CheatSheet Command

  1. Get ReplicaSet : kubectl get rs

  2. Create ReplicaSet: kubectl apply -f <file_name>.yaml

apiVersion: apps/v1
kind: ReplicaSet
metadata:
  name: <replica_name>
spec:
  replicas: <numbers of replicas>
  selector:
    matchLabels:
      # this label need to match pod label for link
      <key_name>: xxx (1)      
  # this below come from Pods template    
  template:
    metadata:
      labels:
        <key_name>: xxx (2)
    spec:
      containers:
      - name: <pod_name>
        image: <image_name>
  1. Describe information of ReplicaSet: kubectl describe rs <replicaset_name>

  2. Delete ReplicaSet: kubectl delete rs <replicaset_name>

  3. Edit ReplicaSet: kubeclt edit rs <replicaset_name> after use this command you need to remove existing pod manually to let it recreate

  4. Check the apiVersion of the template: kubectl explain rs

  5. Execute command from file kubectl apply -f <file_name>.yaml

  6. Scale Pod by ReplicaSet: kubectl scale rs --replicas=<amount_of_pod> <replicaset_name> (It will down or create new pod automatically)

Last updated