Skip to content

Commit a21e1f7

Browse files
committed
Clean up page distribute-credentials-secure
1 parent 448e1fa commit a21e1f7

File tree

1 file changed

+61
-64
lines changed

1 file changed

+61
-64
lines changed

content/en/docs/tasks/inject-data-application/distribute-credentials-secure.md

Lines changed: 61 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,12 @@ min-kubernetes-server-version: v1.6
66
---
77

88
<!-- overview -->
9+
910
This page shows how to securely inject sensitive data, such as passwords and
1011
encryption keys, into Pods.
1112

12-
1313
## {{% heading "prerequisites" %}}
1414

15-
1615
{{< include "task-tutorial-prereqs.md" >}}
1716

1817
### Convert your secret data to a base-64 representation
@@ -94,7 +93,6 @@ kubectl create secret generic test-secret --from-literal='username=my-app' --fro
9493
This is more convenient. The detailed approach shown earlier runs
9594
through each step explicitly to demonstrate what is happening.
9695

97-
9896
## Create a Pod that has access to the secret data through a Volume
9997

10098
Here is a configuration file you can use to create a Pod:
@@ -125,7 +123,7 @@ Here is a configuration file you can use to create a Pod:
125123
```
126124

127125
1. The secret data is exposed to the Container through a Volume mounted under
128-
`/etc/secret-volume`.
126+
`/etc/secret-volume`.
129127

130128
In your shell, list the files in the `/etc/secret-volume` directory:
131129
```shell
@@ -182,17 +180,17 @@ spec:
182180
183181
When you deploy this Pod, the following happens:
184182
185-
* The `username` key from `mysecret` is available to the container at the path
183+
- The `username` key from `mysecret` is available to the container at the path
186184
`/etc/foo/my-group/my-username` instead of at `/etc/foo/username`.
187-
* The `password` key from that Secret object is not projected.
185+
- The `password` key from that Secret object is not projected.
188186

189187
If you list keys explicitly using `.spec.volumes[].secret.items`, consider the
190188
following:
191189

192-
* Only keys specified in `items` are projected.
193-
* To consume all keys from the Secret, all of them must be listed in the
190+
- Only keys specified in `items` are projected.
191+
- To consume all keys from the Secret, all of them must be listed in the
194192
`items` field.
195-
* All listed keys must exist in the corresponding Secret. Otherwise, the volume
193+
- All listed keys must exist in the corresponding Secret. Otherwise, the volume
196194
is not created.
197195

198196
### Set POSIX permissions for Secret keys
@@ -246,87 +244,86 @@ secrets change.
246244

247245
### Define a container environment variable with data from a single Secret
248246

249-
* Define an environment variable as a key-value pair in a Secret:
247+
- Define an environment variable as a key-value pair in a Secret:
250248

251-
```shell
252-
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
253-
```
249+
```shell
250+
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
251+
```
254252

255-
* Assign the `backend-username` value defined in the Secret to the `SECRET_USERNAME` environment variable in the Pod specification.
253+
- Assign the `backend-username` value defined in the Secret to the `SECRET_USERNAME` environment variable in the Pod specification.
256254

257-
{{< codenew file="pods/inject/pod-single-secret-env-variable.yaml" >}}
255+
{{< codenew file="pods/inject/pod-single-secret-env-variable.yaml" >}}
258256

259-
* Create the Pod:
257+
- Create the Pod:
260258

261-
```shell
262-
kubectl create -f https://k8s.io/examples/pods/inject/pod-single-secret-env-variable.yaml
263-
```
259+
```shell
260+
kubectl create -f https://k8s.io/examples/pods/inject/pod-single-secret-env-variable.yaml
261+
```
264262

265-
* In your shell, display the content of `SECRET_USERNAME` container environment variable
263+
- In your shell, display the content of `SECRET_USERNAME` container environment variable
266264

267-
```shell
268-
kubectl exec -i -t env-single-secret -- /bin/sh -c 'echo $SECRET_USERNAME'
269-
```
265+
```shell
266+
kubectl exec -i -t env-single-secret -- /bin/sh -c 'echo $SECRET_USERNAME'
267+
```
270268

271-
The output is
272-
```
273-
backend-admin
274-
```
269+
The output is
270+
```
271+
backend-admin
272+
```
275273

276274
### Define container environment variables with data from multiple Secrets
277275

278-
* As with the previous example, create the Secrets first.
279-
280-
```shell
281-
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
282-
kubectl create secret generic db-user --from-literal=db-username='db-admin'
283-
```
276+
- As with the previous example, create the Secrets first.
284277

285-
* Define the environment variables in the Pod specification.
278+
```shell
279+
kubectl create secret generic backend-user --from-literal=backend-username='backend-admin'
280+
kubectl create secret generic db-user --from-literal=db-username='db-admin'
281+
```
286282

287-
{{< codenew file="pods/inject/pod-multiple-secret-env-variable.yaml" >}}
283+
- Define the environment variables in the Pod specification.
288284

289-
* Create the Pod:
285+
{{< codenew file="pods/inject/pod-multiple-secret-env-variable.yaml" >}}
290286

291-
```shell
292-
kubectl create -f https://k8s.io/examples/pods/inject/pod-multiple-secret-env-variable.yaml
293-
```
287+
- Create the Pod:
294288

295-
* In your shell, display the container environment variables
289+
```shell
290+
kubectl create -f https://k8s.io/examples/pods/inject/pod-multiple-secret-env-variable.yaml
291+
```
296292

297-
```shell
298-
kubectl exec -i -t envvars-multiple-secrets -- /bin/sh -c 'env | grep _USERNAME'
299-
```
300-
The output is
301-
```
302-
DB_USERNAME=db-admin
303-
BACKEND_USERNAME=backend-admin
304-
```
293+
- In your shell, display the container environment variables
305294

295+
```shell
296+
kubectl exec -i -t envvars-multiple-secrets -- /bin/sh -c 'env | grep _USERNAME'
297+
```
298+
The output is
299+
```
300+
DB_USERNAME=db-admin
301+
BACKEND_USERNAME=backend-admin
302+
```
306303

307304
## Configure all key-value pairs in a Secret as container environment variables
308305

309306
{{< note >}}
310307
This functionality is available in Kubernetes v1.6 and later.
311308
{{< /note >}}
312309

313-
* Create a Secret containing multiple key-value pairs
310+
- Create a Secret containing multiple key-value pairs
314311

315-
```shell
316-
kubectl create secret generic test-secret --from-literal=username='my-app' --from-literal=password='39528$vdg7Jb'
317-
```
312+
```shell
313+
kubectl create secret generic test-secret --from-literal=username='my-app' --from-literal=password='39528$vdg7Jb'
314+
```
318315

319-
* 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.
316+
- 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.
320317

321-
{{< codenew file="pods/inject/pod-secret-envFrom.yaml" >}}
318+
{{< codenew file="pods/inject/pod-secret-envFrom.yaml" >}}
322319

323-
* Create the Pod:
320+
- Create the Pod:
324321

325-
```shell
326-
kubectl create -f https://k8s.io/examples/pods/inject/pod-secret-envFrom.yaml
327-
```
322+
```shell
323+
kubectl create -f https://k8s.io/examples/pods/inject/pod-secret-envFrom.yaml
324+
```
328325

329-
* In your shell, display `username` and `password` container environment variables
326+
- In your shell, display `username` and `password` container environment variables
330327

331328
```shell
332329
kubectl exec -i -t envfrom-secret -- /bin/sh -c 'echo "username: $username\npassword: $password\n"'
@@ -340,11 +337,11 @@ This functionality is available in Kubernetes v1.6 and later.
340337

341338
### References
342339

343-
* [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
344-
* [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core)
345-
* [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core)
340+
- [Secret](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#secret-v1-core)
341+
- [Volume](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#volume-v1-core)
342+
- [Pod](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#pod-v1-core)
346343

347344
## {{% heading "whatsnext" %}}
348345

349-
* Learn more about [Secrets](/docs/concepts/configuration/secret/).
350-
* Learn about [Volumes](/docs/concepts/storage/volumes/).
346+
- Learn more about [Secrets](/docs/concepts/configuration/secret/).
347+
- Learn about [Volumes](/docs/concepts/storage/volumes/).

0 commit comments

Comments
 (0)