pub struct Config {
    pub cluster_url: Uri,
    pub default_namespace: String,
    pub root_cert: Option<Vec<Vec<u8, Global>, Global>>,
    pub connect_timeout: Option<Duration>,
    pub read_timeout: Option<Duration>,
    pub write_timeout: Option<Duration>,
    pub timeout: Option<Duration>,
    pub accept_invalid_certs: bool,
    pub auth_info: AuthInfo,
    pub proxy_url: Option<Uri>,
}
Available on crate feature config only.
Expand description

Configuration object detailing things like cluster URL, default namespace, root certificates, and timeouts.

Usage

Construct a Config instance by using one of the many constructors.

Prefer Config::infer unless you have particular issues, and avoid manually managing the data in this struct unless you have particular needs. It exists to be consumed by the Client.

If you are looking to parse the kubeconfig found in a user’s home directory see Kubeconfig.

Fields

cluster_url: Uri

The configured cluster url

default_namespace: String

The configured default namespace

root_cert: Option<Vec<Vec<u8, Global>, Global>>

The configured root certificate

connect_timeout: Option<Duration>

Set the timeout for connecting to the Kubernetes API.

A value of None means no timeout

read_timeout: Option<Duration>

Set the timeout for the Kubernetes API response.

A value of None means no timeout

write_timeout: Option<Duration>

Set the timeout for the Kubernetes API request.

A value of None means no timeout

timeout: Option<Duration>
👎Deprecated since 0.75.0:

replaced by more granular members connect_timeout, read_timeout and write_timeout. This member will be removed in 0.78.0.

Timeout for calls to the Kubernetes API.

A value of None means no timeout

accept_invalid_certs: bool

Whether to accept invalid certificates

auth_info: AuthInfo

Stores information to tell the cluster who you are.

proxy_url: Option<Uri>

Optional proxy URL.

Implementations

Construct a new config where only the cluster_url is set by the user. and everything else receives a default value.

Most likely you want to use Config::infer to infer the config from the environment.

Infer a Kubernetes client configuration.

First, a user’s kubeconfig is loaded from KUBECONFIG or ~/.kube/config. If that fails, an in-cluster config is loaded via Config::incluster. If inference from both sources fails, then an error is returned.

Config::apply_debug_overrides is used to augment the loaded configuration based on the environment.

Load an in-cluster Kubernetes client configuration using Config::incluster_dns.

The rustls-tls feature is currently incompatible with Config::incluster_env. See https://github.com/kube-rs/kube-rs/issues/1003.

Load an in-cluster config using the KUBERNETES_SERVICE_HOST and KUBERNETES_SERVICE_PORT environment variables.

A service account’s token must be available in /var/run/secrets/kubernetes.io/serviceaccount/.

This method matches the behavior of the official Kubernetes client libraries, but it is not compatible with the rustls-tls feature . When this feature is enabled, Config::incluster_dns should be used instead. See https://github.com/kube-rs/kube-rs/issues/1003.

Load an in-cluster config using the API server at https://kubernetes.default.svc.

A service account’s token must be available in /var/run/secrets/kubernetes.io/serviceaccount/.

This behavior does not match that of the official Kubernetes clients, but this approach is compatible with the rustls-tls feature.

Create configuration from the default local config file

This will respect the $KUBECONFIG evar, but otherwise default to ~/.kube/config. You can also customize what context/cluster/user you want to use here, but it will default to the current-context.

Create configuration from a Kubeconfig struct

This bypasses kube’s normal config parsing to obtain custom functionality.

Override configuration based on environment variables

This is only intended for use as a debugging aid, and the specific variables and their behaviour should not be considered stable across releases.

Currently, the following overrides are supported:

  • KUBE_RS_DEBUG_IMPERSONATE_USER: A Kubernetes user to impersonate, for example: system:serviceaccount:default:foo will impersonate the ServiceAccount foo in the Namespace default
  • KUBE_RS_DEBUG_IMPERSONATE_GROUP: A Kubernetes group to impersonate, multiple groups may be specified by separating them with commas
  • KUBE_RS_DEBUG_OVERRIDE_URL: A Kubernetes cluster URL to use rather than the one specified in the config, useful for proxying traffic through kubectl proxy

Trait Implementations

Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Layer to set the base URI of requests to the configured server.
Optional layer to set up Authorization header depending on the config.
Layer to add non-authn HTTP headers depending on the config.
Create native_tls::TlsConnector based on config. Read more
Create [hyper_tls::HttpsConnector] based on config. Read more
Create [rustls::ClientConfig] based on config. Read more
Create [hyper_rustls::HttpsConnector] based on config. Read more
Create [openssl::ssl::SslConnectorBuilder] based on config. Read more
Create [hyper_openssl::HttpsConnector] based on config. Read more
Create [hyper_openssl::HttpsConnector] based on config and connector. Read more
Formats the value using the given formatter. Read more

Builds a default Client from a Config, see ClientBuilder if more customization is required

The type returned in the event of a conversion error.

Builds a default ClientBuilder stack from a given configuration

The type returned in the event of a conversion error.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self
The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.
Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more