<p>I have yaml file which use to deploy my application in all the environments. I want to add some JVM args only for test environment . is there anyway i can do it in YAML file?</p>
<p>here is the yaml</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: rss-site
  labels:
    app: web
spec:
  containers:
    - name: front-end
      image: nginx
      ports:
        - containerPort: 80
    - name: rss-reader
      image: nickchase/rss-php-nginx:v1
      ports:
        - containerPort: 88
      env:
       - name: JAVA_OPTS
         value: &quot;
                -Dlog4j.configurationFile=log4j2.xml
                -Denable.scan=true

                &quot;
</code></pre>
<p>here i want <code> -Denable.scan=true</code> to be conditional and should add only for Test environment .</p>
<p>I tried following way but it not working and kubernete throwing error <code>error converting YAML to JSON: yaml: line 53: did not find expected key</code></p>
<p>Tried:-</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: rss-site
  labels:
    app: web
spec:
  containers:
    - name: front-end
      image: nginx
      ports:
        - containerPort: 80
    - name: rss-reader
      image: nickchase/rss-php-nginx:v1
      ports:
        - containerPort: 88
      env:
       - name: JAVA_OPTS
         value: &quot;
                -Dlog4j.configurationFile=log4j2.xml
                ${{if eq &quot;TEST&quot; &quot;TEST&quot; }} # just sample condition , it will change
                -Denable.scan=true
                 ${{end }}

                &quot;
</code></pre>

<p><code>helm</code> will do that. In fact, the syntax is almost identical to what you've put, and would be something like this:</p>
<pre class="lang-yaml prettyprint-override"><code>      env:
       - name: JAVA_OPTS
         value: &quot;
                -Dlog4j.configurationFile=log4j2.xml
                 {{- if eq .Values.profile &quot;TEST&quot; }}
                -Denable.scan=true
                 {{- end }}

                &quot;
</code></pre>
<p>And you declare via the install package (called a Chart) which profile you want to use (i.e. you set the <code>.Values.profile</code> value)</p>
<p>You can check out <a href="https://helm.sh/" rel="nofollow noreferrer">https://helm.sh/</a> for details and examples</p>
