Struct kube_client::Config
source · [−]pub struct Config {
pub cluster_url: Uri,
pub default_namespace: String,
pub root_cert: Option<Vec<Vec<u8>>>,
pub timeout: Option<Duration>,
pub accept_invalid_certs: bool,
pub proxy_url: Option<Uri>,
/* private fields */
}
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>>>
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
sourceimpl Config
impl Config
sourcepub fn new(cluster_url: Uri) -> Self
pub fn new(cluster_url: Uri) -> Self
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.
sourcepub async fn infer() -> Result<Self, InferConfigError>
pub async fn infer() -> Result<Self, InferConfigError>
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
sourcepub fn from_cluster_env() -> Result<Self, InClusterError>
pub fn from_cluster_env() -> Result<Self, InClusterError>
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.
sourcepub async fn from_kubeconfig(
options: &KubeConfigOptions
) -> Result<Self, KubeconfigError>
pub async fn from_kubeconfig(
options: &KubeConfigOptions
) -> Result<Self, KubeconfigError>
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.
sourcepub async fn from_custom_kubeconfig(
kubeconfig: Kubeconfig,
options: &KubeConfigOptions
) -> Result<Self, KubeconfigError>
pub async fn from_custom_kubeconfig(
kubeconfig: Kubeconfig,
options: &KubeConfigOptions
) -> Result<Self, KubeconfigError>
Create configuration from a Kubeconfig
struct
This bypasses kube’s normal config parsing to obtain custom functionality.
sourcepub fn apply_debug_overrides(&mut self)
pub fn apply_debug_overrides(&mut self)
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 theServiceAccount
foo
in theNamespace
default
KUBE_RS_DEBUG_IMPERSONATE_GROUP
: A Kubernetes group to impersonate, multiple groups may be specified by separating them with commasKUBE_RS_DEBUG_OVERRIDE_URL
: A Kubernetes cluster URL to use rather than the one specified in the config, useful for proxying traffic throughkubectl proxy
Trait Implementations
sourceimpl ConfigExt for Config
Available on crate feature client
only.
impl ConfigExt for Config
client
only.sourcefn base_uri_layer(&self) -> BaseUriLayer
fn base_uri_layer(&self) -> BaseUriLayer
Layer to set the base URI of requests to the configured server.
sourcefn auth_layer(&self) -> Result<Option<AuthLayer>>
fn auth_layer(&self) -> Result<Option<AuthLayer>>
Optional layer to set up Authorization
header depending on the config.
sourcefn extra_headers_layer(&self) -> Result<ExtraHeadersLayer>
fn extra_headers_layer(&self) -> Result<ExtraHeadersLayer>
Layer to add non-authn HTTP headers depending on the config.
sourcefn native_tls_connector(&self) -> Result<TlsConnector>
fn native_tls_connector(&self) -> Result<TlsConnector>
native-tls
only.Create native_tls::TlsConnector
based on config. Read more
sourcefn native_tls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
fn native_tls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
native-tls
only.Create hyper_tls::HttpsConnector
based on config. Read more
sourcefn rustls_client_config(&self) -> Result<ClientConfig>
fn rustls_client_config(&self) -> Result<ClientConfig>
rustls-tls
only.Create rustls::ClientConfig
based on config. Read more
sourcefn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
fn rustls_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
rustls-tls
only.Create hyper_rustls::HttpsConnector
based on config. Read more
sourcefn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder>
fn openssl_ssl_connector_builder(&self) -> Result<SslConnectorBuilder>
openssl-tls
only.Create openssl::ssl::SslConnectorBuilder
based on config. Read more
sourcefn openssl_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
fn openssl_https_connector(&self) -> Result<HttpsConnector<HttpConnector>>
openssl-tls
only.Create hyper_openssl::HttpsConnector
based on config. Read more
sourcefn openssl_https_connector_with_connector(
&self,
connector: HttpConnector
) -> Result<HttpsConnector<HttpConnector>>
fn openssl_https_connector_with_connector(
&self,
connector: HttpConnector
) -> Result<HttpsConnector<HttpConnector>>
openssl-tls
only.Create hyper_openssl::HttpsConnector
based on config and connector
. Read more
Auto Trait Implementations
impl RefUnwindSafe for Config
impl Send for Config
impl Sync for Config
impl Unpin for Config
impl UnwindSafe for Config
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
impl<V, T> VZip<V> for T where
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more