k8s通过podAntiAffinity调度方式创建pod

官网

在这里插入图片描述
136服务器,yaml文件:/root/demo/pod-anti-affinity.yaml

apiVersion: v1
kind: Pod
metadata:
  name: pod-anti-affinity
  labels:
    anti-affinity-demo: anti-affinity-demo-yahaha
spec:
  affinity:
    podAntiAffinity:
      requiredDuringSchedulingIgnoredDuringExecution:
      - labelSelector:
          matchExpressions:
          - key: label_key_135
            operator: In
            values:
            - label_value_135
        topologyKey: kubernetes.io/hostname
  containers:
  - name: pod-anti-affinity
    image: nginx
    imagePullPolicy: IfNotPresent

创建
因反亲和性选择; key label_key_135 value label_value_135,这次pod没有调度在135这台服务器中创建

root@server02:~/demo# kubectl create -f pod-anti-affinity.yaml
pod "pod-anti-affinity" created
root@server02:~/demo#
root@server02:~/demo# kubectl get pod -owide
NAME                  READY     STATUS    RESTARTS   AGE       IP              NODE
demo-node-selector    1/1       Running   0          53m       172.20.188.23   192.168.174.135
node-affinity         1/1       Running   0          18h       172.20.188.20   192.168.174.135
pod-affinity          1/1       Running   0          16h       172.20.188.21   192.168.174.135
pod-anti-affinity     1/1       Running   0          10s       172.20.6.46     192.168.174.136
pod-manual-schedule   1/1       Running   0          21h       172.20.188.19   192.168.174.135
pod-schedule          1/1       Running   0          21h       172.20.40.205   192.168.174.137

评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值