k8s.config module¶
- class k8s.config.FileTokenSource(token_file, now_func=<built-in method now of type object>)[source]¶
Bases:
object
Read API token from token_file, exposing it via token(). Calls to token() will re-read the token from file if more than 1 minute has passed since the last read.
Intended to support the BoundServiceAccountTokenVolume feature in Kubernetes 1.21 and later.
- k8s.config.api_server = 'https://kubernetes.default.svc.cluster.local'¶
API server URL
- k8s.config.api_token = ''¶
API token
- k8s.config.cert = None¶
API certificate
- k8s.config.debug = False¶
Enable debugging
- k8s.config.stream_timeout = 270¶
Default timeout for streaming operations, used while waiting for more events. When reached, the library will usually info log and reconnect. There’s a few considerations when setting this value: * On some servers, it might take this long to detect a dropped connection. This speaks for a low value,
to detect the issue faster.
When connecting, a resourceVersion is used to resume, if still valid. This speaks for a low value, to avoid them expiring.
During idle periods, there might not be any new resourceVersions. Bookmarks events are used to avoid this, they are sent at a server specific interval, but usually about once per minute. This speaks for a high value.
4.5 minutes is the default, set to detect the first case above in a reasonable time, while being just below the default resourceVersion expiration of 5 minutes.
- k8s.config.timeout = 20¶
Default timeout for most operations
- k8s.config.use_in_cluster_config(token_file='/var/run/secrets/kubernetes.io/serviceaccount/token', ca_cert_file='/var/run/secrets/kubernetes.io/serviceaccount/ca.crt')[source]¶
Configure the client using the recommended configuration for accessing the API from within a Kubernetes cluster: https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-from-a-pod
- k8s.config.verify_ssl = True¶
Should the client verify the servers SSL certificates?
- k8s.config.watcher_cache_size = 1000¶
Default size of Watcher cache. If you expect a lot of events, you might want to increase this.