Exercise 12.2: Using Taints to Control Pod Deployment
kubectl describe node | grep -E "(^Name:|^Non-terminated)"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 EOFkubectl get pod -l app=nginx -o widekubectl delete deployment taint-deploymentkubectl taint nodes worker status=unstable:PreferNoSchedulekubectl get nodes \ -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effectcat <<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 EOFkubectl get pod -l app=nginx -o widekubectl scale deploy taint-deployment --replicas=16kubectl get pod -l app=nginx -o widekubectl describe node cpkubectl delete deployment taint-deploymentkubectl taint nodes worker status-kubectl get nodes \ -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effectkubectl taint nodes worker operation=upgrading:NoSchedulekubectl get nodes \ -o=custom-columns=NodeName:.metadata.name,TaintKey:.spec.taints[*].key,TaintValue:.spec.taints[*].value,TaintEffect:.spec.taints[*].effectcat <<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 EOFkubectl get pod -l app=nginx -o widekubectl taint nodes worker operation-kubectl get pod -l app=nginx -o widekubectl get pod -l app=nginx -o wide --watchkubectl taint nodes worker performance=slow-disk:NoExecutekubectl get pod -l app=nginxkubectl taint nodes worker performance-kubectl get pod -l app=nginxkubectl delete deployment taint-deployment
Last updated