Look for secrets in the deployed namespace

This commit is contained in:
Sergey Dudoladov
2018-02-14 15:37:30 +01:00
parent 5837015b3c
commit d5d15b7546
4 changed files with 50 additions and 21 deletions
+1 -12
View File
@@ -2,7 +2,6 @@ package main
import (
"flag"
"io/ioutil"
"log"
"os"
"os/signal"
@@ -14,11 +13,6 @@ import (
"github.com/zalando-incubator/postgres-operator/pkg/util/k8sutil"
)
const (
// assumes serviceaccount secret is mounted by kubernetes
fileWithNamespace = "/var/run/secrets/kubernetes.io/serviceaccount/namespace"
)
var (
kubeConfigFile string
outOfCluster bool
@@ -33,15 +27,10 @@ func init() {
flag.BoolVar(&config.NoTeamsAPI, "noteamsapi", false, "Disable all access to the teams API")
flag.Parse()
operatorNamespaceBytes, err := ioutil.ReadFile(fileWithNamespace)
if err != nil {
log.Fatalf("Unable to detect operator namespace from within its pod due to %v", err)
}
configMapRawName := os.Getenv("CONFIG_MAP_NAME")
if configMapRawName != "" {
operatorNamespace := string(operatorNamespaceBytes)
operatorNamespace := spec.GetOperatorNamespace()
config.Namespace = operatorNamespace
namespacedConfigMapName := operatorNamespace + "/" + configMapRawName