Learn about replica sets
Tips and Tricks
For simulated Practice problems visit KillerCoda.
-
Solution
k run p1 --image=nginx --labels=tier=frontend
-
Solution
replica_set.yaml
apiVersion: apps/v1 kind: ReplicaSet metadata: name: rs1 labels: tier: frontend spec: replicas: 3 # no of pods selector: matchLabels: tier: frontend template: # pod p1 template details metadata: labels: tier: frontend spec: containers: - image: nginx name: p1 dnsPolicy: ClusterFirst restartPolicy: Always
-
Delete two of pods belonging to
rs1
replicaSet, check the pods again they are reinstated to a total of3
.Solution
# check the pods belonging to rs1 replica set #one is p1 that we created in the first step, other two will be named in pattern rs1-xxxxx k get po k delete po p1 rs1-xxx --force # list the pods # you will notice that the no of pods belonging to rs1 replica set are respawing, till they are 3 in number k get po