[root@k8scloude1 pod]# kubectl get pods -o wideNAMEREADYSTATUSRESTARTSAGEIPNODENOMINATED NODEREADINESS GATESpod11/1Running04s10.244.158.84k8scloude1<none><none>[root@k8scloude1 pod]# kubectl delete pod pod1 --forcewarning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.pod "pod1" force deleted[root@k8scloude1 pod]# kubectl get pods -o wideNo resources found in pod namespace.
注意,tolerations容忍度有两种写法,任选一种即可:
tolerations:- key: "key1"operator: "Equal"value: "value1"effect: "NoSchedule"tolerations:- key: "key1"operator: "Exists"effect: "NoSchedule"
给k8scloude2节点打标签
[root@k8scloude1 pod]# kubectl label nodes k8scloude2 taint=Tnode/k8scloude2 labeled[root@k8scloude1 pod]# kubectl get node --show-labelsNAMESTATUSROLESAGEVERSIONLABELSk8scloude1Readycontrol-plane,master8dv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude1,kubernetes.io/os=linux,node-role.kubernetes.io/control-plane=,node-role.kubernetes.io/master=,node.kubernetes.io/exclude-from-external-load-balancers=k8scloude2Ready<none>8dv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude2,kubernetes.io/os=linux,taint=Tk8scloude3Ready<none>8dv1.21.0beta.kubernetes.io/arch=amd64,beta.kubernetes.io/os=linux,kubernetes.io/arch=amd64,kubernetes.io/hostname=k8scloude3,kubernetes.io/os=linux
对k8scloude2设置污点
#污点taint的格式:键=值:NoSchedule[root@k8scloude1 pod]# kubectl taint node k8scloude2 wudian=true:NoSchedulenode/k8scloude2 tainted[root@k8scloude1 pod]# kubectl describe nodes k8scloude2 | grep -i TaintsTaints:wudian=true:NoSchedule
创建pod,tolerations参数表示容忍污点wudian=true:NoSchedule,nodeSelector:taint: T参数表示pod运行在标签为nodeSelector=taint: T的节点 。
[root@k8scloude1 pod]# vim schedulepod4.yaml [root@k8scloude1 pod]# cat schedulepod4.yamlapiVersion: v1kind: Podmetadata:creationTimestamp: nulllabels:run: pod1name: pod1namespace: podspec:tolerations:- key: "wudian"operator: "Equal"value: "true"effect: "NoSchedule"nodeSelector:taint: Tcontainers:- image: nginximagePullPolicy: IfNotPresentname: pod1resources: {}ports:- name: httpcontainerPort: 80protocol: TCPhostPort: 80dnsPolicy: ClusterFirstrestartPolicy: Alwaysstatus: {}[root@k8scloude1 pod]# kubectl get pod -o wideNo resources found in pod namespace.[root@k8scloude1 pod]# kubectl apply -f schedulepod4.yamlpod/pod1 created
查看pod,k8scloude2节点就算有污点也能运行pod
[root@k8scloude1 pod]# kubectl get pods -o wideNAMEREADYSTATUSRESTARTSAGEIPNODENOMINATED NODEREADINESS GATESpod11/1Running08s10.244.112.177k8scloude2<none><none>[root@k8scloude1 pod]# kubectl delete pod pod1 --forcewarning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.pod "pod1" force deleted[root@k8scloude1 pod]# kubectl get pods -o wideNo resources found in pod namespace.
污点容忍的另一种写法:operator: "Exists",没有value值 。
[root@k8scloude1 pod]# vim schedulepod4.yaml [root@k8scloude1 pod]# cat schedulepod4.yamlapiVersion: v1kind: Podmetadata:creationTimestamp: nulllabels:run: pod1name: pod1namespace: podspec:tolerations:- key: "wudian"operator: "Exists"effect: "NoSchedule"nodeSelector:taint: Tcontainers:- image: nginximagePullPolicy: IfNotPresentname: pod1resources: {}ports:- name: httpcontainerPort: 80protocol: TCPhostPort: 80dnsPolicy: ClusterFirstrestartPolicy: Alwaysstatus: {}[root@k8scloude1 pod]# kubectl apply -f schedulepod4.yamlpod/pod1 created
查看pod,k8scloude2节点就算有污点也能运行pod
[root@k8scloude1 pod]# kubectl get pods -o wideNAMEREADYSTATUSRESTARTSAGEIPNODENOMINATED NODEREADINESS GATESpod11/1Running010s10.244.112.178k8scloude2<none><none>[root@k8scloude1 pod]# kubectl delete pod pod1 --forcewarning: Immediate deletion does not wait for confirmation that the running resource has been terminated. The resource may continue to run on the cluster indefinitely.pod "pod1" force deleted[root@k8scloude1 pod]# kubectl get pods -o wideNo resources found in pod namespace.
经验总结扩展阅读
- 2023年农历七月廿九宜订婚吗 2023年9月13日是订婚的黄道吉日吗
- 2023年9月13日嫁娶好吗 2023年农历七月廿九嫁娶吉日
- 2023年农历七月廿九领证吉日 2023年农历七月廿九宜领证吗
- 2023年农历七月廿九求婚吉日 2023年9月13日是求婚吉日吗
- 2023年9月13日提亲吉日一览表 2023年农历七月廿九提亲吉日
- 2023年9月13日定亲行吗 2023年农历七月廿九定亲吉日
- 2023年9月13日是举办婚礼的黄道吉日吗 2023年农历七月廿九举办婚礼吉日
- 2023年9月13日喝喜酒好吗 2023年农历七月廿九喝喜酒吉日
- 2023年农历七月廿九搬家吉日 2023年农历七月廿九宜搬家吗
- 2023年农历七月廿九宜搬迁吗 2023年农历七月廿九搬迁吉日