Skip to content

Commit 00fc4c5

Browse files
authored
Merge pull request #20439 from AlphaWong/patch-1
Add example for secret.md for `envFrom` field
2 parents c480f03 + a0f9db9 commit 00fc4c5

File tree

1 file changed

+37
-0
lines changed
  • content/en/docs/concepts/configuration

1 file changed

+37
-0
lines changed

content/en/docs/concepts/configuration/secret.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -854,6 +854,43 @@ start until all the Pod's volumes are mounted.
854854

855855
## Use cases
856856

857+
### Use-Case: As container environment variables
858+
859+
Create a secret
860+
```yaml
861+
apiVersion: v1
862+
kind: Secret
863+
metadata:
864+
name: mysecret
865+
type: Opaque
866+
data:
867+
USER_NAME: YWRtaW4=
868+
PASSWORD: MWYyZDFlMmU2N2Rm
869+
```
870+
871+
Create the Secret:
872+
```shell
873+
kubectl apply -f mysecret.yaml
874+
```
875+
876+
Use `envFrom` to define all of the Secret’s data as container environment variables. The key from the Secret becomes the environment variable name in the Pod.
877+
878+
```yaml
879+
apiVersion: v1
880+
kind: Pod
881+
metadata:
882+
name: secret-test-pod
883+
spec:
884+
containers:
885+
- name: test-container
886+
image: k8s.gcr.io/busybox
887+
command: [ "/bin/sh", "-c", "env" ]
888+
envFrom:
889+
- secretRef:
890+
name: mysecret
891+
restartPolicy: Never
892+
```
893+
857894
### Use-Case: Pod with ssh keys
858895

859896
Create a secret containing some ssh keys:

0 commit comments

Comments
 (0)