kubernetes_asyncio.config.kube_config module
- class kubernetes_asyncio.config.kube_config.ConfigNode(name: str, value: Any, path: str | None = None)
Bases:
objectRemembers each config key’s path and construct a relevant exception message in case of missing keys. The assumption is all access keys are present in a well-formed kube-config.
- get_with_name(name, safe=False) ConfigNode | None
- safe_get(key: str | int) Any
- class kubernetes_asyncio.config.kube_config.FileOrData(obj, file_key_name, data_key_name=None, file_base_path='', base64_file_content=True, temp_file_path=None)
Bases:
objectUtility class to read content of obj[%data_key_name] or file’s content of obj[%file_key_name] and represent it as file or data. Note that the data is preferred. The obj[%file_key_name] will be used iff obj[‘%data_key_name’] is not set or empty. Assumption is file content is raw data and data field is base64 string. The assumption can be changed with base64_file_content flag. If set to False, the content of the file will assumed to be base64 and read as is. The default True value will result in base64 encode of the file content after read.
- as_data() str | None
If obj[%data_key_name] exists, Return obj[%data_key_name] otherwise base64 encoded string of obj[%file_key_name] file content.
- as_file() str | None
If obj[%data_key_name] exists, return name of a file with base64 decoded obj[%data_key_name] content otherwise obj[%file_key_name].
- class kubernetes_asyncio.config.kube_config.KubeConfigLoader(config_dict: Any, active_context=None, get_google_credentials=None, config_base_path: str | None = '', config_persister=None, temp_file_path=None)
Bases:
object- property current_context: Any | None
- list_contexts() list[Any]
- async load_and_set(client_configuration) None
- async load_from_exec_plugin() bool
- async load_gcp_token() str
- set_active_context(context_name=None)
- class kubernetes_asyncio.config.kube_config.KubeConfigMerger(paths: str)
Bases:
objectReads and merges configuration from one or more kube-config’s. The propery config can be passed to the KubeConfigLoader as config_dict. It uses a path attribute from ConfigNode to store the path to kubeconfig. This path is required to load certs from relative paths. A method save_changes updates changed kubeconfig’s (it compares current state of dicts with).
- property config: ConfigNode | None
- load_config(path) None
- save_changes() None
- save_config(path) None
- kubernetes_asyncio.config.kube_config.list_kube_config_contexts(config_file: str | None = None) tuple[list[Any], Any | None]
- async kubernetes_asyncio.config.kube_config.load_kube_config(config_file=None, context=None, client_configuration=None, persist_config=True, temp_file_path=None) KubeConfigLoader
Loads authentication and cluster information from kube-config file and stores them in kubernetes.client.configuration.
- Parameters:
config_file – Name of the kube-config file.
context – set the active context. If is set to None, current_context from config file will be used.
client_configuration – The kubernetes.client.Configuration to set configs to.
persist_config – If True, config file will be updated when changed (e.g GCP token refresh).
temp_file_path – directory where temp files are stored (default - system temp dir).
- async kubernetes_asyncio.config.kube_config.load_kube_config_from_dict(config_dict, context=None, client_configuration=None, temp_file_path=None) KubeConfigLoader
Loads authentication and cluster information from config_dict and stores them in kubernetes.client.configuration.
- Parameters:
config_dict – Takes the config file as a dict.
context – set the active context. If is set to None, current_context from config file will be used.
client_configuration – The kubernetes_asyncio.client.Configuration to set configs to.
temp_file_path – directory where temp files are stored (default - system temp dir).
- async kubernetes_asyncio.config.kube_config.new_client_from_config(config_file=None, context=None, persist_config=True, temp_file_path=None) ApiClient
Loads configuration the same as load_kube_config but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.
- async kubernetes_asyncio.config.kube_config.new_client_from_config_dict(config_dict=None, context=None, temp_file_path=None) ApiClient
Loads configuration the same as load_kube_config_dict but returns an ApiClient to be used with any API object. This will allow the caller to concurrently talk with multiple clusters.
- async kubernetes_asyncio.config.kube_config.refresh_token(loader, client_configuration=None, interval=60) None
Refresh token if necessary, updates the token in client configurarion
- Parameters:
loader – KubeConfigLoader returned by load_kube_config
client_configuration – The kubernetes.client.Configuration to set configs to.
interval – how often check if token is up-to-date