CKA - Practice test - Replicasets

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

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.

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.

@Tej-Singh-Rana thanks for the reply. but ‘new-replica-set’ is only a replicaset.

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

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.
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
    name: new-replica-set
   replicas: 4
           name: busybox-pod
           name: busybox-pod
              name: busybox-pod
          -  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 @Tej-Singh-Rana

but answer still same.

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

Could you verify kubectl get pods until the replicasets are ready?

Change the “busybox” image in kubectl edit replicaset new-replica-set is correct but after that, we need to delete replicaset in the kube pods. Use command kubectl delete pods new-replica-set-xxxxx.