- .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 V1ResourceQuotaSpec
that represents a Kubernetes resource quota specification. It’s part of the Kubernetes client library for Python.
Here’s a breakdown of the code:
Class Definition:
V1ResourceQuotaSpec
: This class defines the structure of a resource quota specification. It’s used to specify limits on various resources within a Kubernetes namespace.
Attributes:
hard
: A dictionary that defines the hard limits for each resource. The keys are the resource names (e.g., “cpu”, “memory”), and the values are the limit values (e.g., “2”, “5Gi”).scope_selector
: AV1ScopeSelector
object that defines a scope selector for the resource quota. This allows you to target specific kinds of resources.scopes
: A list of strings representing resource scopes that are subject to this quota. Each string is a resource type (e.g., “pods”, “services”, “replicationcontrollers”).
Methods:
__init__(self, hard=None, scope_selector=None, scopes=None, local_vars_configuration=None)
: The constructor initializes the object with optional values forhard
,scope_selector
, andscopes
.hard()
: A getter method to retrieve thehard
attribute.hard(self, hard)
: A setter method to update thehard
attribute.scope_selector()
: A getter method to retrieve thescope_selector
attribute.scope_selector(self, scope_selector)
: A setter method to update thescope_selector
attribute.scopes()
: A getter method to retrieve thescopes
attribute.scopes(self, scopes)
: A setter method to update thescopes
attribute.to_dict()
: A method to convert the object into a dictionary representation.to_str()
: A method to convert the object into a string representation.__repr__()
: A method that returns a string representation of the object for use withprint
andpprint
.__eq__(self, other)
: A method to compare the object with another object for equality.__ne__(self, other)
: A method to compare the object with another object for inequality.
Usage:
This class is used by the Kubernetes client library to represent and work with resource quota specifications. For example, you could create an instance of V1ResourceQuotaSpec
and set the hard limits for various resources:
from kubernetes.client.models.v1_resource_quota_spec import V1ResourceQuotaSpec
quota_spec = V1ResourceQuotaSpec(
hard={"cpu": "2", "memory": "5Gi"},
scopes=["pods", "services"]
)
This quota_spec
object would then be used when creating or updating a resource quota object in Kubernetes.
Key Points:
- This class provides a way to define limits on resource consumption within a Kubernetes namespace.
- The
hard
attribute allows specifying maximum limits for various resource types, ensuring resource availability and preventing excessive resource usage. - The
scope_selector
andscopes
attributes allow for targeting specific types of resources to be subject to the quota. - The Kubernetes client library uses this class to work with resource quota specifications, allowing for automated creation, update, and management of resource quotas.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph