Struct kube::Config

source · []
pub struct Config {
    pub cluster_url: Uri,
    pub default_namespace: String,
    pub root_cert: Option<Vec<Vec<u8, Global>, Global>>,
    pub timeout: Option<Duration>,
    pub accept_invalid_certs: bool,
    pub proxy_url: Option<Uri>,
    /* private fields */
}
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

timeout: Option<Duration>

Timeout for calls to the Kubernetes API.

A value of None means no timeout

accept_invalid_certs: bool

Whether to accept invalid certificates

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 the configuration from the environment

Done by attempting to load the local kubec-config first, and then if that fails, trying the in-cluster environment variables .

Fails if inference from both sources fails

Applies debug overrides, see Config::apply_debug_overrides for more details

Create configuration from the cluster’s environment variables

This follows the standard API Access from a Pod and relies on you having the service account’s token mounted, as well as having given the service account rbac access to do what you need.

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 ClientBuilder stack from a given configuration

The type returned in the event of a conversion error.

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

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

🔬 This is a nightly-only experimental API. (toowned_clone_into)

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