Skip to content

Commit

Permalink
try using cluster dns to reach apiserver - for #587
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Jul 21, 2021
1 parent e668ca0 commit 52dc95b
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions kube/src/config/incluster_config.rs
Expand Up @@ -4,19 +4,18 @@ use crate::{config::utils, Result};

pub const SERVICE_HOSTENV: &str = "KUBERNETES_SERVICE_HOST";
pub const SERVICE_PORTENV: &str = "KUBERNETES_SERVICE_PORT";
pub const SERVICE_DNS: &str = "kubernetes.default.svc";
const SERVICE_TOKENFILE: &str = "/var/run/secrets/kubernetes.io/serviceaccount/token";
const SERVICE_CERTFILE: &str = "/var/run/secrets/kubernetes.io/serviceaccount/ca.crt";
const SERVICE_DEFAULT_NS: &str = "/var/run/secrets/kubernetes.io/serviceaccount/namespace";

/// Returns Kubernetes address from specified environment variables.
pub fn kube_server() -> Option<String> {
let host = kube_host()?;
let port = kube_port()?;
Some(format!("https://{}:{}", host, port))
Some(SERVICE_DNS.into())
}

fn kube_host() -> Option<String> {
env::var(SERVICE_HOSTENV).ok()
env::var(SERVICE_DNS).ok()
}

fn kube_port() -> Option<String> {
Expand Down

0 comments on commit 52dc95b

Please sign in to comment.