官网

在这里插入图片描述
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

Logo

Authing 是一款以开发者为中心的全场景身份云产品,集成了所有主流身份认证协议,为企业和开发者提供完善安全的用户认证和访问管理服务

更多推荐