Exercise 12.1: Assign Pods Using Labels
CP 노드에 연결된 터미널로 이동
노드 목록 확인
kubectl get node
노드에 부여된 Label 확인
kubectl get node --show-labels
노드에 부여된 Taint 확인
kubectl get nodes \ -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect
클러스터에 생성된 모든 Pod 확인
kubectl get pod --all-namespaces -o wide
각 Node별로 배포된 Pod 갯수 확인
kubectl describe node | grep -E "(^Name:|^Non-terminated)"
각 노드에 Label 부여
{ kubectl label nodes cp status=vip kubectl label nodes worker status=other }
노드에 부여된 Label 확인
kubectl get nodes --show-labels | grep --color 'status\|$'
Pod 생성 - status=vip Label을 가진 노드에 배포
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: vip spec: terminationGracePeriodSeconds: 0 containers: - name: busybox image: busybox args: - sleep - "1000000" nodeSelector: status: vip EOF
위에서 생성한 Pod가 어떤 노드에 배포 됐는지 확인
kubectl get pod vip -o wide
Pod 삭제
kubectl delete pod vip
Pod 생성 - 위에서 생성한 Pod와 동일한 Manifest에서 nodeSelector만 삭제
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: vip spec: terminationGracePeriodSeconds: 0 containers: - name: busybox image: busybox args: - sleep - "1000000" EOF
위에서 생성한 Pod가 어떤 노드에 배포 됐는지 확인
kubectl get pod vip -o wide
Pod 생성 - status=other Label을 가진 노드에 배포
cat <<EOF | kubectl create -f - apiVersion: v1 kind: Pod metadata: name: other spec: terminationGracePeriodSeconds: 0 containers: - name: busybox image: busybox args: - sleep - "1000000" nodeSelector: status: other EOF
위에서 생성한 Pod가 어떤 노드에 배포 됐는지 확인
kubectl get pod other -o wide
Pod 삭제
kubectl delete pod vip other
Last updated