Skip to content

Latest commit

 

History

History
53 lines (45 loc) · 2.03 KB

nodes-nodes-rebooting-affinity.adoc

File metadata and controls

53 lines (45 loc) · 2.03 KB

Rebooting a node using pod anti-affinity

Pod anti-affinity is slightly different than node anti-affinity. Node anti-affinity can be violated if there are no other suitable locations to deploy a pod. Pod anti-affinity can be set to either required or preferred.

With this in place, if only two infrastructure nodes are available and one is rebooted, the container image registry pod is prevented from running on the other node. oc get pods reports the pod as unready until a suitable node is available. Once a node is available and all pods are back in ready state, the next node can be restarted.

Procedure

To reboot a node using pod anti-affinity:

  1. Edit the node specification to configure pod anti-affinity:

    apiVersion: v1
    kind: Pod
    metadata:
      name: with-pod-antiaffinity
    spec:
      affinity:
        podAntiAffinity: (1)
          preferredDuringSchedulingIgnoredDuringExecution: (2)
          - weight: 100 (3)
            podAffinityTerm:
              labelSelector:
                matchExpressions:
                - key: registry (4)
                  operator: In (5)
                  values:
                  - default
              topologyKey: kubernetes.io/hostname
    1. Stanza to configure pod anti-affinity.

    2. Defines a preferred rule.

    3. Specifies a weight for a preferred rule. The node with the highest weight is preferred.

    4. Description of the pod label that determines when the anti-affinity rule applies. Specify a key and value for the label.

    5. The operator represents the relationship between the label on the existing pod and the set of values in the matchExpression parameters in the specification for the new pod. Can be In, NotIn, Exists, or DoesNotExist.

      This example assumes the container image registry pod has a label of registry=default. Pod anti-affinity can use any Kubernetes match expression.

  2. Enable the MatchInterPodAffinity scheduler predicate in the scheduling policy file.