From 93b544505d958fc33e98623223133a6fb970ab4b Mon Sep 17 00:00:00 2001 From: Gao Wen Date: Wed, 22 Aug 2018 03:13:09 +0800 Subject: [PATCH] Update code render and format auto-generate list (#9070) * Update the code render * Update the generate catalog and formate code rendering * Fix heading levels for template --- .../distribute-credentials-secure.md | 100 +++++++++++------- .../inject-data-application/podpreset.md | 15 ++- 2 files changed, 67 insertions(+), 48 deletions(-) diff --git a/content/en/docs/tasks/inject-data-application/distribute-credentials-secure.md b/content/en/docs/tasks/inject-data-application/distribute-credentials-secure.md index 58380b735d..8e4f45d87c 100644 --- a/content/en/docs/tasks/inject-data-application/distribute-credentials-secure.md +++ b/content/en/docs/tasks/inject-data-application/distribute-credentials-secure.md @@ -39,8 +39,15 @@ username and password: 1. Create the Secret - kubectl create -f https://k8s.io/examples/pods/inject/secret.yaml - + ```shell + kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret.yaml + ``` +{{< note >}} +**Note:** If you want to skip the Base64 encoding step, you can create a Secret by using the `kubectl create secret` command: +{{< /note >}} + ```shell + kubectl create secret generic test-secret --from-literal=username='my-app' --from-literal=password='39528$vdg7Jb' + ``` 1. View information about the Secret: @@ -88,44 +95,52 @@ Here is a configuration file you can use to create a Pod: 1. Create the Pod: - kubectl create -f https://k8s.io/examples/pods/inject/secret-pod.yaml + ```shell + kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret-pod.yaml + ``` 1. Verify that your Pod is running: - kubectl get pod secret-test-pod + ```shell + kubectl get pod secret-test-pod + ``` Output: - - NAME READY STATUS RESTARTS AGE - secret-test-pod 1/1 Running 0 42m - + ```shell + NAME READY STATUS RESTARTS AGE + secret-test-pod 1/1 Running 0 42m + ``` 1. Get a shell into the Container that is running in your Pod: - - kubectl exec -it secret-test-pod -- /bin/bash + ```shell + kubectl exec -it secret-test-pod -- /bin/bash + ``` 1. The secret data is exposed to the Container through a Volume mounted under `/etc/secret-volume`. In your shell, go to the directory where the secret data is exposed: - - root@secret-test-pod:/# cd /etc/secret-volume + ```shell + root@secret-test-pod:/# cd /etc/secret-volume + ``` 1. In your shell, list the files in the `/etc/secret-volume` directory: - - root@secret-test-pod:/etc/secret-volume# ls - + ```shell + root@secret-test-pod:/etc/secret-volume# ls + ``` The output shows two files, one for each piece of secret data: - - password username + ```shell + password username + ``` 1. In your shell, display the contents of the `username` and `password` files: - - root@secret-test-pod:/etc/secret-volume# cat username; echo; cat password; echo - + ```shell + root@secret-test-pod:/etc/secret-volume# cat username; echo; cat password; echo + ``` The output is your username and password: - - my-app - 39528$vdg7Jb + ```shell + my-app + 39528$vdg7Jb + ``` ## Create a Pod that has access to the secret data through environment variables @@ -135,32 +150,39 @@ Here is a configuration file you can use to create a Pod: 1. Create the Pod: - kubectl create -f https://k8s.io/examples/pods/inject/secret-envars-pod.yaml + ```shell + kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret-envars-pod.yaml + ``` 1. Verify that your Pod is running: - - kubectl get pod secret-envars-test-pod + ```shell + kubectl get pod secret-envars-test-pod + ``` Output: - - NAME READY STATUS RESTARTS AGE - secret-envars-test-pod 1/1 Running 0 4m + ```shell + NAME READY STATUS RESTARTS AGE + secret-envars-test-pod 1/1 Running 0 4m + ``` 1. Get a shell into the Container that is running in your Pod: - - kubectl exec -it secret-envars-test-pod -- /bin/bash + ```shell + kubectl exec -it secret-envars-test-pod -- /bin/bash + ``` 1. In your shell, display the environment variables: - - root@secret-envars-test-pod:/# printenv + ```shell + root@secret-envars-test-pod:/# printenv + ``` The output includes your username and password: - - ... - SECRET_USERNAME=my-app - ... - SECRET_PASSWORD=39528$vdg7Jb - + ```shell + ... + SECRET_USERNAME=my-app + ... + SECRET_PASSWORD=39528$vdg7Jb + ``` + {{% /capture %}} {{% capture whatsnext %}} diff --git a/content/en/docs/tasks/inject-data-application/podpreset.md b/content/en/docs/tasks/inject-data-application/podpreset.md index d64512751b..10fff8cec4 100644 --- a/content/en/docs/tasks/inject-data-application/podpreset.md +++ b/content/en/docs/tasks/inject-data-application/podpreset.md @@ -8,14 +8,12 @@ weight: 60 {{% capture overview %}} -You can use a `podpreset` object to inject information like secrets, volume +You can use a `PodPreset` object to inject information like secrets, volume mounts, and environment variables etc into pods at creation time. This task shows some examples on using the `PodPreset` resource. {{% /capture %}} -{{< toc >}} - {{% capture prerequisites %}} Get an overview of PodPresets at @@ -27,9 +25,8 @@ Get an overview of PodPresets at {{% capture steps %}} -## Create a Pod Preset -### Simple Pod Spec Example +## Simple Pod Spec Example This is a simple example to show how a Pod spec is modified by the Pod Preset. @@ -78,7 +75,7 @@ To see above output, run the following command: $ kubectl get pod website -o yaml ``` -### Pod Spec with `ConfigMap` Example +## Pod Spec with ConfigMap Example This is an example to show how a Pod spec is modified by the Pod Preset that defines a `ConfigMap` for Environment Variables. @@ -99,7 +96,7 @@ that defines a `ConfigMap` for Environment Variables. {{< codenew file="podpreset/allow-db-merged.yaml" >}} -### ReplicaSet with Pod Spec Example +## ReplicaSet with Pod Spec Example The following example shows that only the pod spec is modified by the Pod Preset. @@ -119,7 +116,7 @@ to validate that the PodPreset has been applied. {{< codenew file="podpreset/replicaset-merged.yaml" >}} -### Multiple PodPreset Example +## Multiple PodPreset Example This is an example to show how a Pod spec is modified by multiple Pod Injection Policies. @@ -140,7 +137,7 @@ Injection Policies. {{< codenew file="podpreset/multi-merged.yaml" >}} -### Conflict Example +## Conflict Example This is an example to show how a Pod spec is not modified by the Pod Preset when there is a conflict.