Consolidate YAML files [part-9] (#9361)

This PR relocates the YAML files referenced by the data injection topic.
pull/9375/head
Qiming 2018-07-04 02:50:19 +08:00 committed by k8s-ci-robot
parent 81bc804e9a
commit 1228689b1d
28 changed files with 71 additions and 84 deletions

View File

@ -1,13 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: command-demo
labels:
purpose: demonstrate-command
spec:
containers:
- name: command-demo-container
image: debian
command: ["printenv"]
args: ["HOSTNAME", "KUBERNETES_PORT"]
restartPolicy: OnFailure

View File

@ -37,11 +37,11 @@ with your new arguments.
In this exercise, you create a Pod that runs one container. The configuration In this exercise, you create a Pod that runs one container. The configuration
file for the Pod defines a command and two arguments: file for the Pod defines a command and two arguments:
{{< code file="commands.yaml" >}} {{< codenew file="pods/commands.yaml" >}}
1. Create a Pod based on the YAML configuration file: 1. Create a Pod based on the YAML configuration file:
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/commands.yaml kubectl create -f https://k8s.io/examples/pods/commands.yaml
1. List the running Pods: 1. List the running Pods:
@ -140,4 +140,3 @@ Here are some examples:
{{% /capture %}} {{% /capture %}}

View File

@ -32,11 +32,11 @@ file for the Pod defines an environment variable with name `DEMO_GREETING` and
value `"Hello from the environment"`. Here is the configuration file for the value `"Hello from the environment"`. Here is the configuration file for the
Pod: Pod:
{{< code file="envars.yaml" >}} {{< codenew file="pods/inject/envars.yaml" >}}
1. Create a Pod based on the YAML configuration file: 1. Create a Pod based on the YAML configuration file:
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/envars.yaml kubectl create -f https://k8s.io/examples/pods/inject/envars.yaml
1. List the running Pods: 1. List the running Pods:

View File

@ -35,18 +35,12 @@ and the base-64 representation of your password is `Mzk1MjgkdmRnN0pi`.
Here is a configuration file you can use to create a Secret that holds your Here is a configuration file you can use to create a Secret that holds your
username and password: username and password:
{{< code file="secret.yaml" >}} {{< codenew file="pods/inject/secret.yaml" >}}
1. Create the Secret 1. Create the Secret
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret.yaml kubectl create -f https://k8s.io/examples/pods/inject/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 >}}
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:
@ -76,15 +70,25 @@ username and password:
password: 13 bytes password: 13 bytes
username: 7 bytes username: 7 bytes
{{< 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'
```
## Create a Pod that has access to the secret data through a Volume ## Create a Pod that has access to the secret data through a Volume
Here is a configuration file you can use to create a Pod: Here is a configuration file you can use to create a Pod:
{{< code file="secret-pod.yaml" >}} {{< codenew file="pods/inject/secret-pod.yaml" >}}
1. Create the Pod: 1. Create the Pod:
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret-pod.yaml kubectl create -f https://k8s.io/examples/pods/inject/secret-pod.yaml
1. Verify that your Pod is running: 1. Verify that your Pod is running:
@ -127,11 +131,11 @@ is exposed:
Here is a configuration file you can use to create a Pod: Here is a configuration file you can use to create a Pod:
{{< code file="secret-envars-pod.yaml" >}} {{< codenew file="pods/inject/secret-envars-pod.yaml" >}}
1. Create the Pod: 1. Create the Pod:
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/secret-envars-pod.yaml kubectl create -f https://k8s.io/examples/pods/inject/secret-envars-pod.yaml
1. Verify that your Pod is running: 1. Verify that your Pod is running:

View File

@ -36,7 +36,7 @@ Together, these two ways of exposing Pod and Container fields are called the
In this exercise, you create a Pod that has one Container. In this exercise, you create a Pod that has one Container.
Here is the configuration file for the Pod: Here is the configuration file for the Pod:
{{< code file="dapi-volume.yaml" >}} {{< codenew file="pods/inject/dapi-volume.yaml" >}}
In the configuration file, you can see that the Pod has a `downwardAPI` Volume, In the configuration file, you can see that the Pod has a `downwardAPI` Volume,
and the Container mounts the Volume at `/etc/podinfo`. and the Container mounts the Volume at `/etc/podinfo`.
@ -56,7 +56,7 @@ fields of the Container in the Pod.
Create the Pod: Create the Pod:
```shell ```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/dapi-volume.yaml kubectl create -f https://k8s.io/examples/pods/inject/dapi-volume.yaml
``` ```
Verify that Container in the Pod is running: Verify that Container in the Pod is running:
@ -156,7 +156,7 @@ The preceding exercise, you stored Pod fields in a DownwardAPIVolumeFile.
In this next exercise, you store Container fields. Here is the configuration In this next exercise, you store Container fields. Here is the configuration
file for a Pod that has one Container: file for a Pod that has one Container:
{{< code file="dapi-volume-resources.yaml" >}} {{< codenew file="pods/inject/dapi-volume-resources.yaml" >}}
In the configuration file, you can see that the Pod has a `downwardAPI` Volume, In the configuration file, you can see that the Pod has a `downwardAPI` Volume,
and the Container mounts the Volume at `/etc/podinfo`. and the Container mounts the Volume at `/etc/podinfo`.
@ -171,7 +171,7 @@ should be stored in a file named `cpu_limit`.
Create the Pod: Create the Pod:
```shell ```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/dapi-volume-resources.yaml kubectl create -f https://k8s.io/examples/pods/inject/dapi-volume-resources.yaml
``` ```
Get a shell into the Container that is running in your Pod: Get a shell into the Container that is running in your Pod:

View File

@ -38,7 +38,7 @@ Together, these two ways of exposing Pod and Container fields are called the
In this exercise, you create a Pod that has one Container. Here is the In this exercise, you create a Pod that has one Container. Here is the
configuration file for the Pod: configuration file for the Pod:
{{< code file="dapi-envars-pod.yaml" >}} {{< codenew file="pods/inject/dapi-envars-pod.yaml" >}}
In the configuration file, you can see five environment variables. The `env` In the configuration file, you can see five environment variables. The `env`
field is an array of field is an array of
@ -55,7 +55,7 @@ Container in the Pod.
Create the Pod: Create the Pod:
```shell ```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/dapi-envars-pod.yaml kubectl create -f https://k8s.io/examples/pods/inject/dapi-envars-pod.yaml
``` ```
Verify that the Container in the Pod is running: Verify that the Container in the Pod is running:
@ -117,7 +117,7 @@ variables. In this next exercise, you use Container fields as the values for
environment variables. Here is the configuration file for a Pod that has one environment variables. Here is the configuration file for a Pod that has one
container: container:
{{< code file="dapi-envars-container.yaml" >}} {{< codenew file="pods/inject/dapi-envars-container.yaml" >}}
In the configuration file, you can see four environment variables. The `env` In the configuration file, you can see four environment variables. The `env`
field is an array of field is an array of
@ -130,7 +130,7 @@ from Container fields.
Create the Pod: Create the Pod:
```shell ```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/dapi-envars-container.yaml kubectl create -f https://k8s.io/examples/pods/inject/dapi-envars-container.yaml
``` ```
Verify that the Container in the Pod is running: Verify that the Container in the Pod is running:
@ -168,6 +168,3 @@ The output shows the values of selected environment variables:
{{% /capture %}} {{% /capture %}}

View File

@ -34,12 +34,12 @@ Get an overview of PodPresets at
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.
{{< code file="podpreset-preset.yaml" >}} {{< codenew file="podpreset/preset.yaml" >}}
Create the PodPreset: Create the PodPreset:
```shell ```shell
kubectl create -f https://k8s.io/docs/tasks/inject-data-application/podpreset-preset.yaml kubectl create -f https://k8s.io/examples/podpreset/preset.yaml
``` ```
Examine the created PodPreset: Examine the created PodPreset:
@ -52,12 +52,12 @@ allow-database 1m
The new PodPreset will act upon any pod that has label `role: frontend`. The new PodPreset will act upon any pod that has label `role: frontend`.
{{< code file="podpreset-pod.yaml" >}} {{< codenew file="podpreset/pod.yaml" >}}
Create a pod: Create a pod:
```shell ```shell
$ kubectl create -f https://k8s.io/docs/tasks/inject-data-application/podpreset-pod.yaml $ kubectl create -f https://k8s.io/examples/podpreset/pod.yaml
``` ```
List the running Pods: List the running Pods:
@ -70,7 +70,7 @@ website 1/1 Running 0 4m
**Pod spec after admission controller:** **Pod spec after admission controller:**
{{< code file="podpreset-merged.yaml" >}} {{< codenew file="podpreset/merged.yaml" >}}
To see above output, run the following command: To see above output, run the following command:
@ -85,19 +85,19 @@ that defines a `ConfigMap` for Environment Variables.
**User submitted pod spec:** **User submitted pod spec:**
{{< code file="podpreset-pod.yaml" >}} {{< codenew file="podpreset/pod.yaml" >}}
**User submitted `ConfigMap`:** **User submitted `ConfigMap`:**
{{< code file="podpreset-configmap.yaml" >}} {{< codenew file="podpreset/configmap.yaml" >}}
**Example Pod Preset:** **Example Pod Preset:**
{{< code file="podpreset-allow-db.yaml" >}} {{< codenew file="podpreset/allow-db.yaml" >}}
**Pod spec after admission controller:** **Pod spec after admission controller:**
{{< code file="podpreset-allow-db-merged.yaml" >}} {{< codenew file="podpreset/allow-db-merged.yaml" >}}
### ReplicaSet with Pod Spec Example ### ReplicaSet with Pod Spec Example
@ -106,18 +106,18 @@ Preset.
**User submitted ReplicaSet:** **User submitted ReplicaSet:**
{{< code file="podpreset-replicaset.yaml" >}} {{< codenew file="podpreset/replicaset.yaml" >}}
**Example Pod Preset:** **Example Pod Preset:**
{{< code file="podpreset-preset.yaml" >}} {{< codenew file="podpreset/preset.yaml" >}}
**Pod spec after admission controller:** **Pod spec after admission controller:**
Note that the ReplicaSet spec was not changed, users have to check individual pods Note that the ReplicaSet spec was not changed, users have to check individual pods
to validate that the PodPreset has been applied. to validate that the PodPreset has been applied.
{{< code file="podpreset-replicaset-merged.yaml" >}} {{< codenew file="podpreset/replicaset-merged.yaml" >}}
### Multiple PodPreset Example ### Multiple PodPreset Example
@ -126,19 +126,19 @@ Injection Policies.
**User submitted pod spec:** **User submitted pod spec:**
{{< code file="podpreset-pod.yaml" >}} {{< codenew file="podpreset/pod.yaml" >}}
**Example Pod Preset:** **Example Pod Preset:**
{{< code file="podpreset-preset.yaml" >}} {{< codenew file="podpreset/preset.yaml" >}}
**Another Pod Preset:** **Another Pod Preset:**
{{< code file="podpreset-proxy.yaml" >}} {{< codenew file="podpreset/proxy.yaml" >}}
**Pod spec after admission controller:** **Pod spec after admission controller:**
{{< code file="podpreset-multi-merged.yaml" >}} {{< codenew file="podpreset/multi-merged.yaml" >}}
### Conflict Example ### Conflict Example
@ -147,15 +147,15 @@ when there is a conflict.
**User submitted pod spec:** **User submitted pod spec:**
{{< code file="podpreset-conflict-pod.yaml" >}} {{< codenew file="podpreset/conflict-pod.yaml" >}}
**Example Pod Preset:** **Example Pod Preset:**
{{< code file="podpreset-conflict-preset.yaml" >}} {{< codenew file="podpreset/conflict-preset.yaml" >}}
**Pod spec after admission controller will not change because of the conflict:** **Pod spec after admission controller will not change because of the conflict:**
{{< code file="podpreset-conflict-pod.yaml" >}} {{< codenew file="podpreset/conflict-pod.yaml" >}}
**If we run `kubectl describe...` we can see the event:** **If we run `kubectl describe...` we can see the event:**

View File

@ -412,30 +412,6 @@ func TestExampleObjectSchemas(t *testing.T) {
"task-pv-volume": {&api.PersistentVolume{}}, "task-pv-volume": {&api.PersistentVolume{}},
"tcp-liveness-readiness": {&api.Pod{}}, "tcp-liveness-readiness": {&api.Pod{}},
}, },
// TODO: decide whether federation examples should be added
"docs/tasks/inject-data-application": {
"commands": {&api.Pod{}},
"dapi-envars-container": {&api.Pod{}},
"dapi-envars-pod": {&api.Pod{}},
"dapi-volume": {&api.Pod{}},
"dapi-volume-resources": {&api.Pod{}},
"envars": {&api.Pod{}},
"podpreset-allow-db": {&settings.PodPreset{}},
"podpreset-allow-db-merged": {&api.Pod{}},
"podpreset-configmap": {&api.ConfigMap{}},
"podpreset-conflict-pod": {&api.Pod{}},
"podpreset-conflict-preset": {&settings.PodPreset{}},
"podpreset-merged": {&api.Pod{}},
"podpreset-multi-merged": {&api.Pod{}},
"podpreset-pod": {&api.Pod{}},
"podpreset-preset": {&settings.PodPreset{}},
"podpreset-proxy": {&settings.PodPreset{}},
"podpreset-replicaset-merged": {&api.Pod{}},
"podpreset-replicaset": {&extensions.ReplicaSet{}},
"secret": {&api.Secret{}},
"secret-envars-pod": {&api.Pod{}},
"secret-pod": {&api.Pod{}},
},
"examples/application/job": { "examples/application/job": {
"job-tmpl": {&batch.Job{}}, "job-tmpl": {&batch.Job{}},
"cronjob": {&batch.CronJob{}}, "cronjob": {&batch.CronJob{}},
@ -488,12 +464,36 @@ func TestExampleObjectSchemas(t *testing.T) {
"replication": {&api.ReplicationController{}}, "replication": {&api.ReplicationController{}},
"nginx-deployment": {&extensions.Deployment{}}, "nginx-deployment": {&extensions.Deployment{}},
}, },
"examples/podpreset": {
"allow-db": {&settings.PodPreset{}},
"allow-db-merged": {&api.Pod{}},
"configmap": {&api.ConfigMap{}},
"conflict-pod": {&api.Pod{}},
"conflict-preset": {&settings.PodPreset{}},
"merged": {&api.Pod{}},
"multi-merged": {&api.Pod{}},
"pod": {&api.Pod{}},
"preset": {&settings.PodPreset{}},
"proxy": {&settings.PodPreset{}},
"replicaset-merged": {&api.Pod{}},
"replicaset": {&extensions.ReplicaSet{}},
},
"examples/pods": { "examples/pods": {
"commands": {&api.Pod{}}, "commands": {&api.Pod{}},
"pod-nginx": {&api.Pod{}}, "pod-nginx": {&api.Pod{}},
"pod-with-node-affinity": {&api.Pod{}}, "pod-with-node-affinity": {&api.Pod{}},
"pod-with-pod-affinity": {&api.Pod{}}, "pod-with-pod-affinity": {&api.Pod{}},
}, },
"examples/pods/inject": {
"dapi-envars-container": {&api.Pod{}},
"dapi-envars-pod": {&api.Pod{}},
"dapi-volume": {&api.Pod{}},
"dapi-volume-resources": {&api.Pod{}},
"envars": {&api.Pod{}},
"secret": {&api.Secret{}},
"secret-envars-pod": {&api.Pod{}},
"secret-pod": {&api.Pod{}},
},
"examples/policy": { "examples/policy": {
"privileged-psp": {&policy.PodSecurityPolicy{}}, "privileged-psp": {&policy.PodSecurityPolicy{}},
"restricted-psp": {&policy.PodSecurityPolicy{}}, "restricted-psp": {&policy.PodSecurityPolicy{}},