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
This commit is contained in:
@@ -39,8 +39,15 @@ username and password:
|
|||||||
|
|
||||||
1. Create the Secret
|
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:
|
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:
|
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:
|
1. Verify that your Pod is running:
|
||||||
|
|
||||||
kubectl get pod secret-test-pod
|
```shell
|
||||||
|
kubectl get pod secret-test-pod
|
||||||
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
```shell
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
secret-test-pod 1/1 Running 0 42m
|
secret-test-pod 1/1 Running 0 42m
|
||||||
|
```
|
||||||
|
|
||||||
1. Get a shell into the Container that is running in your Pod:
|
1. Get a shell into the Container that is running in your Pod:
|
||||||
|
```shell
|
||||||
kubectl exec -it secret-test-pod -- /bin/bash
|
kubectl exec -it secret-test-pod -- /bin/bash
|
||||||
|
```
|
||||||
|
|
||||||
1. The secret data is exposed to the Container through a Volume mounted under
|
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
|
`/etc/secret-volume`. In your shell, go to the directory where the secret data
|
||||||
is exposed:
|
is exposed:
|
||||||
|
```shell
|
||||||
root@secret-test-pod:/# cd /etc/secret-volume
|
root@secret-test-pod:/# cd /etc/secret-volume
|
||||||
|
```
|
||||||
|
|
||||||
1. In your shell, list the files in the `/etc/secret-volume` directory:
|
1. In your shell, list the files in the `/etc/secret-volume` directory:
|
||||||
|
```shell
|
||||||
root@secret-test-pod:/etc/secret-volume# ls
|
root@secret-test-pod:/etc/secret-volume# ls
|
||||||
|
```
|
||||||
The output shows two files, one for each piece of secret data:
|
The output shows two files, one for each piece of secret data:
|
||||||
|
```shell
|
||||||
password username
|
password username
|
||||||
|
```
|
||||||
|
|
||||||
1. In your shell, display the contents of the `username` and `password` files:
|
1. In your shell, display the contents of the `username` and `password` files:
|
||||||
|
```shell
|
||||||
root@secret-test-pod:/etc/secret-volume# cat username; echo; cat password; echo
|
root@secret-test-pod:/etc/secret-volume# cat username; echo; cat password; echo
|
||||||
|
```
|
||||||
The output is your username and password:
|
The output is your username and password:
|
||||||
|
```shell
|
||||||
my-app
|
my-app
|
||||||
39528$vdg7Jb
|
39528$vdg7Jb
|
||||||
|
```
|
||||||
|
|
||||||
## Create a Pod that has access to the secret data through environment variables
|
## 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:
|
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:
|
1. Verify that your Pod is running:
|
||||||
|
```shell
|
||||||
kubectl get pod secret-envars-test-pod
|
kubectl get pod secret-envars-test-pod
|
||||||
|
```
|
||||||
|
|
||||||
Output:
|
Output:
|
||||||
|
```shell
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
secret-envars-test-pod 1/1 Running 0 4m
|
secret-envars-test-pod 1/1 Running 0 4m
|
||||||
|
```
|
||||||
|
|
||||||
1. Get a shell into the Container that is running in your Pod:
|
1. Get a shell into the Container that is running in your Pod:
|
||||||
|
```shell
|
||||||
kubectl exec -it secret-envars-test-pod -- /bin/bash
|
kubectl exec -it secret-envars-test-pod -- /bin/bash
|
||||||
|
```
|
||||||
|
|
||||||
1. In your shell, display the environment variables:
|
1. In your shell, display the environment variables:
|
||||||
|
```shell
|
||||||
root@secret-envars-test-pod:/# printenv
|
root@secret-envars-test-pod:/# printenv
|
||||||
|
```
|
||||||
|
|
||||||
The output includes your username and password:
|
The output includes your username and password:
|
||||||
|
```shell
|
||||||
...
|
...
|
||||||
SECRET_USERNAME=my-app
|
SECRET_USERNAME=my-app
|
||||||
...
|
...
|
||||||
SECRET_PASSWORD=39528$vdg7Jb
|
SECRET_PASSWORD=39528$vdg7Jb
|
||||||
|
```
|
||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
{{% capture whatsnext %}}
|
{{% capture whatsnext %}}
|
||||||
|
|||||||
@@ -8,14 +8,12 @@ weight: 60
|
|||||||
|
|
||||||
{{% capture overview %}}
|
{{% 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.
|
mounts, and environment variables etc into pods at creation time.
|
||||||
This task shows some examples on using the `PodPreset` resource.
|
This task shows some examples on using the `PodPreset` resource.
|
||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
{{< toc >}}
|
|
||||||
|
|
||||||
{{% capture prerequisites %}}
|
{{% capture prerequisites %}}
|
||||||
|
|
||||||
Get an overview of PodPresets at
|
Get an overview of PodPresets at
|
||||||
@@ -27,9 +25,8 @@ Get an overview of PodPresets at
|
|||||||
|
|
||||||
{{% capture steps %}}
|
{{% 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
|
This is a simple example to show how a Pod spec is modified by the Pod
|
||||||
Preset.
|
Preset.
|
||||||
@@ -78,7 +75,7 @@ To see above output, run the following command:
|
|||||||
$ kubectl get pod website -o yaml
|
$ 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
|
This is an example to show how a Pod spec is modified by the Pod Preset
|
||||||
that defines a `ConfigMap` for Environment Variables.
|
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" >}}
|
{{< 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
|
The following example shows that only the pod spec is modified by the Pod
|
||||||
Preset.
|
Preset.
|
||||||
@@ -119,7 +116,7 @@ to validate that the PodPreset has been applied.
|
|||||||
|
|
||||||
{{< codenew file="podpreset/replicaset-merged.yaml" >}}
|
{{< 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
|
This is an example to show how a Pod spec is modified by multiple Pod
|
||||||
Injection Policies.
|
Injection Policies.
|
||||||
@@ -140,7 +137,7 @@ Injection Policies.
|
|||||||
|
|
||||||
{{< codenew file="podpreset/multi-merged.yaml" >}}
|
{{< 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
|
This is an example to show how a Pod spec is not modified by the Pod Preset
|
||||||
when there is a conflict.
|
when there is a conflict.
|
||||||
|
|||||||
Reference in New Issue
Block a user