CKA - Practice test - Replicasets

Hi, I update replicaset using
kubectl edit replicaset new-replica-set.
image

and I got
master $ kubectl edit replicaset new-replica-set
replicaset.apps/new-replica-set edited

message also. but Question no: 14 says, my tasks not completed. what should be the issue and how can i fox this

Add replicas: 4 in your replicaset yaml file. Put it in yaml file and add this column and replace it with your previous replicaset.

It’s default count also 4.
image

Can you copy your yaml file here?


I changed Image name only

Save it in the yaml file and try with kubectl replace -f file-name.yaml --force. It will recreate and will delete previous all pods and replicaset.

@player001 thanks for the reply. but ‘new-replica-set’ is only a replicaset.
image

there is no any yml file, to update ‘new-replica-set’. it generated from the system.
image

this practice test have two more question.

question 15. scale the ReplicaSet up to 5 PODs.
same as previous qustion no 14, I only did, edit new-replica-set using
kubectl edit replicaset new-replica-set
but it’s correct.
image
answer also correct.

can we update replicaset without using yml file with ‘replace’ cmd? If can, how can I do that?

Try this one : ----

apiVersion: apps/v1
kind: ReplicaSet
metadata:
    name: new-replica-set
spec:
   replicas: 4
   selector:
      matchLabels:
           name: busybox-pod
   template:
      metadata:
           name: busybox-pod
           labels:
              name: busybox-pod
      spec:
          containers:
          -  image: busybox   
             command: ["sh","-c","echo Hello Kubernetes! && sleep 3600"]
             imagePullPolicy: Always
             name: busybox-container
          schedulerName: default-scheduler

By command you can do this like
kubectl get replicaset new-replica-set -oyaml >> replica.yaml
After that remove unnecessary fields. Get a idea from yaml file.
kubectl replace -f replica.yaml --force

1 Like

Great explanation. Thank you so much @player001

but answer still same.
image

I think issue on system. anyway, your explanation all clear and learn more additional things. it’s so much to me. thank you.

You have to write busybox version i guess, because we are only mentioning busybox not with version.

do kubectl describe replicaset new-replica-set inspect it. May be they are not scheduling on nodes. Might by taints and tolerations issue.

1 Like

I still not followed the scheduling section. I’ll try to explain in the future