MLOps/Doker & Kubernetes

Udemy CKA 강의 정리 63: Solution - Node Affinity (optional)

공부하는 무니 2023. 1. 10. 04:15
반응형

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

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


Q1. How many Labels exist on node node01?

kubectl describe node node01 로 확인합니다.

답: 5

Q2. What is the value set to the label key beta.kubernetes.io/arch on node01?

마찬가지로 kubectl describe node node01 에서 확인합니다.

답: amd64

Q3. Apply a label color=blue to node node01

kubectl label node node01 color=blue커맨드를 실행합니다.

Q4. Create a new deployment named blue with the nginx image and 3 replicas.

kubectl create deployment blue --image=nginx --replicas=3커맨드를 입력합니다.

Q5. Which nodes can the pods for the blue deployment be placed on?

Q6. Set Node Affinity to the deployment to place the pods on node01 only.

Name: blue
Replicas: 3
Image: nginx
NodeAffinity: requiredDuringSchedulingIgnoredDuringExecution
Key: color
value: blue

kubectl edit deployments.apps blue

Q7. Which nodes are the pods placed on now?

답: node01

Q8. Create a new deployment named red with the nginx image and 2 replicas, and ensure it gets placed on the controlplane node only.

Use the label key - node-role.kubernetes.io/control-plane - which is already set on the controlplane node.

affinity:
     nodeAffinity:
       requiredDuringSchedulingIgnoredDuringExecution:
         nodeSelectorTerms:
         - matchExpressions:
           - key: node-role.kubernetes.io/master
             operator: Exists

kubectl create -f red-deployment.yaml
kubectl get pods -o wide

반응형