Node Selector¶
nodeSelector
Assign pods to Nodes using Labels and Selectors
给节点设置label Apply Labels to Nodes
Scheduler will assign Pods to a Node with a matchling Label
简单来说就是 key-value的匹配
Pod with nodeSelector¶
apiVersion: v1
kind: Pod
metadata:
name: web
spec:
containers:
- name: hello-world
image: nginx
nodeSelector:
hardware: local_gpu
Status will be pending, 通过 kubectl describe pod web 可以查看event
$ $ kubectl get pods -o wide
NAME READY STATUS RESTARTS AGE IP NODE NOMINATED NODE READINESS GATES
web 0/1 Pending 0 8s <none> <none> <none> <none>
add label to the Node
$ kubectl label nodes k8s-worker1 hardware=local_gpu