Update secret.md
parent
7b637bdb06
commit
a0f9db9382
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue