Make sure to keep other files in kube-proxy ConfigMap

The data was being overwritten with the new file map,
which caused the "config.conf" file to be deleted (!).

Compared to the original "kubeconfig.conf" generated,
the template also inserted an extra newline character.
pull/2406/head
Anders F Björklund 2018-01-07 16:05:16 +01:00 committed by dlorenc
parent fd410549b5
commit fc9fe5fa21
1 changed files with 4 additions and 3 deletions

View File

@ -20,6 +20,7 @@ import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"html/template" "html/template"
"strings"
"github.com/golang/glog" "github.com/golang/glog"
"github.com/pkg/errors" "github.com/pkg/errors"
@ -175,11 +176,11 @@ func restartKubeProxy(k8s bootstrapper.KubernetesConfig) error {
return errors.Wrap(err, "executing kube proxy configmap template") return errors.Wrap(err, "executing kube proxy configmap template")
} }
data := map[string]string{ if cfgMap.Data == nil {
kubeconfigConf: kubeconfig.String(), cfgMap.Data = map[string]string{}
} }
cfgMap.Data[kubeconfigConf] = strings.TrimSuffix(kubeconfig.String(), "\n")
cfgMap.Data = data
if _, err := client.CoreV1().ConfigMaps("kube-system").Update(cfgMap); err != nil { if _, err := client.CoreV1().ConfigMaps("kube-system").Update(cfgMap); err != nil {
return errors.Wrap(err, "updating configmap") return errors.Wrap(err, "updating configmap")
} }