- .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 code defines a Python class V1SuccessPolicyRule
which represents a success policy rule for Kubernetes Jobs. It’s likely used to specify how many pods or specific pods must succeed for a Job to be considered successful. Here’s a breakdown:
Key Attributes:
succeeded_count
(int): This attribute represents the minimum number of pods that must succeed for the Job to be considered successful. If it’sNone
, the count is not evaluated. If specified, it must be a positive integer.succeeded_indexes
(str): This attribute represents a comma-separated list of indexes that must be in the set of pods that succeeded for the Job to be successful.- The indexes are specified as intervals, either a single decimal integer or a pair of decimal integers separated by a hyphen, representing a range.
- For example, “1,3-5,7” means that pods with indexes 1, 3, 4, 5, and 7 must be successful.
- If it’s
None
, this attribute is not evaluated.
How It Works:
__init__
: The constructor takes optional arguments forsucceeded_count
andsucceeded_indexes
, initializing the corresponding attributes.to_dict
: This method converts the instance ofV1SuccessPolicyRule
into a dictionary representation, which can be useful for serialization.to_str
: This method provides a string representation of the instance, useful for debugging.__repr__
: This method is used forprint
andpprint
, also returning a string representation.__eq__
and__ne__
: These methods define how equality and inequality are determined for twoV1SuccessPolicyRule
instances.
Usage:
The V1SuccessPolicyRule
object would be used within the definition of a Kubernetes Job, allowing you to define specific success criteria. For example, you could use it to:
- Ensure that at least a certain number of pods succeed.
- Ensure that specific pods within a Job are successful.
Example:
from kubernetes.client.models import V1SuccessPolicyRule
success_policy = V1SuccessPolicyRule(
succeeded_count=3,
succeeded_indexes="1,3-5"
)
This success policy would require that at least 3 pods are successful, and those pods must have indexes 1, 3, 4, and 5.
Note: This code is likely generated automatically from a Kubernetes API specification, which means its purpose and functionality are tightly tied to the Kubernetes API and the structure of Job objects.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph