- Add the
disk=fast
label to the worker2 node:
kubectl label nodes acgk8s-worker2 disk=fast
- Create a YAML file named
fast-nginx.yml
withnodeSelector
:
vim fast-nginx.yml
In the file, paste the following:
apiVersion: v1
kind: Pod
metadata:
name: fast-nginx
namespace: dev
spec:
nodeSelector:
disk: fast
containers:
- name: nginx
image: nginx
Save the file
- Create the fast-nginx pod:
kubectl create -f fast-nginx.yml
- Check the status of the pod:
kubectl get pod fast-nginx -n dev -o wide
Create a Pod That Will Only Be Scheduled on Nodes using taints
- Add a taint to a node using
kubectl taint
:
kubectl taint nodes node1 disk=fast:NoSchedule
- Create a YAML file named
fast-nginx.yml
withtolerations
:
apiVersion: v1
kind: Pod
metadata:
name: fast-nginx
namespace: dev
spec:
containers:
- name: nginx
image: nginx
tolerations:
- key: "disk"
operator: "Equal"
value: "fast"
effect: "NoSchedule"
Save the file
- Create the fast-nginx pod:
kubectl create -f fast-nginx.yml
- Check the status of the pod:
kubectl get pod fast-nginx -n dev -o wide