指定调度节点
I、Pod.spec.nodeName 将 Pod 直接调度到指定的Node节点上,会跳过 Scheduler 的调度策略,该匹配规则是强制匹配
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myweb
spec:
replicas: 7
template:
metadata:
labels:
app: myweb
spec:
nodeName: k8s-node1
containers:
- name: myweb
image: harbor.bwingame8.com/library/myapp:v2
ports:
- containerPort: 80
II、Pod.spec.nodeSelector: 通过kubernetes 的 label-selector 机制选择节点,由调度器调度策略匹配label,而后调度Pod到目标节点,该匹配规则属于强制约束
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: myweb
spec:
replicas: 2
template:
metadata:
labels:
app: myweb
spec:
nodeSelector:
disk: ssd
containers:
- name: myweb
image: harbor.bwingame8.com/library/myapp:v2
ports:
- containerPort: 80