Replicasets 관련된 문제를 풀어보겠습니다.
1. How many PODs exist on the system?
# k get pods
A) 0
2.How many ReplicaSets exist on the system?
# k get replicasets.apps
A) 0
3.How about now? How many ReplicaSets do you see?
# k get replicasets.apps
A) 1
4.How many PODs are DESIRED in the new-replica-set?
# k get replicasets.apps
: 위의 이미지 참고
A) 4
5. What is the image used to create the pods in the new-replica-set?
# k get pods
# k describe pods new~~ <특정 ID>
A) busybox777
6. How many PODs are READY in the new-replica-set?
# k get pods
A) 0
7.Why do you think the PODs are not ready?
# k describe pods new-replica-set-rb9pg
A) The image busybox777 doesn't exist.
8.Delete any one of the 4 PODs.
#k delete pod new-replica-set-276k4 new-replica-set-b45qk new-replica-set-jjn6g new-replica-set-rb9pg
: 각 이름 뒤 띄어쓰기 한칸으로 여러개를 지울 수 있다.
9. How many PODs exist now?
# k get pods
A) 4
10.Why are there still 4 PODs, even after you deleted one?
A) ReplicaSet ensures that desired number of PODs always run
11. 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.
: /root/ 경로의 replicaset-definition-1.yaml 파일을 수정해라
: 어떤문제인지 눈으로 찾기 전에 먼저 명령어를 통해 어떤 문제로 작동이 되지 않는지 살펴본다.
# k apply -f replicaset-definition-1.yaml
: version 에서 에러가 발생한다 -> 인지
# vi replicaset-definition-1.yaml
apiVersion: apps/v1 ->변경
# k apply -f replicaset-definition-1.yaml
12. Fix the issue in the replicaset-definition-2.yaml file and create a ReplicaSet using it.
This file is located at /root/.
# k apply -f replicaset-definition-2.yaml
: selector 의 라벨과 template 의 라벨이 달라서 발생하는 문제
# vi replicaset-definition-2.yaml
: selector 의 tier 를 동일하게 변경
# k apply -f replicaset-definition-2.yaml
13.Delete the two newly created ReplicaSets - replicaset-1 and replicaset-2
# k get rs
# k delete rs replicaset-1 replicaset-2
: replicaSets 줄인말 rs 로 사용도 가능
14. Fix the original replica set new-replica-set to use the correct busybox image.
Either delete and recreate the ReplicaSet or Update the existing ReplicaSet and then delete all
PODs, so new ones with the correct image will be created.
# k edit rs new-replica-set
# k delete pods new-replica-set-p8bsm new-replica-set-4gfzf new-replica-set-5s8w8 new-replica-set-bbjdf
# k get pods
15.Scale the ReplicaSet to 5 PODs.
Use kubectl scale command or edit the replicaset using kubectl edit replicaset.
# k edit rs new-replica-set
# k get rs
16. Now scale the ReplicaSet down to 2 PODs.
Use the kubectl scale command or edit the replicaset using kubectl edit replicaset.
# k edit rs new-replica-set
# k get rs
'cloud > k8s(문제풀이)' 카테고리의 다른 글
[cka]kodekloud-services (0) | 2022.06.07 |
---|---|
[cka] kodekloud-namespaces (0) | 2022.06.07 |
[cka]kodekloud-Deployments (0) | 2022.06.07 |
[cka]kodekloud-pods (0) | 2022.06.07 |
[cka]kodekloud -시작하기에 앞서... (0) | 2022.06.07 |