1
votes

I am now testing the deployment into different namespace using Kubernetes. Here I am using Kubernetes Helm Chart for that. In my chart, I have deployment.yaml and service.yaml.

When I am defining the "namespace" parameter with Helm command helm install --upgrade, it is not working. When I a read about that I found the statement that - "Helm 2 is not overwritten by the --namespace parameter".

I tried the following command:

helm upgrade --install kubedeploy --namespace=test pipeline/spacestudychart 

NB Here my service is deploying with default namespace.

Screenshot of describe pod:

enter image description here

Here my "helm version" command output is like follows:

docker@mildevdcr01:~$ helm version
Client: &version.Version{SemVer:"v2.14.3", 
GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.14.3", 
GitCommit:"0e7f3b6637f7af8fcfddb3d2941fcc7cbebb0085", GitTreeState:"clean"}

Because of this reason, I tried to addthis command in deployment.yaml, under metadata.namespace like following,

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "spacestudychart.fullname" . }}
  namespace: test

I created test and prod, 2 namespaces. But here also it's not working. When I adding like this, I am not getting my service up. I am not able to accessible. And in Jenkins console there is no error. When I defined in helm install --upgrade command it was deploying with default namespace. But here not deploying also.

After this, I removed the namespace from deployment.yaml and added metadata.namespace like the same. There also I am not able to access deployed service. But Jenkins console output still showing success.

Why namespace is not working with my Helm deployment? What changes I need to do here for deploying test/prod instead of this default namespace.

2

2 Answers

2
votes

Remove namespace: test from all your chart files and helm install --namesapce=namespace2 ... should work

0
votes

On Helm 3.2+, I would suggest (based on this thread) to move the namespace creation to the CLI:

1 ) Add the --create-namespace after the -n flag:

helm upgrade --install <name> <repo> -n <namespace> --create-namespace

2 ) Inside the different resources - pass the Release namespace:

namespace: {{ .Release.Namespace }}