Affinity#

pydantic model controller.models.domain.kubernetes.Affinity#

Pod affinity rules.

Parameters:

data (Any) –

Show JSON schema
{
   "title": "Affinity",
   "description": "Pod affinity rules.",
   "type": "object",
   "properties": {
      "nodeAffinity": {
         "anyOf": [
            {
               "$ref": "#/$defs/NodeAffinity"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Node affinity rules"
      },
      "podAffinity": {
         "anyOf": [
            {
               "$ref": "#/$defs/PodAffinity"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Pod affinity rules"
      },
      "podAntiAffinity": {
         "anyOf": [
            {
               "$ref": "#/$defs/PodAntiAffinity"
            },
            {
               "type": "null"
            }
         ],
         "default": null,
         "title": "Pod anti-affinity rules"
      }
   },
   "$defs": {
      "LabelSelector": {
         "additionalProperties": false,
         "description": "Rule for matching labels of pods or namespaces.\n\nAll provided expressions must match. (In other words, they are combined\nwith and.)",
         "properties": {
            "matchExpressions": {
               "default": [],
               "description": "Rules for matching labels",
               "items": {
                  "$ref": "#/$defs/LabelSelectorRequirement"
               },
               "title": "Label match expressions",
               "type": "array"
            },
            "matchLabels": {
               "additionalProperties": {
                  "type": "string"
               },
               "default": {},
               "description": "Label keys and values that must be set",
               "title": "Exact label matches",
               "type": "object"
            }
         },
         "title": "LabelSelector",
         "type": "object"
      },
      "LabelSelectorOperator": {
         "description": "Match operations for label selectors.",
         "enum": [
            "In",
            "NotIn",
            "Exists",
            "DoesNotExist"
         ],
         "title": "LabelSelectorOperator",
         "type": "string"
      },
      "LabelSelectorRequirement": {
         "additionalProperties": false,
         "description": "Single rule for label matching.",
         "properties": {
            "key": {
               "description": "Label key to match",
               "title": "Key",
               "type": "string"
            },
            "operator": {
               "allOf": [
                  {
                     "$ref": "#/$defs/LabelSelectorOperator"
                  }
               ],
               "description": "Label match operator",
               "title": "Operator"
            },
            "values": {
               "default": [],
               "description": "For ``In`` and ``NotIn``, matches any value in this list. For ``Exists`` or ``DoesNotExist``, must be empty.",
               "items": {
                  "type": "string"
               },
               "title": "Matching values",
               "type": "array"
            }
         },
         "required": [
            "key",
            "operator"
         ],
         "title": "LabelSelectorRequirement",
         "type": "object"
      },
      "NodeAffinity": {
         "additionalProperties": false,
         "description": "Node affinity rules.",
         "properties": {
            "preferredDuringSchedulingIgnoredDuringExecution": {
               "default": [],
               "description": "Preference rules used for scheduling and ignored afterwards",
               "items": {
                  "$ref": "#/$defs/PreferredSchedulingTerm"
               },
               "title": "Scheduling terms",
               "type": "array"
            },
            "requiredDuringSchedulingIgnoredDuringExecution": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/NodeSelector"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Required node selection rules",
               "title": "Node selectors"
            }
         },
         "title": "NodeAffinity",
         "type": "object"
      },
      "NodeSelector": {
         "additionalProperties": false,
         "description": "Matching terms for nodes.",
         "properties": {
            "nodeSelectorTerms": {
               "default": [],
               "description": "Matching terms for nodes",
               "items": {
                  "$ref": "#/$defs/NodeSelectorTerm"
               },
               "title": "Terms",
               "type": "array"
            }
         },
         "title": "NodeSelector",
         "type": "object"
      },
      "NodeSelectorOperator": {
         "description": "Match operations for node selectors.",
         "enum": [
            "In",
            "NotIn",
            "Exists",
            "DoesNotExist",
            "Gt",
            "Lt"
         ],
         "title": "NodeSelectorOperator",
         "type": "string"
      },
      "NodeSelectorRequirement": {
         "additionalProperties": false,
         "description": "Individual match rule for nodes.",
         "properties": {
            "key": {
               "description": "Label key to match",
               "title": "Key",
               "type": "string"
            },
            "operator": {
               "allOf": [
                  {
                     "$ref": "#/$defs/NodeSelectorOperator"
                  }
               ],
               "description": "Match operation to use",
               "title": "Operator"
            },
            "values": {
               "default": [],
               "description": "For ``In`` and ``NotIn``, matches any value in this list. For ``Gt`` or ``Lt``, must contain a single member interpreted as an integer. For ``Exists`` or ``DoesNotExist``, must be empty.",
               "items": {
                  "type": "string"
               },
               "title": "Matching values",
               "type": "array"
            }
         },
         "required": [
            "key",
            "operator"
         ],
         "title": "NodeSelectorRequirement",
         "type": "object"
      },
      "NodeSelectorTerm": {
         "additionalProperties": false,
         "description": "Term to match nodes.",
         "properties": {
            "matchExpressions": {
               "default": [],
               "description": "Matching rules applied to node labels",
               "items": {
                  "$ref": "#/$defs/NodeSelectorRequirement"
               },
               "title": "Rules for node labels",
               "type": "array"
            },
            "matchFields": {
               "default": [],
               "description": "Matching rules applied to node fields",
               "items": {
                  "$ref": "#/$defs/NodeSelectorRequirement"
               },
               "title": "Rules for node fields",
               "type": "array"
            }
         },
         "title": "NodeSelectorTerm",
         "type": "object"
      },
      "PodAffinity": {
         "additionalProperties": false,
         "description": "Pod affinity rules.",
         "properties": {
            "preferredDuringSchedulingIgnoredDuringExecution": {
               "default": [],
               "description": "Preference rules used for scheduling and ignored afterwards",
               "items": {
                  "$ref": "#/$defs/WeightedPodAffinityTerm"
               },
               "title": "Scheduling terms",
               "type": "array"
            },
            "requiredDuringSchedulingIgnoredDuringExecution": {
               "default": [],
               "description": "Required node selection rules",
               "items": {
                  "$ref": "#/$defs/PodAffinityTerm"
               },
               "title": "Node selectors",
               "type": "array"
            }
         },
         "title": "PodAffinity",
         "type": "object"
      },
      "PodAffinityTerm": {
         "additionalProperties": false,
         "description": "Pod matching term for pod affinity.",
         "properties": {
            "labelSelector": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/LabelSelector"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Match rules for pod labels",
               "title": "Pod label match"
            },
            "namespaceSelector": {
               "anyOf": [
                  {
                     "$ref": "#/$defs/LabelSelector"
                  },
                  {
                     "type": "null"
                  }
               ],
               "default": null,
               "description": "Match rules for namespace labels",
               "title": "Namespace label match"
            },
            "namespaces": {
               "default": [],
               "description": "List of namespaces to which this term applies. The term will apply to the union of this list of namespaces and any namespaces that match ``namespaceSelector``, if given. If both are empty, only the pod's namespace is matched.",
               "items": {
                  "type": "string"
               },
               "title": "Matching namespaces",
               "type": "array"
            },
            "topologyKey": {
               "description": "Name of the node label that should match between nodes to consider two pods to be scheduled on adjacent nodes, which in turn is the definition of an affinity (and the opposite of an anti-affinity).",
               "title": "Node topology label",
               "type": "string"
            }
         },
         "required": [
            "topologyKey"
         ],
         "title": "PodAffinityTerm",
         "type": "object"
      },
      "PodAntiAffinity": {
         "additionalProperties": false,
         "description": "Pod anti-affinity rules.\n\nNotes\n-----\nThis model is structurally identical to `PodAffinity`, but it has to\nconvert to a different Kubernetes model.",
         "properties": {
            "preferredDuringSchedulingIgnoredDuringExecution": {
               "default": [],
               "description": "Preference rules used for scheduling and ignored afterwards",
               "items": {
                  "$ref": "#/$defs/WeightedPodAffinityTerm"
               },
               "title": "Scheduling terms",
               "type": "array"
            },
            "requiredDuringSchedulingIgnoredDuringExecution": {
               "default": [],
               "description": "Required node selection rules",
               "items": {
                  "$ref": "#/$defs/PodAffinityTerm"
               },
               "title": "Node selectors",
               "type": "array"
            }
         },
         "title": "PodAntiAffinity",
         "type": "object"
      },
      "PreferredSchedulingTerm": {
         "additionalProperties": false,
         "description": "Scheduling term with a weight, used to find preferred nodes.",
         "properties": {
            "preference": {
               "allOf": [
                  {
                     "$ref": "#/$defs/NodeSelectorTerm"
                  }
               ],
               "description": "Selector term for a node",
               "title": "Node selector"
            },
            "weight": {
               "description": "Weight to assign to nodes matching this term",
               "title": "Weight",
               "type": "integer"
            }
         },
         "required": [
            "preference",
            "weight"
         ],
         "title": "PreferredSchedulingTerm",
         "type": "object"
      },
      "WeightedPodAffinityTerm": {
         "additionalProperties": false,
         "description": "Pod matching term for pod affinity with an associated weight.",
         "properties": {
            "podAffinityTerm": {
               "allOf": [
                  {
                     "$ref": "#/$defs/PodAffinityTerm"
                  }
               ],
               "description": "Pod affinity matching term",
               "title": "Matching term"
            },
            "weight": {
               "description": "Weight to associate with pods matching this term",
               "maximum": 100,
               "minimum": 1,
               "title": "Associated weight",
               "type": "integer"
            }
         },
         "required": [
            "podAffinityTerm",
            "weight"
         ],
         "title": "WeightedPodAffinityTerm",
         "type": "object"
      }
   },
   "additionalProperties": false
}

Fields:
field nodeAffinity: NodeAffinity | None = None (name 'node_affinity')#
field podAffinity: PodAffinity | None = None (name 'pod_affinity')#
field podAntiAffinity: PodAntiAffinity | None = None (name 'pod_anti_affinity')#
to_kubernetes()#

Convert to the corresponding Kubernetes model. :rtype: V1Affinity