k8s中设置污点 让pod不分配在某个节点

前置环境:k8s集群

1.创建pod

kubectl create deployment web  --image=nginx

查看刚创建的pod分配在哪个节点上

kubectl get pods -o wide

2.然后创建5份pod,我们观察pod分配在哪些node上面

kubectl scale deployment web --replicas=5

3.添加污点

刚才创建的pod 随机分配在compute01、compute11上,如果不想分配在01上,可以通过加污点实现

kubectl taint node compute01 env_role=yes:NoSchedule
NoSchedule属性值表示该node永远不会被调度

我们删除刚创建的五份pod

 kubectl delete deployment web

然后重新创建,观察pod分配到哪些节点

kubectl create deployment web  --image=nginx
kubectl scale deployment web --replicas=5

我们发现新创建的pod全部分配到了compute11节点,没有分配在compute01节点,说明我们在compute01上加的污点已经生效了。

4.最后附上删除污点的命令

kubectl taint node compute01 env_role:NoSchedule-

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值