<p>I am trying to deploy my microservice on a Kuberenetes cluster in 2 different environment dev and test. And I am using helm chart to deploy my Kubernetes service. I am using Jenkinsfile to deploy the chart. And inside Jenkinsfile I added helm command within the stage like the following ,</p>

<pre><code>stage ('helmchartinstall')
                {
                    steps
                    {
                        sh 'helm upgrade --install kubekubedeploy --namespace test pipeline/spacestudychart'
                    }
                }
             }
</code></pre>

<p>Here I am defining the <code>--namespace</code> test parameter. But when it deploying, it showing the console output with default namespace. I already created namespaces test and prod.</p>

<p>When I checked the Helm version, I got response like the following,</p>

<pre><code>docker@mildevdcr01:~$ helm version
Client: &amp;version.Version{SemVer:"v2.14.1", 
GitCommit:"5270352a09c7e8b6e8c9593002a73535276507c0", GitTreeState:"clean"}
Server: &amp;version.Version{SemVer:"v2.14.0", 
GitCommit:"05811b84a3f93603dd6c2fcfe57944dfa7ab7fd0", GitTreeState:"clean"}
</code></pre>

<p>Have I made any mistake here for defining the namespace?</p>

<p>The most likely issue here is that the Chart already specifies <code>default</code> as <code>metadata.namespace</code> which in Helm 2 is not overwritten by the <code>--namespace</code> parameter.</p>

<p>If this is the cause a solution would be to remove the namespace specified in the <code>metadata.namespace</code> or to make it a template parameter (aka release <code>value</code>). </p>

<p>Also see <a href="https://stackoverflow.com/a/51137448/1977182">https://stackoverflow.com/a/51137448/1977182</a>. </p>
