<p>In my final <code>deployment.yaml</code> created from helm template I would like to have liveness and readiness blocks only if in <code>values.yaml</code> the block <code>.Values.livenessReadinessProbe</code> <strong>doesn't exist</strong> or if <code>.Values.livenessReadinessProbe.enabled</code> <strong>is true</strong>.</p>
<p>I tried to do it so:</p>
<pre><code>  {{- if or (not .Values.livenessReadinessProbe) (.Values.livenessReadinessProbe.enabled) }}
  livenessProbe:
    httpGet:
      path: /actuator/health/liveness
      port: 8080
    initialDelaySeconds: 300
    failureThreshold: 5
    periodSeconds: 10
  readinessProbe:
    httpGet:
      path: /actuator/health/readiness
      port: 8080
    initialDelaySeconds: 200
    failureThreshold: 5
    periodSeconds: 10
  {{- end }}
</code></pre>
<p>But I'm getting <code>nil pointer evaluating interface {}.enabled</code>, if <code>livenessReadinessProbe</code> is absent in <code>values.yaml</code>, so it seems like the second OR condition is being executed, even though the first condition is <code>true</code> (i.e. <code>.Values.livenessReadinessProbe</code> is absent).</p>
<p>How can I achieve it?</p>
<p>My <code>values.yaml</code> with existing <code>livenessReadinessProbe</code> value:</p>
<pre><code>livenessReadinessProbe:
  enabled: true
</code></pre>
<p>Thank you in advance!</p>

Georgii Lvov
<blockquote>
<p>I would like to have liveness and readiness blocks only if in
values.yaml the block .Values.livenessReadinessProbe doesn't exist or
if .Values.livenessReadinessProbe.enabled is true.</p>
</blockquote>
<p>You can test it <a href="https://helm-playground.com/" rel="nofollow noreferrer">here</a>:</p>
<p>template.yaml</p>
<pre><code>{{- if .Values.livenessReadinessProbe }}
{{- if eq (.Values.livenessReadinessProbe.enabled) true }}
livenessProbe:
  httpGet:
    path: /actuator/health/liveness
    port: 8080
  initialDelaySeconds: 300
  failureThreshold: 5
  periodSeconds: 10
readinessProbe:
  httpGet:
    path: /actuator/health/readiness
    port: 8080
  initialDelaySeconds: 200
  failureThreshold: 5
  periodSeconds: 10
{{- end }}
{{- end }}
</code></pre>
<p>values.yaml</p>
<pre><code>livenessReadinessProbe:
  enabled: true
</code></pre>
<p>See the output when you adjust the values.yaml:</p>
<ul>
<li>Delete <code>livenessReadinessProbe.enabled</code>, or set it to false.</li>
<li>Delete the entire value block.</li>
</ul>
