From ae425ed2ee2c7c0a5e4f758227829fe19c24d337 Mon Sep 17 00:00:00 2001 From: Ce Gao Date: Fri, 27 Sep 2019 16:24:21 +0800 Subject: [PATCH] feat: Use env var for namespace Signed-off-by: Ce Gao --- manifests/v1alpha3/ui/deployment.yaml | 5 +++++ pkg/util/v1alpha3/katibclient/katib_client.go | 5 +---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/manifests/v1alpha3/ui/deployment.yaml b/manifests/v1alpha3/ui/deployment.yaml index 67faa843a4e..1b38e333e3a 100644 --- a/manifests/v1alpha3/ui/deployment.yaml +++ b/manifests/v1alpha3/ui/deployment.yaml @@ -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 diff --git a/pkg/util/v1alpha3/katibclient/katib_client.go b/pkg/util/v1alpha3/katibclient/katib_client.go index df1253dcc7b..6b8eb5f311a 100644 --- a/pkg/util/v1alpha3/katibclient/katib_client.go +++ b/pkg/util/v1alpha3/katibclient/katib_client.go @@ -17,8 +17,6 @@ package katibclient import ( "context" - "io/ioutil" - "strings" apiv1 "k8s.io/api/core/v1" "k8s.io/apimachinery/pkg/types" @@ -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] }