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?
Optional Secrets When you define a container environment variable based on a Secret, you can mark it as optional.
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.
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With