Merge pull request #21027 from scoulomb/secTask
Improve task 'Distribute Credentials Securely Using Secrets' by showi…
This commit is contained in:
@@ -167,8 +167,16 @@ is exposed:
|
|||||||
kubectl create -f https://k8s.io/examples/pods/inject/pod-single-secret-env-variable.yaml
|
kubectl create -f https://k8s.io/examples/pods/inject/pod-single-secret-env-variable.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
* Now, the Pod’s output includes environment variable `SECRET_USERNAME=backend-admin`
|
* In your shell, display the content of `SECRET_USERNAME` container environment variable
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kubectl exec -it env-single-secret -- /bin/sh -c 'echo $SECRET_USERNAME'
|
||||||
|
```
|
||||||
|
|
||||||
|
The output is
|
||||||
|
```shell
|
||||||
|
backend-admin
|
||||||
|
```
|
||||||
|
|
||||||
### Define container environment variables with data from multiple Secrets
|
### Define container environment variables with data from multiple Secrets
|
||||||
|
|
||||||
@@ -176,7 +184,6 @@ is exposed:
|
|||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
|
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
|
||||||
|
|
||||||
kubectl create secret generic db-user --from-literal=db-username='db-admin'
|
kubectl create secret generic db-user --from-literal=db-username='db-admin'
|
||||||
```
|
```
|
||||||
|
|
||||||
@@ -190,7 +197,16 @@ is exposed:
|
|||||||
kubectl create -f https://k8s.io/examples/pods/inject/pod-multiple-secret-env-variable.yaml
|
kubectl create -f https://k8s.io/examples/pods/inject/pod-multiple-secret-env-variable.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
* Now, the Pod’s output includes `BACKEND_USERNAME=backend-admin` and `DB_USERNAME=db-admin` environment variables.
|
* In your shell, display the container environment variables
|
||||||
|
|
||||||
|
```shell
|
||||||
|
kubectl exec -it envvars-multiple-secrets -- /bin/sh -c 'env | grep _USERNAME'
|
||||||
|
```
|
||||||
|
The output is
|
||||||
|
```shell
|
||||||
|
DB_USERNAME=db-admin
|
||||||
|
BACKEND_USERNAME=backend-admin
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
## Configure all key-value pairs in a Secret as container environment variables
|
## Configure all key-value pairs in a Secret as container environment variables
|
||||||
@@ -215,8 +231,17 @@ This functionality is available in Kubernetes v1.6 and later.
|
|||||||
kubectl create -f https://k8s.io/examples/pods/inject/pod-secret-envFrom.yaml
|
kubectl create -f https://k8s.io/examples/pods/inject/pod-secret-envFrom.yaml
|
||||||
```
|
```
|
||||||
|
|
||||||
* Now, the Pod’s output includes `username=my-app` and `password=39528$vdg7Jb` environment variables.
|
* In your shell, display `username` and `password` container environment variables
|
||||||
|
|
||||||
|
````shell
|
||||||
|
kubectl exec -it envfrom-secret -- /bin/sh -c 'echo "username: $username\npassword: $password"'
|
||||||
|
````
|
||||||
|
|
||||||
|
The output is
|
||||||
|
````shell
|
||||||
|
username: my-app
|
||||||
|
password: 39528$vdg7Jb
|
||||||
|
````
|
||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user