본문 바로가기
MLOps/Doker & Kubernetes

Udemy CKA 강의 정리 30: Practice Test - ReplicaSets - Solution (Optional)

by 공부하는 무니 2023. 1. 4.
반응형

해당 내용은 Udemy의 Certified Kubernetes Administrator (CKA) with Practice Tests  강의를 공부한 내용입니다. 내용을 그대로 번역하기보다는, 제가 이해하기 쉬운 대로 수정한 부분들이 있습니다.

⚠️ 영어 독해가 많이 부족합니다. 틀린 내용이 있으면 알려주시면 감사하겠습니다.


Q1. How many PODs exist on the system? In the current(default) namespace.

답: 0

Q2. How many ReplicaSets exist on the system? In the current(default) namespace.

답: 0

Q3. How about now? How many ReplicaSets do you see?

답: 1

Q4. How many PODs are DESIRED in the new-replica-set?

답: 4

Q5. What is the image used to create the pods in the new-replica-set?

 kubectl describe replicaset replicaset이름 커맨드를 입력하여 이미지를 확인할 수 있습니다.

답: BUSYBOX777

Q6. How many PODs are READY in the new-replica-set?

kubectl get replicaset커맨드를 입력했을 때 나오는 결과에서 확인할 수 있습니다.

답: 0

Q7. Why do you think the PODs are not ready?

파드가 READY가 안된 이유를 찾으려면 파드 1개를 자세히 살펴보아야 합니다.

kubectl get pods 커맨드를 통해 파드 이름 1개를 가져온 후, kubectl describe pod 파드이름 커맨드를 실행하면 파드에 대한 자세한 정보를 볼 수 있습니다.

Events: 이후를 보면 에러 메시지가 나옵니다.

답: The image BUSYBOX777 doesn’t exist

Q8. Delete any one of the 4 PODs.

kubectl delete pod 파드이름커맨드를 통해 파드를 1개 삭제합니다.

Q9. How many PODs exist now?

kubectl get pods커맨드로 확인합니다.

방금 파드를 하나 삭제했는데, 새로운 파드가 하나 생긴 것을 확인할 수 있습니다.

답: 4

Q10. Why are there still 4 PODs, even after you deleted one?

답: ReplicaSet ensures that desired number of PODs always run

Q11. Create a ReplicaSet using the replicaset-definition-1.yaml file located at /root/. There is an issue with the file, so try to fix it.

kubectl create -f yaml파일 커맨드로 replicaset을 만들 수 있습니다.

그런데 에러가 났네요. apiVersion 이 잘못 들어간 것 같습니다.

따라서 yaml 파일의 apiVersion 를 수정해야 합니다.

vi /root/replicaset-definiton-1.yaml

수정 후, 다시 replicaset 생성 커맨드를 실행합니다.

Q12. Fix the issue in the replicaset-definition-2.yaml file and create a ReplicaSet using it. This file is located at /root/.

이번엔 selector  와 labels가 매칭이 안되었다는 에러가 났습니다.

yaml 파일을 살펴보니 selectormatchLabelstemplate  의 labels이 일치하지 않습니다.

selectormatchLabels을 tier: nginx로 수정하고 다시 생성해봅니다.

Q13. Delete the two newly created ReplicaSets - replicaset-1 and replicaset-2

각 커맨드에서 replicaset 대신 rs를 써도 됩니다.

Q14. Fix the original replica set new-replica-setto use the correct busyboximage.

kubectl edit rs new-replica-set으로 yaml 파일을 수정할 수 있습니다.

yaml file 수정 완료

여기서 파드의 상태를 확인해보면, 아직도 에러가 나고 있는 것을 볼 수 있습니다. replicaset 의 definition file을 업데이트했다고 하더라도 파드는 자동으로 다시 생성되지 않습니다.

따라서 모든 파드 삭제하고 다시 생성해야 합니다.

모든 파드를 삭제 후 다시 조회해보니 Running 되고 있는 것을 확인할 수 있습니다.

Q15. Scale the ReplicaSet to 5 PODs.

Q16. Now scale the ReplicaSet down to 2 PODs. Use the kubectl scale  command or edit the replicaset using kubectl edit replicaset.

yaml 파일을 수정하여 replicas를 축소해보겠습니다.

kubectl edit rs new-replica-set으로 yaml 파일을 수정할 수 있습니다.

반응형

댓글