Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Name

Operator Version

Description

Usage

affinity

2.5.0+

Affinity describes node affinity scheduling rules for pods that run CDAP services. You can indicate that a rule is soft or preferred, so that the k8s scheduler still schedules the Pod even if it can't find a matching node.

With pod affinity/anti-affinity, you can constrain a Pod using labels on other Pods running on the node (or other topological domain), instead of just node labels, which allows you to define rules for which Pods can be co-located on a node.

The affinity field is similar to the one used by k8s for pods, deployments, replica sets etc. See k8s docs.

Assume you want AppFabric and Messaging services to be scheduled on separate nodes. If running the services on different nodes isn’t possible, you want the services to still get scheduled. This constraint can be represented using the following configuration in the CDAP custom resource:

Code Block
languageyaml
appFabric:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: cdap.container.AppFabric
              operator: In
              values:
              - my-instance
          topologyKey: kubernetes.io/hostname
        weight: 1
...
messaging:
  affinity:
    podAntiAffinity:
      preferredDuringSchedulingIgnoredDuringExecution:
      - podAffinityTerm:
          labelSelector:
            matchExpressions:
            - key: cdap.container.Messaging
              operator: In
              values:
              - my-instance
          topologyKey: kubernetes.io/hostname
        weight: 1
...

...