- .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 class called V2MetricSpec
within the kubernetes.client.models
module. This class models a Kubernetes v2 Metric Specification, which is used to define the desired scaling behavior of a Kubernetes resource based on a specific metric.
The class contains several attributes, each corresponding to a different type of metric source:
container_resource
: AV2ContainerResourceMetricSource
object, representing a metric based on a container’s resource usage.external
: AV2ExternalMetricSource
object, representing a metric from an external system.object
: AV2ObjectMetricSource
object, representing a metric based on the usage of a specific object, like a deployment or service.pods
: AV2PodsMetricSource
object, representing a metric based on the number of pods in a certain state.resource
: AV2ResourceMetricSource
object, representing a metric based on the overall resource usage (CPU, memory, etc.) across all pods in a deployment.type
: A string representing the type of metric source being used. This must match one of the fields mentioned above (e.g., ‘ContainerResource’, ‘External’, etc.).
The class provides getter and setter methods (@property
decorators) for each attribute. This allows accessing and modifying the object’s attributes in a controlled manner.
The __init__
method initializes a new V2MetricSpec
object. It takes optional parameters for each of the metric source types. It also takes a local_vars_configuration
parameter, which is used to configure the client’s behavior (e.g., for setting API version or headers).
The to_dict()
method converts the object to a dictionary representation, while the to_str()
method converts it to a string. The __repr__
method returns the string representation for use with print
and pprint
. Finally, the __eq__
and __ne__
methods implement equality and inequality comparisons, respectively.
In summary, the V2MetricSpec
class serves as a blueprint for defining various metric sources that can be used for automated scaling in Kubernetes deployments. It encapsulates the necessary information about each type of metric source, simplifying the process of configuring scaling rules for your applications.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph