Skip to content

Commit

Permalink
feat: Use env var for namespace (#829)
Browse files Browse the repository at this point in the history
Signed-off-by: Ce Gao <gaoce@caicloud.io>
  • Loading branch information
gaocegege authored and k8s-ci-robot committed Sep 27, 2019
1 parent cad5060 commit 92069c2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 5 additions & 0 deletions manifests/v1alpha3/ui/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ spec:
imagePullPolicy: IfNotPresent
command:
- './katib-ui'
env:
- name: KATIB_CORE_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: ui
containerPort: 80
Expand Down
5 changes: 1 addition & 4 deletions pkg/util/v1alpha3/katibclient/katib_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ package katibclient

import (
"context"
"io/ioutil"
"strings"

apiv1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/types"
Expand Down Expand Up @@ -174,8 +172,7 @@ func (k *KatibClient) UpdateTrialTemplates(newTrialTemplates map[string]string,

func getNamespace(namespace ...string) string {
if len(namespace) == 0 {
data, _ := ioutil.ReadFile("/var/run/secrets/kubernetes.io/serviceaccount/namespace")
return strings.TrimSpace(string(data))
return consts.DefaultKatibNamespace
}
return namespace[0]
}

0 comments on commit 92069c2

Please sign in to comment.