Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to mark secret as optional in kubernetes?

Tags:

kubernetes

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?

like image 747
nmiculinic Avatar asked Jan 11 '18 13:01

nmiculinic


People also ask

Can secrets be marked as optional?

Optional Secrets When you define a container environment variable based on a Secret, you can mark it as optional.

How do I get rid of Kubernetes secrets?

Deleting a Kubernetes Secret Using kubectl delete To delete a Secret, first, use cat or id <name> to check if there are any Secrets in your cluster. Next, use describe <name> to get more information about a specific Secret. You delete Kubernetes Secrets using the kubectl delete command.

How do I protect secrets in Kubernetes?

A common approach to getting more secure secret management on Kubernetes is to introduce an external secret management solution, such as Hashicorp Vault, AWS Secrets Manager, Azure Key Vault, or Google Secret Manager.


1 Answers

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

Edit: similarly for envFrom

envFrom:
- secretRef:
    name: secname
    optional: true
like image 169
Radek 'Goblin' Pieczonka Avatar answered Sep 18 '22 07:09

Radek 'Goblin' Pieczonka