Exercise 12.2: Using Taints to Control Pod Deployment

  1. CP 노드에 연결된 터미널로 이동

  2. 각 Node별로 배포된 Pod 갯수 확인

    kubectl describe node | grep -E "(^Name:|^Non-terminated)"
  3. Deployment 생성

    cat <<EOF | kubectl create -f -
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: taint-deployment
    spec:
      replicas: 8
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name:  nginx
            image: nginx:1.20.1
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 100m
    EOF
  4. 위에서 생성한 Deployment를 통해서 생성된 Pod가 어떤 노드에 배포 됐는지 확인

    kubectl get pod -l app=nginx -o wide
  5. Deployment 삭제

    kubectl delete deployment taint-deployment
  6. Worker 노드에 Taint 부여

    kubectl taint nodes worker status=unstable:PreferNoSchedule
  7. 노드에 부여된 Taint 확인

    kubectl get nodes \
    -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect
  8. Deployment 생성

    cat <<EOF | kubectl create -f -
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: taint-deployment
    spec:
      replicas: 8
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name:  nginx
            image: nginx:1.20.1
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 100m
    EOF
  9. 위에서 생성한 Deployment를 통해서 생성된 Pod가 어떤 노드에 배포 됐는지 확인

    kubectl get pod -l app=nginx -o wide
  10. Replica 갯수를 16개로 변경

    kubectl scale deploy taint-deployment --replicas=16
  11. 추가로 생성되는 Pod들이 어떤 노드에 배포 됐는지 확인

    kubectl get pod -l app=nginx -o wide
  12. CP 노드에 할당된 리소스 확인

    kubectl describe node cp
  13. Deployment 삭제

    kubectl delete deployment taint-deployment
  14. Worker 노드에 부여한 Taint 삭제

    kubectl taint nodes worker status-
  15. 노드에 부여된 Taint 확인

    kubectl get nodes \
    -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect
  16. Worker 노드에 Taint 부여

    kubectl taint nodes worker operation=upgrading:NoSchedule
  17. 노드에 부여된 Taint 확인

    kubectl get nodes \
    -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effect
  18. Deployment 생성

    cat <<EOF | kubectl create -f -
    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: taint-deployment
    spec:
      replicas: 16
      selector:
        matchLabels:
          app: nginx
      template:
        metadata:
          labels:
            app: nginx
        spec:
          containers:
          - name:  nginx
            image: nginx:1.20.1
            ports:
            - containerPort: 80
            resources:
              requests:
                cpu: 100m
    EOF
  19. 위에서 생성한 Deployment를 통해서 생성된 Pod가 어떤 노드에 배포 됐는지 확인

    kubectl get pod -l app=nginx -o wide
  20. Worker 노드에 부여한 Taint 삭제

    kubectl taint nodes worker operation-
  21. Pending 상태였던 Pod들이 배포되는지 확인

    kubectl get pod -l app=nginx -o wide
  22. 새로운 터미널을 키고 CP 노드로 SSH 접속

  23. Pod 상태 모니터링

    kubectl get pod -l app=nginx -o wide --watch
  24. 기존 터미널로 이동

  25. Worker 노드에 Taint 부여

    kubectl taint nodes worker performance=slow-disk:NoExecute
  26. Pod 상태 모니터링 명령어를 실행한 터미널로 이동해서 Pod가 삭제되는지 확인

  27. 기존 터미널로 이동

  28. Pod 상태 확인

    kubectl get pod -l app=nginx
  29. Worker 노드에 부여한 Taint 삭제

    kubectl taint nodes worker performance-
  30. Pod 상태 모니터링 명령어를 실행한 터미널로 이동해서 Pod가 배포되는지 확인

  31. 기존 터미널로 이동

  32. Pod 상태 확인

    kubectl get pod -l app=nginx
  33. Deployment 삭제

    kubectl delete deployment taint-deployment

Last updated