From 01fe548abd2aae07584fd339ba65dfdbfc0c65d3 Mon Sep 17 00:00:00 2001 From: Matt Jibson Date: Fri, 13 Nov 2015 17:05:14 -0500 Subject: [PATCH] Use env vars to set k8s endpoint URL The old DNS method is optionally enabled in k8s, but the env vars are always there. partial solution to #864 --- util/config/provider/k8sprovider.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/util/config/provider/k8sprovider.py b/util/config/provider/k8sprovider.py index 7fac1b179..78702b9c1 100644 --- a/util/config/provider/k8sprovider.py +++ b/util/config/provider/k8sprovider.py @@ -10,7 +10,10 @@ from util.config.provider.fileprovider import FileConfigProvider logger = logging.getLogger(__name__) -KUBERNETES_API_HOST = 'kubernetes.default.svc.cluster.local' +KUBERNETES_API_HOST = os.environ.get('KUBERNETES_SERVICE_HOST', '') +port = os.environ.get('KUBERNETES_SERVICE_PORT') +if port: + KUBERNETES_API_HOST += ':' + port SERVICE_ACCOUNT_TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token'