Node的隔离与恢复
使用yaml文件进行隔离和恢复调度
可能会报错,不建议使用
# 隔离调度
# unschedule_node.yaml
apiVersion: v1
kind: Node
metadata:
name: k8s-node1
labels:
kubernetes.io/hostname: k8s-node1
spec:
unschedulable: true
# 对node状态进行修改
# kubectl replace -f unschedule_node.yaml
# 观察node状态,是否包含 SchedulingDisabled
# kubectl get nodes
# 报错
# The Node "k8s-node1" is invalid: spec.podCIDRs: Forbidden: node updates may not change podCIDR except from "" to valid
---
# 恢复调度
# unschedule_node.yaml
apiVersion: v1
kind: Node
metadata:
name: k8s-node1
labels:
kubernetes.io/hostname: k8s-node1
spec:
unschedulable: false
# 对node状态进行修改
# kubectl replace -f unschedule_node.yaml
# 观察node状态,是否包含 SchedulingDisabled
# kubectl get nodes
# 报错
# The Node "k8s-node1" is invalid: spec.podCIDRs: Forbidden: node updates may not change podCIDR except from "" to valid
使用kubectl patch实现node的隔离和恢复调度
隔离
kubectl patch node k8s-node1 -p ‘{“spec”:{“unschedulable”:true}}’
恢复
kubectl patch node k8s-node1 -p ‘{“spec”:{“unschedulable”:false}}’
使用cordon和uncordon进行隔离和恢复调度
隔离
kubectl cordon k8s-node1
恢复
kubectl uncordon k8s-node1