diff --git a/examples/config.yaml b/examples/config.yaml index fa6647c..1442840 100644 --- a/examples/config.yaml +++ b/examples/config.yaml @@ -2,6 +2,9 @@ clusters: # Specify 1 or more clusters - name: example-cluster + # Default namespace (optional) + namespace: my-namespace + # Descriptions used in the WebUI short_description: "Example Cluster" description: "Example Cluster Long Description..." diff --git a/main.go b/main.go index d195f18..6fd7e80 100644 --- a/main.go +++ b/main.go @@ -56,6 +56,7 @@ func (d debugTransport) RoundTrip(req *http.Request) (*http.Response, error) { // Define each cluster type Cluster struct { Name string + Namespace string Short_Description string Description string Issuer string diff --git a/templates.go b/templates.go index c6ab1b1..e45608c 100644 --- a/templates.go +++ b/templates.go @@ -43,6 +43,7 @@ type templateData struct { Web_Path_Prefix string StaticContextName bool KubectlVersion string + Namespace string } func (cluster *Cluster) renderToken(w http.ResponseWriter, @@ -86,6 +87,7 @@ func (cluster *Cluster) renderToken(w http.ResponseWriter, LogoURI: logoURI, Web_Path_Prefix: webPathPrefix, StaticContextName: cluster.Static_Context_Name, + Namespace: cluster.Namespace, KubectlVersion: kubectlVersion} err = templates.ExecuteTemplate(w, "kubeconfig.html", token_data) diff --git a/templates/linux-mac-common.html b/templates/linux-mac-common.html index 3a79790..e4bd825 100644 --- a/templates/linux-mac-common.html +++ b/templates/linux-mac-common.html @@ -97,7 +97,7 @@

Run configuration commands

kubectl config set-context {{ if not .StaticContextName }}{{ .Username }}-{{ end }}{{ .ClusterName }} \
-    --cluster={{ .ClusterName }} \
+    --cluster={{ .ClusterName }}{{ if .Namespace }} --namespace={{ .Namespace }}{{ end }} \
     --user={{ .Username}}-{{.ClusterName }}