kubernetes / kubernetes

Production-Grade Container Scheduling and Management
https://kubernetes.io
Apache License 2.0
110.6k stars 39.54k forks source link

[docs] Node affinity example has an odd extra annotation #32071

Closed errordeveloper closed 7 years ago

errordeveloper commented 8 years ago

We currently have this:

apiVersion: v1
kind: Pod
metadata:
  name: with-labels
  annotations:
    scheduler.alpha.kubernetes.io/affinity: >
      {
        "nodeAffinity": {
          "requiredDuringSchedulingIgnoredDuringExecution": {
            "nodeSelectorTerms": [
              {
                "matchExpressions": [
                  {
                    "key": "kubernetes.io/e2e-az-name",
                    "operator": "In",
                    "values": ["e2e-az1", "e2e-az2"]
                  }
                ]
              }
            ]
          }
        }
      }
    another-annotation-key: another-annotation-value
spec:
  containers:
  - name: with-labels
    image: gcr.io/google_containers/pause:2.0

The line with another-annotation-key: another-annotation-value is confusing and seems to be a bit of red herring.

However, the text below this example goes:

In addition, among nodes that meet that criteria, nodes with a label whose key is another-annotation-key and whose value is another-annotation-value should be preferred.

Was the intention to have another selector term featuring that key/value pair?

jimmycuadra commented 7 years ago

I found this confusing also. I think the other annotation was supposed to be a preferredDuringSchedulingIgnoredDuringExecution object in the affinity annotation. That would make the quoted text correct, and would also give the document an example about the "preferred" affinity type, which currently has no example at all.

xiangpengzhao commented 7 years ago
      preferredDuringSchedulingIgnoredDuringExecution:
      - weight: 1
        preference:
          matchExpressions:
          - key: another-node-label-key
            operator: In
            values:
            - another-node-label-value

In addition, among nodes that meet that criteria, nodes with a label whose key is another-node-label-key and whose value is another-node-label-value should be preferred.

In the latest doc, it's more clear, as @jimmycuadra said.

As this issue is confirmed, we might close it :)

xiangpengzhao commented 7 years ago

/cc @thockin