- .github
- devel
- doc
-
examples
-
dynamic-client
-
notebooks
-
watch
-
yaml_dir
- README.md
- __init__.py
- annotate_deployment.py
- api_discovery.py
- apply_from_dict.py
- apply_from_directory.py
- apply_from_single_file.py
- cluster_scoped_custom_object.py
- cronjob_crud.py
- deployment_create.py
- deployment_crud.py
- duration-gep2257.py
- in_cluster_config.py
- ingress_create.py
- job_crud.py
- multiple_clusters.py
- namespaced_custom_object.py
- node_labels.py
- out_of_cluster_config.py
- pick_kube_config_context.py
- pod_config_list.py
- pod_exec.py
- pod_portforward.py
- remote_cluster.py
- rollout-daemonset.py
- rollout-statefulset.py
-
dynamic-client
- kubernetes
- scripts
- .gitignore
- CHANGELOG.md
- CONTRIBUTING.md
- LICENSE
- MANIFEST.in
- OWNERS
- README.md
- SECURITY_CONTACTS
- code-of-conduct.md
- codecov.yml
- requirements.txt
- setup.cfg
- setup.py
- test-requirements.txt
- tox.ini
Explanation
This Python code defines a model named V1PodAffinity
representing a Kubernetes pod affinity. Pod affinity describes the scheduling preferences and constraints for where a pod can be placed.
- The model is auto-generated by OpenAPI Generator, which ensures compatibility with Kubernetes API specifications.
- It has two main attributes:
preferred_during_scheduling_ignored_during_execution
: Represents a list ofV1WeightedPodAffinityTerm
objects. These terms define “soft” affinity preferences, where the scheduler will try to fulfill them but is not obligated to.required_during_scheduling_ignored_during_execution
: Represents a list ofV1PodAffinityTerm
objects. These terms define “hard” affinity constraints, where the scheduler must meet them for a pod to be scheduled.
Key Functionality:
- Constructor: The
__init__
method initializes the object, optionally taking values for thepreferred_during_scheduling_ignored_during_execution
andrequired_during_scheduling_ignored_during_execution
attributes. - Property Accessors:
@property
decorators provide getter and setter methods for the two main attributes, ensuring that the values are validated and managed consistently. - Serialization: The
to_dict
,to_str
, and__repr__
methods provide ways to serialize the object into a dictionary, string representation, and a printable form for debugging. - Comparison: The
__eq__
and__ne__
methods define how to compare twoV1PodAffinity
objects based on their attributes.
Use Case:
The V1PodAffinity
model allows you to control the scheduling preferences and constraints for your pods. For example, you can use:
preferred_during_scheduling_ignored_during_execution
to encourage pods to be placed on nodes where other pods with specific labels already exist.required_during_scheduling_ignored_during_execution
to ensure pods are only placed on nodes where other pods with specific labels already exist.
This model is crucial for controlling pod placement within your Kubernetes clusters, influencing resource allocation and potentially enhancing pod communication or data locality.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph