需求:daemonset正常是在每个节点已agent形式部署,现因节点node-1出现问题,为了不blocked 正常升级,部署的时候,把这个节点排除在外.

方法:通过nodeSelector形式,在除了node-1的节点上,打上标签,然后在daemonset里添加nodeSelector

操作步骤如下:

(1) 查看每个节点标签

kubectl get nodes --show-labels

(2) 打标签

kubectl label node node-2 ipmi-enable=true
kubectl label node node-3 ipmi-enable=true

节点多的话可以写个循环

(3) 在daemonset里添加nodeSelector

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
    imagePullPolicy: IfNotPresent
  nodeSelector:
    ipmi-enable: "true"

等待该daemonset的所有pod的重启即可

(4) 删除标签

kubectl label node node-2 ipmi-enable-
kubectl label node node-3 ipmi-enable-

 

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐