<p>I have a template part like:</p>
<pre><code>    spec:
      containers:
        - name: webinspect-runner-{{ .Values.pipeline.sequence }}
          ...
          env:
            - name: wi_base_url
              valueFrom:
                secretKeyRef:
                  name: webinspect
                  key: wi-base-url
            - name: wi_type
              valueFrom:
                secretKeyRef:
                  name: webinspect
                  key: wi-type
</code></pre>
<p>The <code>webinspect/wi_type</code> secret may be missing. I want the container also don't have the wi_type envvar or get a default value (better) when the secret is missing, but k8s just reports <code>   CreateContainerConfigError: couldn't find key wi-type in Secret namespace/webinspect</code>  and the pod fails.</p>
<p>Is there a way to use a default value, or skip the block if the secret does not exist?</p>

Romulus Urakagi Ts'ai
<p>Two options, the first is add <code>optional: true</code> to the secretKeyRef block(s) which makes it skip. The second is a much more complex approach using the <a href="https://helm.sh/docs/chart_template_guide/functions_and_pipelines/" rel="nofollow noreferrer"><code>lookup</code> template function in Helm</a>. Probably go with the first :)</p>
