- .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 Configuration
class, responsible for managing various configuration settings related to interacting with a Kubernetes API. Here’s a breakdown:
Core Configuration Properties:
host
: The base URL of the Kubernetes API server. Defaults tohttp://localhost
.api_key
: A dictionary storing API key values. The keys of this dictionary correspond to security scheme names defined in the OpenAPI specification, and the values are the secret API key strings.api_key_prefix
: A dictionary for storing API key prefixes (like “Bearer”). Similar structure toapi_key
, but stores prefixes instead of keys.username
&password
: Used for basic HTTP authentication.discard_unknown_keys
: A boolean flag controlling whether to discard unknown properties received from the API server. This helps handle situations where the OpenAPI specification doesn’t fully match the server implementation.temp_folder_path
: Specifies a folder for storing temporary files, useful for downloading files from the API.
Logging Configuration:
logger
: A dictionary storing logging objects. This allows fine-grained logging control for different components of the code.logger_format
: Sets the format of log messages.logger_stream_handler
: Handles log output to the console.logger_file_handler
: Handles log output to a file, controlled by thelogger_file
property.logger_file
: Specifies the path of the log file.
HTTP Client Settings:
verify_ssl
: Controls whether SSL/TLS certificate verification is enabled. Set toFalse
to disable verification.ssl_ca_cert
: Allows customizing the CA certificate used for verifying the server’s certificate.cert_file
&key_file
: Specify client certificate and key files for client-side SSL authentication.assert_hostname
: Enables/disables hostname verification during SSL handshakes.tls_server_name
: Allows setting the SNI (Server Name Indication) value for TLS connections.connection_pool_maxsize
: Controls the maximum number of connections in urllib3’s connection pool.proxy
: Sets a proxy URL for HTTP requests.no_proxy
: Specifies a list of hosts to exclude from using the proxy.proxy_headers
: Adds custom headers to requests going through the proxy.safe_chars_for_path_param
: Specifies characters considered safe for use in URL path parameters.retries
: Overrides the default retry count for urllib3 requests.
API Key Management:
get_api_key_with_prefix
: Fetches an API key (and its prefix) from theapi_key
andapi_key_prefix
dictionaries based on the provided identifier.get_basic_auth_token
: Constructs the HTTP Basic authentication header.auth_settings
: Returns a dictionary describing the authentication settings for the API client.
Utility Methods:
to_debug_report
: Returns a string with essential debugging information about the Python SDK.get_host_settings
: Provides an array of host settings (likely used for selecting different API endpoints).get_host_from_settings
: Constructs a complete host URL based on the given index in the host settings and any provided variables.
Key Considerations:
- Default Configuration: The class provides methods for setting a default configuration (using
set_default
) and retrieving a copy of it (usingget_default_copy
). This is useful for standardizing settings across multiple instances of the client. - Logging: The class offers flexible logging control, allowing developers to configure log levels, formats, and output destinations.
- API Key Management: The class provides mechanisms for storing, retrieving, and prefixing API keys.
- HTTP Client Customization: The class allows for extensive customization of HTTP client behavior, including SSL configuration, proxy settings, retry policies, and connection pooling.
The Configuration
class provides a comprehensive framework for configuring the Kubernetes Python client. By properly utilizing its features, developers can streamline the process of interacting with the Kubernetes API and tailor the client’s behavior to suit their specific needs.
Graph
The graph shows the usage of functions within the codebase.
Select a code symbol to view it's graph