<p>How can I expose the K8S Namespace Name to an environment variable in Kubernetes deployment file?</p>
<p>This section is from my deployment yaml:</p>
<pre><code>        - name: JAVA_OPTIONS # Jetty JAVA_OPTIONS
          value: &gt;-
            -server
            -Xms$(MIN_MEMORY) -Xmx$(MAX_MEMORY) -XX:+UseG1GC -XX:MaxGCPauseMillis=500 
-Dsun.zip.disableMemoryMapping=true    
-Dpod.name=$(POD_NAME) -Dsome.key.tags=$(POD_NAME),[K8S_NAMESPACE_NAME]
</code></pre>
<p>is there a system variable I can use to add it to</p>
<pre><code>some.key.tags=$(POD_NAME),[K8S_NAMESPACE_NAME]
</code></pre>
<p>If not, I think I have in on my Kustomization.yaml file</p>
<pre><code>namespace: default
</code></pre>
<p>maybe I can read it in the deployment yaml from the Kustomization.yaml ?</p>

Hard Worker
<p>You can define an environment variable for your container:
and then you can read it using</p>
<p>some.key.tags=$(POD_NAME),$(NAMESPACE)</p>
<pre><code>- name: NAMESPACE
  valueFrom:
    fieldRef:
      fieldPath: metadata.namespace
</code></pre>
