Taint the node, replacing <NODE_NAME>
with one of the worker node names returned in the previous command:
kubectl taint node <NODE_NAME> node-type=prod:NoSchedule
Schedule a pod to the dev environment.
Create the dev-pod.yaml
file:
vim dev-pod.yaml
Enter the following YAML to specify a pod that will be scheduled to the dev environment:
apiVersion: v1
kind: Pod
metadata:
name: dev-pod
labels:
app: busybox
spec:
containers:
- name: dev
image: busybox
command: ['sh', '-c', 'echo Hello Kubernetes! && sleep 3600']
Save and quit the file by pressing Escape followed by :wq!
.
Create the pod:
kubectl create -f dev-pod.yaml
Schedule a pod to the prod environment.
Create the prod-deployment.yaml
file:
vim prod-deployment.yaml
Enter the following YAML to specify a pod that will be scheduled to the prod environment:
apiVersion: apps/v1
kind: Deployment
metadata:
name: prod
spec:
replicas: 1
selector:
matchLabels:
app: prod
template:
metadata:
labels:
app: prod
spec:
containers:
- args:
- sleep
- "3600"
image: busybox
name: main
tolerations:
- key: node-type
operator: Equal
value: prod
effect: NoSchedule
Save and quit the file by pressing Escape followed by :wq!
.
Create the deployment:
kubectl create -f prod-deployment.yaml
Verify each pod has been scheduled to the correct environment.