- .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 class named V1Toleration
which represents a Kubernetes toleration object.
Tolerations are used in Kubernetes to allow pods to run on nodes that have taints applied to them. Taints are used to prevent pods from running on certain nodes unless they have a matching toleration.
Here’s a breakdown of the code:
Imports:
pprint
is used for pretty-printing.re
is used for regular expressions.six
provides compatibility for Python 2 and 3.kubernetes.client.configuration
is used to access the configuration object.Class Definition:
The
V1Toleration
class is defined with a few key attributes:openapi_types
: A dictionary mapping attribute names to their types.attribute_map
: A dictionary mapping attribute names to their JSON key names.The class initializes with several attributes representing the properties of a toleration:
effect
: Specifies the type of taint effect the toleration matches. It can beNoSchedule
,PreferNoSchedule
, orNoExecute
.key
: The taint key that the toleration applies to. An empty key means matching all keys.operator
: Defines the relationship between the taint key and value. It can beExists
(matches any value) orEqual
(matches a specific value).toleration_seconds
: Defines how long the toleration should be applied. By default, it’s unlimited, meaning the pod will tolerate the taint indefinitely.value
: The taint value the toleration matches. If the operator isExists
, the value should be empty.Property Getters and Setters:
For each attribute, the code defines a property getter (
@property
) and setter (@setter
). These methods encapsulate access to the attributes and ensure consistent behavior when setting values.The getter methods return the corresponding attribute value.
The setter methods validate and set the attribute value, ensuring that the data is valid and consistent with the expected format.
Utility Methods:
to_dict()
: This method converts theV1Toleration
object into a dictionary representation.to_str()
: This method returns a string representation of theV1Toleration
object.__repr__()
: This method defines the object’s string representation for debugging.__eq__()
: This method checks if twoV1Toleration
objects are equal based on their attributes.__ne__()
: This method checks if twoV1Toleration
objects are not equal.
Overall, this code provides a clear and well-structured representation of a Kubernetes toleration object. It leverages property accessors to ensure consistency and provides utility methods for serialization, string representation, and comparison.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph