Is it possible to source a `.env` file to create Kubernetes secrets?

Yes, use the option –from-env-file

kubectl create secret generic person --from-env-file=.test-secret

To consume the secrets from the initial .env file in a pod, you can use the following :

apiVersion: v1
kind: Pod
metadata:
  name: some-meta
spec:
  containers:
  - name: xyz
    image: abc
    envFrom:
    - secretRef:
        name: person # <--

Leave a Comment