How to mark secret as optional in kubernetes?

1/11/2018

From the docs:

Secrets must be created before they are consumed in pods as environment variables unless they are marked as optional. References to Secrets that do not exist will prevent the pod from starting.

How to mark secret as optional?

-- nmiculinic
kubernetes

1 Answer

1/11/2018

What you're looking for is

  - name: ENV_NAME
    valueFrom:
      secretKeyRef:
        name: <secrets name>
        key: <secrets key>
        optional: true

You can find type definition here

-- Radek 'Goblin' Pieczonka
Source: StackOverflow