当一个pod在同一台服务器上,同时这个pod如果消耗了大量资源,就需要进行反亲和力配置,让这个pod不在同一节点上。
参考如下

spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - store
            topologyKey: "kubernetes.io/hostname"
      containers:
      - name: redis-server
        image: redis:3.2-alpine


#最新配置
  spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
          - weight: 100
            podAffinityTerm:    
              labelSelector:
                matchExpressions:
                - key: app
                  operator: In
                  values:
                  - ${DOCKER_NAME}
              topologyKey: "kubernetes.io/hostname"

参考链接https://kubernetes.io/zh/docs/concepts/scheduling-eviction/assign-pod-node/

最后修改:2021 年 01 月 14 日
如果觉得我的文章对你有用,请随意赞赏