Openshift Origin 1.5.1在DeploymentConfig上的Pod反关联不起作用

问题描述 投票:1回答:1

我有一个奇怪的问题,我正在尝试应用PodAntiAffinity来确保特定deploymentConfig的2个pod都不会在同一节点上结束:

我尝试使用以下命令编辑直流:

spec:
  replicas: 1
  selector:
    app: server-config
    deploymentconfig: server-config
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: server-config
        deploymentconfig: server-config
    spec:
      affinity:
        podAntiAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
          - labelSelector:
              matchExpressions:
              - key: app
                operator: In
                values:
                - server-config
            topologyKey: "kubernetes.io/hostname"

但是在节省的时候,我得到了:

"/tmp/oc-edit-34z56.yaml" 106L, 3001C written
deploymentconfig "server-config" skipped

并且变化不坚持。我的openshift / Kubernetes版本是:

[root@master1 ~]# oc version
oc v1.5.1
kubernetes v1.5.2+43a9be4
features: Basic-Auth GSSAPI Kerberos SPNEGO

提前致谢。

kubernetes openshift
1个回答
1
投票

这似乎有效,语法完全不同,需要将“scheduler.alpha.kubernetes.io/affinity”注释添加到工作中:

spec:
  replicas: 1
  selector:
    app: server-config
    deploymentconfig: server-config
  strategy:
    activeDeadlineSeconds: 21600
    resources: {}
    rollingParams:
      intervalSeconds: 1
      maxSurge: 25%
      maxUnavailable: 25%
      timeoutSeconds: 600
      updatePeriodSeconds: 1
    type: Rolling
  template:
    metadata:
      annotations:
        scheduler.alpha.kubernetes.io/affinity: |
          {
            "podAntiAffinity": {
              "requiredDuringSchedulingIgnoredDuringExecution": [{
                "labelSelector": {
                  "matchExpressions": [{
                    "key": "app",
                    "operator": "In",
                    "values":["server-config"]
                  }]
                },
                "topologyKey": "kubernetes.io/hostname"
              }]
            }
          }

按预期工作并在节点之间正确分布:

[root@master1 ~]# oc get pods -o wide |grep server-config
server-config-22-4ktvf                      1/1       Running   0          3h        10.1.1.73    10.0.4.101
server-config-22-fz31j                      1/1       Running   0          3h        10.1.0.3     10.0.4.100
server-config-22-mrw09                      1/1       Running   0          3h        10.1.2.64    10.0.4.102
© www.soinside.com 2019 - 2024. All rights reserved.