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

This PR relocates the YAML files referenced by the data injection topic.
This commit is contained in:
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
@@ -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
@@ -1,45 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: dapi-envars-resourcefieldref
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox:1.24
command: [ "sh", "-c"]
args:
- while true; do
echo -en '\n';
printenv MY_CPU_REQUEST MY_CPU_LIMIT;
printenv MY_MEM_REQUEST MY_MEM_LIMIT;
sleep 10;
done;
resources:
requests:
memory: "32Mi"
cpu: "125m"
limits:
memory: "64Mi"
cpu: "250m"
env:
- name: MY_CPU_REQUEST
valueFrom:
resourceFieldRef:
containerName: test-container
resource: requests.cpu
- name: MY_CPU_LIMIT
valueFrom:
resourceFieldRef:
containerName: test-container
resource: limits.cpu
- name: MY_MEM_REQUEST
valueFrom:
resourceFieldRef:
containerName: test-container
resource: requests.memory
- name: MY_MEM_LIMIT
valueFrom:
resourceFieldRef:
containerName: test-container
resource: limits.memory
restartPolicy: Never
@@ -1,38 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: dapi-envars-fieldref
spec:
containers:
- name: test-container
image: k8s.gcr.io/busybox
command: [ "sh", "-c"]
args:
- while true; do
echo -en '\n';
printenv MY_NODE_NAME MY_POD_NAME MY_POD_NAMESPACE;
printenv MY_POD_IP MY_POD_SERVICE_ACCOUNT;
sleep 10;
done;
env:
- name: MY_NODE_NAME
valueFrom:
fieldRef:
fieldPath: spec.nodeName
- name: MY_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: MY_POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: MY_POD_SERVICE_ACCOUNT
valueFrom:
fieldRef:
fieldPath: spec.serviceAccountName
restartPolicy: Never
@@ -1,54 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: kubernetes-downwardapi-volume-example-2
spec:
containers:
- name: client-container
image: k8s.gcr.io/busybox:1.24
command: ["sh", "-c"]
args:
- while true; do
echo -en '\n';
if [[ -e /etc/podinfo/cpu_limit ]]; then
echo -en '\n'; cat /etc/podinfo/cpu_limit; fi;
if [[ -e /etc/podinfo/cpu_request ]]; then
echo -en '\n'; cat /etc/podinfo/cpu_request; fi;
if [[ -e /etc/podinfo/mem_limit ]]; then
echo -en '\n'; cat /etc/podinfo/mem_limit; fi;
if [[ -e /etc/podinfo/mem_request ]]; then
echo -en '\n'; cat /etc/podinfo/mem_request; fi;
sleep 5;
done;
resources:
requests:
memory: "32Mi"
cpu: "125m"
limits:
memory: "64Mi"
cpu: "250m"
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
readOnly: false
volumes:
- name: podinfo
downwardAPI:
items:
- path: "cpu_limit"
resourceFieldRef:
containerName: client-container
resource: limits.cpu
- path: "cpu_request"
resourceFieldRef:
containerName: client-container
resource: requests.cpu
- path: "mem_limit"
resourceFieldRef:
containerName: client-container
resource: limits.memory
- path: "mem_request"
resourceFieldRef:
containerName: client-container
resource: requests.memory
@@ -1,39 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: kubernetes-downwardapi-volume-example
labels:
zone: us-est-coast
cluster: test-cluster1
rack: rack-22
annotations:
build: two
builder: john-doe
spec:
containers:
- name: client-container
image: k8s.gcr.io/busybox
command: ["sh", "-c"]
args:
- while true; do
if [[ -e /etc/podinfo/labels ]]; then
echo -en '\n\n'; cat /etc/podinfo/labels; fi;
if [[ -e /etc/podinfo/annotations ]]; then
echo -en '\n\n'; cat /etc/podinfo/annotations; fi;
sleep 5;
done;
volumeMounts:
- name: podinfo
mountPath: /etc/podinfo
readOnly: false
volumes:
- name: podinfo
downwardAPI:
items:
- path: "labels"
fieldRef:
fieldPath: metadata.labels
- path: "annotations"
fieldRef:
fieldPath: metadata.annotations
@@ -37,11 +37,11 @@ with your new arguments.
In this exercise, you create a Pod that runs one container. The configuration
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:
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:
@@ -140,4 +140,3 @@ Here are some examples:
{{% /capture %}}
@@ -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
Pod:
{{< code file="envars.yaml" >}}
{{< codenew file="pods/inject/envars.yaml" >}}
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:
@@ -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
username and password:
{{< code file="secret.yaml" >}}
{{< codenew file="pods/inject/secret.yaml" >}}
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:
@@ -76,15 +70,25 @@ username and password:
password: 13 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
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:
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:
@@ -127,11 +131,11 @@ is exposed:
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:
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:
@@ -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.
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,
and the Container mounts the Volume at `/etc/podinfo`.
@@ -56,7 +56,7 @@ fields of the Container in the Pod.
Create the Pod:
```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:
@@ -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
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,
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:
```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:
@@ -1,15 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: envar-demo
labels:
purpose: demonstrate-envars
spec:
containers:
- name: envar-demo-container
image: gcr.io/google-samples/node-hello:1.0
env:
- name: DEMO_GREETING
value: "Hello from the environment"
- name: DEMO_FAREWELL
value: "Such a sweet sorrow"
@@ -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
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`
field is an array of
@@ -55,7 +55,7 @@ Container in the Pod.
Create the Pod:
```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:
@@ -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
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`
field is an array of
@@ -130,7 +130,7 @@ from Container fields.
Create the Pod:
```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:
@@ -168,6 +168,3 @@ The output shows the values of selected environment variables:
{{% /capture %}}
@@ -1,37 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
role: frontend
annotations:
podpreset.admission.kubernetes.io/podpreset-allow-database: "resource version"
spec:
containers:
- name: website
image: nginx
volumeMounts:
- mountPath: /cache
name: cache-volume
- mountPath: /etc/app/config.json
readOnly: true
name: secret-volume
ports:
- containerPort: 80
env:
- name: DB_PORT
value: "6379"
- name: duplicate_key
value: FROM_ENV
- name: expansion
value: $(REPLACE_ME)
envFrom:
- configMapRef:
name: etcd-env-config
volumes:
- name: cache-volume
emptyDir: {}
- name: secret-volume
secret:
secretName: config-details
@@ -1,30 +0,0 @@
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-database
spec:
selector:
matchLabels:
role: frontend
env:
- name: DB_PORT
value: "6379"
- name: duplicate_key
value: FROM_ENV
- name: expansion
value: $(REPLACE_ME)
envFrom:
- configMapRef:
name: etcd-env-config
volumeMounts:
- mountPath: /cache
name: cache-volume
- mountPath: /etc/app/config.json
readOnly: true
name: secret-volume
volumes:
- name: cache-volume
emptyDir: {}
- name: secret-volume
secret:
secretName: config-details
@@ -1,14 +0,0 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: etcd-env-config
data:
number_of_members: "1"
initial_cluster_state: new
initial_cluster_token: DUMMY_ETCD_INITIAL_CLUSTER_TOKEN
discovery_token: DUMMY_ETCD_DISCOVERY_TOKEN
discovery_url: http://etcd_discovery:2379
etcdctl_peers: http://etcd:2379
duplicate_key: FROM_CONFIG_MAP
REPLACE_ME: "a value"
@@ -1,19 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
role: frontend
spec:
containers:
- name: website
image: nginx
volumeMounts:
- mountPath: /cache
name: cache-volume
ports:
- containerPort: 80
volumes:
- name: cache-volume
emptyDir: {}
@@ -1,18 +0,0 @@
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-database
spec:
selector:
matchLabels:
role: frontend
env:
- name: DB_PORT
value: "6379"
volumeMounts:
- mountPath: /cache
name: other-volume
volumes:
- name: other-volume
emptyDir: {}
@@ -1,25 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
role: frontend
annotations:
podpreset.admission.kubernetes.io/podpreset-allow-database: "resource version"
spec:
containers:
- name: website
image: nginx
volumeMounts:
- mountPath: /cache
name: cache-volume
ports:
- containerPort: 80
env:
- name: DB_PORT
value: "6379"
volumes:
- name: cache-volume
emptyDir: {}
@@ -1,29 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
role: frontend
annotations:
podpreset.admission.kubernetes.io/podpreset-allow-database: "resource version"
podpreset.admission.kubernetes.io/podpreset-proxy: "resource version"
spec:
containers:
- name: website
image: nginx
volumeMounts:
- mountPath: /cache
name: cache-volume
- mountPath: /etc/proxy/configs
name: proxy-volume
ports:
- containerPort: 80
env:
- name: DB_PORT
value: "6379"
volumes:
- name: cache-volume
emptyDir: {}
- name: proxy-volume
emptyDir: {}
@@ -1,14 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: website
labels:
app: website
role: frontend
spec:
containers:
- name: website
image: nginx
ports:
- containerPort: 80
@@ -1,17 +0,0 @@
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: allow-database
spec:
selector:
matchLabels:
role: frontend
env:
- name: DB_PORT
value: "6379"
volumeMounts:
- mountPath: /cache
name: cache-volume
volumes:
- name: cache-volume
emptyDir: {}
@@ -1,14 +0,0 @@
apiVersion: settings.k8s.io/v1alpha1
kind: PodPreset
metadata:
name: proxy
spec:
selector:
matchLabels:
role: frontend
volumeMounts:
- mountPath: /etc/proxy/configs
name: proxy-volume
volumes:
- name: proxy-volume
emptyDir: {}
@@ -1,31 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: frontend
labels:
app: guestbook
role: frontend
annotations:
podpreset.admission.kubernetes.io/podpreset-allow-database: "resource version"
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
resources:
requests:
cpu: 100m
memory: 100Mi
volumeMounts:
- mountPath: /cache
name: cache-volume
env:
- name: GET_HOSTS_FROM
value: dns
- name: DB_PORT
value: "6379"
ports:
- containerPort: 80
volumes:
- name: cache-volume
emptyDir: {}
@@ -1,29 +0,0 @@
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: frontend
spec:
replicas: 3
selector:
matchLabels:
role: frontend
matchExpressions:
- {key: role, operator: In, values: [frontend]}
template:
metadata:
labels:
app: guestbook
role: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v3
resources:
requests:
cpu: 100m
memory: 100Mi
env:
- name: GET_HOSTS_FROM
value: dns
ports:
- containerPort: 80
@@ -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
Preset.
{{< code file="podpreset-preset.yaml" >}}
{{< codenew file="podpreset/preset.yaml" >}}
Create the PodPreset:
```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:
@@ -52,12 +52,12 @@ allow-database 1m
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:
```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:
@@ -70,7 +70,7 @@ website 1/1 Running 0 4m
**Pod spec after admission controller:**
{{< code file="podpreset-merged.yaml" >}}
{{< codenew file="podpreset/merged.yaml" >}}
To see above output, run the following command:
@@ -85,19 +85,19 @@ that defines a `ConfigMap` for Environment Variables.
**User submitted pod spec:**
{{< code file="podpreset-pod.yaml" >}}
{{< codenew file="podpreset/pod.yaml" >}}
**User submitted `ConfigMap`:**
{{< code file="podpreset-configmap.yaml" >}}
{{< codenew file="podpreset/configmap.yaml" >}}
**Example Pod Preset:**
{{< code file="podpreset-allow-db.yaml" >}}
{{< codenew file="podpreset/allow-db.yaml" >}}
**Pod spec after admission controller:**
{{< code file="podpreset-allow-db-merged.yaml" >}}
{{< codenew file="podpreset/allow-db-merged.yaml" >}}
### ReplicaSet with Pod Spec Example
@@ -106,18 +106,18 @@ Preset.
**User submitted ReplicaSet:**
{{< code file="podpreset-replicaset.yaml" >}}
{{< codenew file="podpreset/replicaset.yaml" >}}
**Example Pod Preset:**
{{< code file="podpreset-preset.yaml" >}}
{{< codenew file="podpreset/preset.yaml" >}}
**Pod spec after admission controller:**
Note that the ReplicaSet spec was not changed, users have to check individual pods
to validate that the PodPreset has been applied.
{{< code file="podpreset-replicaset-merged.yaml" >}}
{{< codenew file="podpreset/replicaset-merged.yaml" >}}
### Multiple PodPreset Example
@@ -126,19 +126,19 @@ Injection Policies.
**User submitted pod spec:**
{{< code file="podpreset-pod.yaml" >}}
{{< codenew file="podpreset/pod.yaml" >}}
**Example Pod Preset:**
{{< code file="podpreset-preset.yaml" >}}
{{< codenew file="podpreset/preset.yaml" >}}
**Another Pod Preset:**
{{< code file="podpreset-proxy.yaml" >}}
{{< codenew file="podpreset/proxy.yaml" >}}
**Pod spec after admission controller:**
{{< code file="podpreset-multi-merged.yaml" >}}
{{< codenew file="podpreset/multi-merged.yaml" >}}
### Conflict Example
@@ -147,15 +147,15 @@ when there is a conflict.
**User submitted pod spec:**
{{< code file="podpreset-conflict-pod.yaml" >}}
{{< codenew file="podpreset/conflict-pod.yaml" >}}
**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:**
{{< code file="podpreset-conflict-pod.yaml" >}}
{{< codenew file="podpreset/conflict-pod.yaml" >}}
**If we run `kubectl describe...` we can see the event:**
@@ -1,19 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: secret-envars-test-pod
spec:
containers:
- name: envars-test-container
image: nginx
env:
- name: SECRET_USERNAME
valueFrom:
secretKeyRef:
name: test-secret
key: username
- name: SECRET_PASSWORD
valueFrom:
secretKeyRef:
name: test-secret
key: password
@@ -1,17 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: secret-test-pod
spec:
containers:
- name: test-container
image: nginx
volumeMounts:
# name must match the volume name below
- name: secret-volume
mountPath: /etc/secret-volume
# The secret data is exposed to Containers in the Pod through a Volume.
volumes:
- name: secret-volume
secret:
secretName: test-secret
@@ -1,7 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: test-secret
data:
username: bXktYXBw
password: Mzk1MjgkdmRnN0pi