Pod.spec.nodeName 强制约束Pod调度到指定Node节点上
Pod.spec.nodeSelector 通过label-selector机制选择节点
# 设置标签
kubectl label nodes 192.168.0.122 env_role=dev
示例:
apiVersion: v1
kind: Pod
metadata:
name: nginx-pod
labels:
app: nginx
spec:
# nodeName: node01
# nodeName: 192.168.0.122
nodeSelector:
env_role: dev
containers:
- name: nginx
image: nginx
三种重启策略:
Always: 当容器停止,总是重建容器,默认策略。
OnFailure: 当容器异常退出(退出状态码非0)时,才重启容器。
Never: 当容器终止退出,从不重启容器。
示例:
apiVersion: V1
kind: Pod
metadata:
namem: nginx-pod
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx
restartPolicy: OnFailure