pub fn from_cluster_env() -> Result<Self> {
        let cluster_url =
            incluster_config::kube_server().ok_or_else(|| ConfigError::MissingInClusterVariables {
                hostenv: incluster_config::SERVICE_HOSTENV,
                portenv: incluster_config::SERVICE_PORTENV,
            })?;
        let cluster_url = reqwest::Url::parse(&cluster_url)?;

        let default_ns = incluster_config::load_default_ns()
            .map_err(Box::new)
            .map_err(ConfigError::InvalidInClusterNamespace)?;

        let root_cert = incluster_config::load_cert()?;

        let token = incluster_config::load_token()
            .map_err(Box::new)
            .map_err(ConfigError::InvalidInClusterToken)?;

        Ok(Self {
            cluster_url,
            default_ns,
            root_cert: Some(root_cert),
            headers: HeaderMap::new(),
            timeout: Some(DEFAULT_TIMEOUT),
            accept_invalid_certs: false,
            proxy: None,
            identity: None,
            auth_header: Authentication::Token(format!("Bearer {}", token)),
        })
    }
/// Create configuration from the cluster's environment variables
///
/// This follows the standard [API Access from a Pod](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-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 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 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 .
pub fn from_cluster_env() -> Result<Self> {
        let cluster_url =
            incluster_config::kube_server().ok_or_else(|| ConfigError::MissingInClusterVariables {
                hostenv: incluster_config::SERVICE_HOSTENV,
                portenv: incluster_config::SERVICE_PORTENV,
            })?;
        let cluster_url = reqwest::Url::parse(&cluster_url)?;
        let default_ns = incluster_config::load_default_ns()
            .map_err(Box::new)
            .map_err(ConfigError::InvalidInClusterNamespace)?;
        let root_cert = incluster_config::load_cert()?;
        let token = incluster_config::load_token()
            .map_err(Box::new)
            .map_err(ConfigError::InvalidInClusterToken)?;
        Ok(Self {
            cluster_url,
            default_ns,
            root_cert: Some(root_cert),
            headers: HeaderMap::new(),
            timeout: Some(DEFAULT_TIMEOUT),
            accept_invalid_certs: false,
            proxy: None,
            identity: None,
            auth_header: Authentication::Token(format!("Bearer {}", token)),
        })
    }
pub fn from_cluster_env ( ) -> Result < Self > { let cluster_url = incluster_config :: kube_server ( ) . ok_or_else ( | | ConfigError :: MissingInClusterVariables { hostenv : incluster_config :: SERVICE_HOSTENV , portenv : incluster_config :: SERVICE_PORTENV , } ) ? ; let cluster_url = reqwest :: Url :: parse ( & cluster_url ) ? ; let default_ns = incluster_config :: load_default_ns ( ) . map_err ( Box :: new ) . map_err ( ConfigError :: InvalidInClusterNamespace ) ? ; let root_cert = incluster_config :: load_cert ( ) ? ; let token = incluster_config :: load_token ( ) . map_err ( Box :: new ) . map_err ( ConfigError :: InvalidInClusterToken ) ? ; Ok ( Self { cluster_url , default_ns , root_cert : Some ( root_cert ) , headers : HeaderMap :: new ( ) , timeout : Some ( DEFAULT_TIMEOUT ) , accept_invalid_certs : false , proxy : None , identity : None , auth_header : Authentication :: Token ( format ! ( " " token ) ) , } ) }
Create configuration from the cluster's environment variables
This follows the standard [API Access from a Pod](https://kubernetes.io/docs/tasks/access-application-cluster/access-cluster/#accessing-the-api-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 cluster ' s environment variables This follows the standard [ API Access from a Pod ] ( https : // kubernetes . io / docs / tasks / access - application - cluster / access - cluster / #accessing - the - api - 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 .