From 9ddcc8470c7ed6a2cbddfb079b6396bb58436827 Mon Sep 17 00:00:00 2001 From: "Frank A. Zdarsky" Date: Mon, 19 Mar 2018 19:08:16 +0100 Subject: make kube2msb use pod secret Issue-ID: OOM-811 Change-Id: I039b6bcc9a301751ba976b77c0f2cc3b904b8e9c Signed-off-by: Frank A. Zdarsky --- build/docker/Dockerfile | 2 +- src/kube2msb/kube2msb.go | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/build/docker/Dockerfile b/build/docker/Dockerfile index 849b07e..f25e592 100644 --- a/build/docker/Dockerfile +++ b/build/docker/Dockerfile @@ -1,4 +1,4 @@ FROM alpine:3.3 COPY kube2msb /bin/ -ENTRYPOINT /bin/kube2msb --kube_master_url=${KUBE_MASTER_URL} --msb_url=${MSB_URL} \ No newline at end of file +ENTRYPOINT /bin/kube2msb --kube_master_url=${KUBE_MASTER_URL} --auth_token=$(cat /var/run/secrets/kubernetes.io/serviceaccount/token) --msb_url=${MSB_URL} diff --git a/src/kube2msb/kube2msb.go b/src/kube2msb/kube2msb.go index 2d39b77..4dac06d 100644 --- a/src/kube2msb/kube2msb.go +++ b/src/kube2msb/kube2msb.go @@ -36,6 +36,7 @@ import ( var ( argMSBUrl = flag.String("msb_url", "", "URL to MSB backend") argKubeMasterUrl = flag.String("kube_master_url", "", "Url to reach kubernetes master. Env variables in this flag will be expanded.") + argAuthToken = flag.String("auth_token", "", "Auth token for accessing Kube master.") addMap = make(map[string]*kapi.Pod) deleteMap = make(map[string]*kapi.Pod) nodeSelector = klabels.Everything() @@ -92,7 +93,10 @@ func newKubeClient() (*kclient.Client, error) { overrides := &kclientcmd.ConfigOverrides{} overrides.ClusterInfo.Server = masterUrl - if token, present := os.LookupEnv("AUTH_TOKEN"); present { + if *argAuthToken != "" { + overrides.AuthInfo.Token = *argAuthToken + overrides.ClusterInfo.InsecureSkipTLSVerify = true + } else if token, present := os.LookupEnv("AUTH_TOKEN"); present { overrides.AuthInfo.Token = token overrides.ClusterInfo.InsecureSkipTLSVerify = true } -- cgit 1.2.3-korg