From a0f9db9382f0cffd32275f76a4332afee20c39d2 Mon Sep 17 00:00:00 2001 From: Alpha Date: Sun, 19 Apr 2020 19:54:06 +0800 Subject: [PATCH] Update secret.md --- .../en/docs/concepts/configuration/secret.md | 37 +++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/content/en/docs/concepts/configuration/secret.md b/content/en/docs/concepts/configuration/secret.md index dc9a214fa3..90d57704b4 100644 --- a/content/en/docs/concepts/configuration/secret.md +++ b/content/en/docs/concepts/configuration/secret.md @@ -854,6 +854,43 @@ start until all the Pod's volumes are mounted. ## Use cases +### Use-Case: As container environment variables + +Create a secret +```yaml +apiVersion: v1 +kind: Secret +metadata: + name: mysecret +type: Opaque +data: + USER_NAME: YWRtaW4= + PASSWORD: MWYyZDFlMmU2N2Rm +``` + +Create the Secret: +```shell +kubectl apply -f mysecret.yaml +``` + +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. + +```yaml +apiVersion: v1 +kind: Pod +metadata: + name: secret-test-pod +spec: + containers: + - name: test-container + image: k8s.gcr.io/busybox + command: [ "/bin/sh", "-c", "env" ] + envFrom: + - secretRef: + name: mysecret + restartPolicy: Never +``` + ### Use-Case: Pod with ssh keys Create a secret containing some ssh keys: