Consolidate YAML files [part-10] (#9362)
* Consolidate YAML files [part-10] This PR relocates the YAML files used by the pod configuration topic. * Update examples_test.go * Update examples_test.go * Update examples_test.go * Update examples_test.go * Update examples_test.go
This commit is contained in:
@@ -71,7 +71,7 @@ In this exercise, you create a Pod that has one Container. The Container has a C
|
||||
request of 0.5 cpu and a CPU limit of 1 cpu. Here's the configuration file
|
||||
for the Pod:
|
||||
|
||||
{{< code file="cpu-request-limit.yaml" >}}
|
||||
{{< codenew file="pods/resource/cpu-request-limit.yaml" >}}
|
||||
|
||||
In the configuration file, the `args` section provides arguments for the Container when it starts.
|
||||
The `-cpus "2"` argument tells the Container to attempt to use 2 cpus.
|
||||
@@ -79,7 +79,7 @@ The `-cpus "2"` argument tells the Container to attempt to use 2 cpus.
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/cpu-request-limit.yaml --namespace=cpu-example
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/cpu-request-limit.yaml --namespace=cpu-example
|
||||
```
|
||||
|
||||
Verify that the Pod's Container is running:
|
||||
@@ -167,12 +167,12 @@ the capacity of any Node in your cluster. Here is the configuration file for a P
|
||||
that has one Container. The Container requests 100 cpu, which is likely to exceed the
|
||||
capacity of any Node in your cluster.
|
||||
|
||||
{{< code file="cpu-request-limit-2.yaml" >}}
|
||||
{{< codenew file="pods/resource/cpu-request-limit-2.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/cpu-request-limit-2.yaml --namespace=cpu-example
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/cpu-request-limit-2.yaml --namespace=cpu-example
|
||||
```
|
||||
|
||||
View the Pod's status:
|
||||
|
||||
@@ -71,7 +71,7 @@ In this exercise, you create a Pod that has one Container. The Container has a m
|
||||
request of 100 MiB and a memory limit of 200 MiB. Here's the configuration file
|
||||
for the Pod:
|
||||
|
||||
{{< code file="memory-request-limit.yaml" >}}
|
||||
{{< codenew file="pods/resource/memory-request-limit.yaml" >}}
|
||||
|
||||
In the configuration file, the `args` section provides arguments for the Container when it starts.
|
||||
The `"--vm-bytes", "150M"` arguments tell the Container to attempt to allocate 150 MiB of memory.
|
||||
@@ -79,7 +79,7 @@ The `"--vm-bytes", "150M"` arguments tell the Container to attempt to allocate 1
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/memory-request-limit.yaml --namespace=mem-example
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/memory-request-limit.yaml --namespace=mem-example
|
||||
```
|
||||
|
||||
Verify that the Pod's Container is running:
|
||||
@@ -142,7 +142,7 @@ In this exercise, you create a Pod that attempts to allocate more memory than it
|
||||
Here is the configuration file for a Pod that has one Container. The Container has a
|
||||
memory request of 50 MiB and a memory limit of 100 MiB.
|
||||
|
||||
{{< code file="memory-request-limit-2.yaml" >}}
|
||||
{{< codenew file="pods/resource/memory-request-limit-2.yaml" >}}
|
||||
|
||||
In the configuration file, in the `args` section, you can see that the Container
|
||||
will attempt to allocate 250 MiB of memory, which is well above the 100 MiB limit.
|
||||
@@ -150,7 +150,7 @@ will attempt to allocate 250 MiB of memory, which is well above the 100 MiB limi
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/memory-request-limit-2.yaml --namespace=mem-example
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/memory-request-limit-2.yaml --namespace=mem-example
|
||||
```
|
||||
|
||||
View detailed information about the Pod:
|
||||
@@ -253,12 +253,12 @@ capacity of any Node in your cluster. Here is the configuration file for a Pod t
|
||||
Container. The Container requests 1000 GiB of memory, which is likely to exceed the capacity
|
||||
of any Node in your cluster.
|
||||
|
||||
{{< code file="memory-request-limit-3.yaml" >}}
|
||||
{{< codenew file="pods/resource/memory-request-limit-3.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/memory-request-limit-3.yaml --namespace=mem-example
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/memory-request-limit-3.yaml --namespace=mem-example
|
||||
```
|
||||
|
||||
View the Pod's status:
|
||||
|
||||
@@ -30,7 +30,7 @@ for the postStart and preStop events.
|
||||
|
||||
Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="lifecycle-events.yaml" >}}
|
||||
{{< codenew file="pods/lifecycle-events.yaml" >}}
|
||||
|
||||
In the configuration file, you can see that the postStart command writes a `message`
|
||||
file to the Container's `/usr/share` directory. The preStop command shuts down
|
||||
@@ -38,7 +38,7 @@ nginx gracefully. This is helpful if the Container is being terminated because o
|
||||
|
||||
Create the Pod:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/lifecycle-events.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/lifecycle-events.yaml
|
||||
|
||||
Verify that the Container in the Pod is running:
|
||||
|
||||
|
||||
+6
-6
@@ -38,7 +38,7 @@ liveness probes to detect and remedy such situations.
|
||||
In this exercise, you create a Pod that runs a Container based on the
|
||||
`k8s.gcr.io/busybox` image. Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="exec-liveness.yaml" >}}
|
||||
{{< codenew file="pods/probe/exec-liveness.yaml" >}}
|
||||
|
||||
In the configuration file, you can see that the Pod has a single Container.
|
||||
The `periodSeconds` field specifies that the kubelet should perform a liveness
|
||||
@@ -62,7 +62,7 @@ code. After 30 seconds, `cat /tmp/healthy` returns a failure code.
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/exec-liveness.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/probe/exec-liveness.yaml
|
||||
```
|
||||
|
||||
Within 30 seconds, view the Pod events:
|
||||
@@ -122,7 +122,7 @@ Another kind of liveness probe uses an HTTP GET request. Here is the configurati
|
||||
file for a Pod that runs a container based on the `k8s.gcr.io/liveness`
|
||||
image.
|
||||
|
||||
{{< code file="http-liveness.yaml" >}}
|
||||
{{< codenew file="pods/probe/http-liveness.yaml" >}}
|
||||
|
||||
In the configuration file, you can see that the Pod has a single Container.
|
||||
The `periodSeconds` field specifies that the kubelet should perform a liveness
|
||||
@@ -163,7 +163,7 @@ checks will fail, and the kubelet will kill and restart the Container.
|
||||
To try the HTTP liveness check, create a Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/http-liveness.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/probe/http-liveness.yaml
|
||||
```
|
||||
|
||||
After 10 seconds, view Pod events to verify that liveness probes have failed and
|
||||
@@ -180,7 +180,7 @@ kubelet will attempt to open a socket to your container on the specified port.
|
||||
If it can establish a connection, the container is considered healthy, if it
|
||||
can’t it is considered a failure.
|
||||
|
||||
{{< code file="tcp-liveness-readiness.yaml" >}}
|
||||
{{< codenew file="pods/probe/tcp-liveness-readiness.yaml" >}}
|
||||
|
||||
As you can see, configuration for a TCP check is quite similar to an HTTP check.
|
||||
This example uses both readiness and liveness probes. The kubelet will send the
|
||||
@@ -198,7 +198,7 @@ will be restarted.
|
||||
To try the TCP liveness check, create a Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/tcp-liveness-readiness.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/probe/tcp-liveness-readiness.yaml
|
||||
```
|
||||
|
||||
After 15 seconds, view Pod events to verify that liveness probes:
|
||||
|
||||
+6
-6
@@ -62,7 +62,7 @@ to set up
|
||||
|
||||
Here is the configuration file for the hostPath PersistentVolume:
|
||||
|
||||
{{< code file="task-pv-volume.yaml" >}}
|
||||
{{< codenew file="pods/storage/pv-volume.yaml" >}}
|
||||
|
||||
The configuration file specifies that the volume is at `/mnt/data` on the
|
||||
cluster's Node. The configuration also specifies a size of 10 gibibytes and
|
||||
@@ -73,7 +73,7 @@ PersistentVolumeClaim requests to this PersistentVolume.
|
||||
|
||||
Create the PersistentVolume:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/task-pv-volume.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/storage/pv-volume.yaml
|
||||
|
||||
View information about the PersistentVolume:
|
||||
|
||||
@@ -94,11 +94,11 @@ access for at least one Node.
|
||||
|
||||
Here is the configuration file for the PersistentVolumeClaim:
|
||||
|
||||
{{< code file="task-pv-claim.yaml" >}}
|
||||
{{< codenew file="pods/storage/pv-claim.yaml" >}}
|
||||
|
||||
Create the PersistentVolumeClaim:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/task-pv-claim.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/storage/pv-claim.yaml
|
||||
|
||||
After you create the PersistentVolumeClaim, the Kubernetes control plane looks
|
||||
for a PersistentVolume that satisfies the claim's requirements. If the control
|
||||
@@ -130,7 +130,7 @@ The next step is to create a Pod that uses your PersistentVolumeClaim as a volum
|
||||
|
||||
Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="task-pv-pod.yaml" >}}
|
||||
{{< codenew file="pods/storage/pv-pod.yaml" >}}
|
||||
|
||||
Notice that the Pod's configuration file specifies a PersistentVolumeClaim, but
|
||||
it does not specify a PersistentVolume. From the Pod's point of view, the claim
|
||||
@@ -138,7 +138,7 @@ is a volume.
|
||||
|
||||
Create the Pod:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/task-pv-pod.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/storage/pv-pod.yaml
|
||||
|
||||
Verify that the Container in the Pod is running;
|
||||
|
||||
|
||||
@@ -26,7 +26,7 @@ container starts.
|
||||
|
||||
Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="init-containers.yaml" >}}
|
||||
{{< codenew file="pods/init-containers.yaml" >}}
|
||||
|
||||
In the configuration file, you can see that the Pod has a Volume that the init
|
||||
container and the application container share.
|
||||
@@ -43,7 +43,7 @@ of the nginx server.
|
||||
|
||||
Create the Pod:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/init-containers.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/init-containers.yaml
|
||||
|
||||
Verify that the nginx container is running:
|
||||
|
||||
|
||||
@@ -28,7 +28,7 @@ In this exercise, you create username and password Secrets from local files. You
|
||||
|
||||
Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="projected-volume.yaml" >}}
|
||||
{{< codenew file="pods/storage/projected.yaml" >}}
|
||||
|
||||
1. Create the Secrets:
|
||||
```shell
|
||||
@@ -42,7 +42,7 @@ Here is the configuration file for the Pod:
|
||||
```
|
||||
1. Create the Pod:
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/projected-volume.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/storage/projected.yaml
|
||||
```
|
||||
1. Verify that the Pod's Container is running, and then watch for changes to
|
||||
the Pod:
|
||||
|
||||
@@ -33,11 +33,11 @@ Volume of type
|
||||
that lasts for the life of the Pod, even if the Container terminates and
|
||||
restarts. Here is the configuration file for the Pod:
|
||||
|
||||
{{< code file="pod-redis.yaml" >}}
|
||||
{{< codenew file="pods/storage/redis.yaml" >}}
|
||||
|
||||
1. Create the Pod:
|
||||
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/pod-redis.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/storage/redis.yaml
|
||||
|
||||
1. Verify that the Pod's Container is running, and then watch for changes to
|
||||
the Pod:
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: cpu-demo-2
|
||||
namespace: cpu-example
|
||||
spec:
|
||||
containers:
|
||||
- name: cpu-demo-ctr-2
|
||||
image: vish/stress
|
||||
resources:
|
||||
limits:
|
||||
cpu: "100"
|
||||
requests:
|
||||
cpu: "100"
|
||||
args:
|
||||
- -cpus
|
||||
- "2"
|
||||
@@ -1,17 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: cpu-demo
|
||||
namespace: cpu-example
|
||||
spec:
|
||||
containers:
|
||||
- name: cpu-demo-ctr
|
||||
image: vish/stress
|
||||
resources:
|
||||
limits:
|
||||
cpu: "1"
|
||||
requests:
|
||||
cpu: "0.5"
|
||||
args:
|
||||
- -cpus
|
||||
- "2"
|
||||
@@ -1,21 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
labels:
|
||||
test: liveness
|
||||
name: liveness-exec
|
||||
spec:
|
||||
containers:
|
||||
- name: liveness
|
||||
image: k8s.gcr.io/busybox
|
||||
args:
|
||||
- /bin/sh
|
||||
- -c
|
||||
- touch /tmp/healthy; sleep 30; rm -rf /tmp/healthy; sleep 600
|
||||
livenessProbe:
|
||||
exec:
|
||||
command:
|
||||
- cat
|
||||
- /tmp/healthy
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 5
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: extended-resource-demo-2
|
||||
spec:
|
||||
containers:
|
||||
- name: extended-resource-demo-2-ctr
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
example.com/dongle: 2
|
||||
limits:
|
||||
example.com/dongle: 2
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: extended-resource-demo
|
||||
spec:
|
||||
containers:
|
||||
- name: extended-resource-demo-ctr
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
example.com/dongle: 3
|
||||
limits:
|
||||
example.com/dongle: 3
|
||||
@@ -36,14 +36,14 @@ descriptive resource name.
|
||||
|
||||
Here is the configuration file for a Pod that has one Container:
|
||||
|
||||
{{< code file="extended-resource-pod.yaml" >}}
|
||||
{{< codenew file="pods/resource/extended-resource-pod.yaml" >}}
|
||||
|
||||
In the configuration file, you can see that the Container requests 3 dongles.
|
||||
|
||||
Create a Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/extended-resource-pod.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/extended-resource-pod.yaml
|
||||
```
|
||||
|
||||
Verify that the Pod is running:
|
||||
@@ -72,7 +72,7 @@ Requests:
|
||||
Here is the configuration file for a Pod that has one Container. The Container requests
|
||||
two dongles.
|
||||
|
||||
{{< code file="extended-resource-pod-2.yaml" >}}
|
||||
{{< codenew file="pods/resource/extended-resource-pod-2.yaml" >}}
|
||||
|
||||
Kubernetes will not be able to satisfy the request for two dongles, because the first Pod
|
||||
used three of the four available dongles.
|
||||
@@ -80,7 +80,7 @@ used three of the four available dongles.
|
||||
Attempt to create a Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/extended-resource-pod-2.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/resource/extended-resource-pod-2.yaml
|
||||
```
|
||||
|
||||
Describe the Pod
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
labels:
|
||||
test: liveness
|
||||
name: liveness-http
|
||||
spec:
|
||||
containers:
|
||||
- name: liveness
|
||||
image: k8s.gcr.io/liveness
|
||||
args:
|
||||
- /server
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /healthz
|
||||
port: 8080
|
||||
httpHeaders:
|
||||
- name: X-Custom-Header
|
||||
value: Awesome
|
||||
initialDelaySeconds: 3
|
||||
periodSeconds: 3
|
||||
@@ -1,30 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: init-demo
|
||||
spec:
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
volumeMounts:
|
||||
- name: workdir
|
||||
mountPath: /usr/share/nginx/html
|
||||
# These containers are run during pod initialization
|
||||
initContainers:
|
||||
- name: install
|
||||
image: busybox
|
||||
command:
|
||||
- wget
|
||||
- "-O"
|
||||
- "/work-dir/index.html"
|
||||
- http://kubernetes.io
|
||||
volumeMounts:
|
||||
- name: workdir
|
||||
mountPath: "/work-dir"
|
||||
dnsPolicy: Default
|
||||
volumes:
|
||||
- name: workdir
|
||||
emptyDir: {}
|
||||
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: lifecycle-demo
|
||||
spec:
|
||||
containers:
|
||||
- name: lifecycle-demo-container
|
||||
image: nginx
|
||||
lifecycle:
|
||||
postStart:
|
||||
exec:
|
||||
command: ["/bin/sh", "-c", "echo Hello from the postStart handler > /usr/share/message"]
|
||||
preStop:
|
||||
exec:
|
||||
command: ["/usr/sbin/nginx","-s","quit"]
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: LimitRange
|
||||
metadata:
|
||||
name: mem-limit-range
|
||||
spec:
|
||||
limits:
|
||||
- default:
|
||||
memory: 512Mi
|
||||
defaultRequest:
|
||||
memory: 256Mi
|
||||
type: Container
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: memory-demo-2
|
||||
namespace: mem-example
|
||||
spec:
|
||||
containers:
|
||||
- name: memory-demo-2-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
requests:
|
||||
memory: "50Mi"
|
||||
limits:
|
||||
memory: "100Mi"
|
||||
command: ["stress"]
|
||||
args: ["--vm", "1", "--vm-bytes", "250M", "--vm-hang", "1"]
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: memory-demo-3
|
||||
namespace: mem-example
|
||||
spec:
|
||||
containers:
|
||||
- name: memory-demo-3-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
limits:
|
||||
memory: "1000Gi"
|
||||
requests:
|
||||
memory: "1000Gi"
|
||||
command: ["stress"]
|
||||
args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: memory-demo
|
||||
namespace: mem-example
|
||||
spec:
|
||||
containers:
|
||||
- name: memory-demo-ctr
|
||||
image: polinux/stress
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
requests:
|
||||
memory: "100Mi"
|
||||
command: ["stress"]
|
||||
args: ["--vm", "1", "--vm-bytes", "150M", "--vm-hang", "1"]
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: redis
|
||||
spec:
|
||||
containers:
|
||||
- name: redis
|
||||
image: redis
|
||||
volumeMounts:
|
||||
- name: redis-storage
|
||||
mountPath: /data/redis
|
||||
volumes:
|
||||
- name: redis-storage
|
||||
emptyDir: {}
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: private-reg
|
||||
spec:
|
||||
containers:
|
||||
- name: private-reg-container
|
||||
image: <your-private-image>
|
||||
imagePullSecrets:
|
||||
- name: regcred
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: test-projected-volume
|
||||
spec:
|
||||
containers:
|
||||
- name: test-projected-volume
|
||||
image: busybox
|
||||
args:
|
||||
- sleep
|
||||
- "86400"
|
||||
volumeMounts:
|
||||
- name: all-in-one
|
||||
mountPath: "/projected-volume"
|
||||
readOnly: true
|
||||
volumes:
|
||||
- name: all-in-one
|
||||
projected:
|
||||
sources:
|
||||
- secret:
|
||||
name: user
|
||||
- secret:
|
||||
name: pass
|
||||
@@ -112,11 +112,11 @@ You have successfully set your Docker credentials as a Secret called `regcred` i
|
||||
|
||||
Here is a configuration file for a Pod that needs access to your Docker credentials in `regcred`:
|
||||
|
||||
{{< code file="private-reg-pod.yaml" >}}
|
||||
{{< codenew file="pods/private-reg-pod.yaml" >}}
|
||||
|
||||
Download the above file:
|
||||
|
||||
wget -O my-private-reg-pod.yaml https://k8s.io/docs/tasks/configure-pod-container/private-reg-pod.yaml
|
||||
wget -O my-private-reg-pod.yaml https://k8s.io/examples/pods/private-reg-pod.yaml
|
||||
|
||||
In file `my-private-reg-pod.yaml`, replace `<your-private-image>` with the path to an image in a private registry such as:
|
||||
|
||||
@@ -142,4 +142,3 @@ Create a Pod that uses your Secret, and verify that the Pod is running:
|
||||
|
||||
{{% /capture %}}
|
||||
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: qos-demo-2
|
||||
namespace: qos-example
|
||||
spec:
|
||||
containers:
|
||||
- name: qos-demo-2-ctr
|
||||
image: nginx
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
requests:
|
||||
memory: "100Mi"
|
||||
@@ -1,9 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: qos-demo-3
|
||||
namespace: qos-example
|
||||
spec:
|
||||
containers:
|
||||
- name: qos-demo-3-ctr
|
||||
image: nginx
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: qos-demo-4
|
||||
namespace: qos-example
|
||||
spec:
|
||||
containers:
|
||||
|
||||
- name: qos-demo-4-ctr-1
|
||||
image: nginx
|
||||
resources:
|
||||
requests:
|
||||
memory: "200Mi"
|
||||
|
||||
- name: qos-demo-4-ctr-2
|
||||
image: redis
|
||||
@@ -1,16 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: qos-demo
|
||||
namespace: qos-example
|
||||
spec:
|
||||
containers:
|
||||
- name: qos-demo-ctr
|
||||
image: nginx
|
||||
resources:
|
||||
limits:
|
||||
memory: "200Mi"
|
||||
cpu: "700m"
|
||||
requests:
|
||||
memory: "200Mi"
|
||||
cpu: "700m"
|
||||
@@ -50,12 +50,12 @@ For a Pod to be given a QoS class of Guaranteed:
|
||||
Here is the configuration file for a Pod that has one Container. The Container has a memory limit and a
|
||||
memory request, both equal to 200 MiB. The Container has a cpu limit and a cpu request, both equal to 700 millicpu:
|
||||
|
||||
{{< code file="qos-pod.yaml" >}}
|
||||
{{< codenew file="pods/qos/qos-pod.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/qos-pod.yaml --namespace=qos-example
|
||||
kubectl create -f https://k8s.io/examples/pods/qos/qos-pod.yaml --namespace=qos-example
|
||||
```
|
||||
|
||||
View detailed information about the Pod:
|
||||
@@ -106,12 +106,12 @@ A Pod is given a QoS class of Burstable if:
|
||||
Here is the configuration file for a Pod that has one Container. The Container has a memory limit of 200 MiB
|
||||
and a memory request of 100 MiB.
|
||||
|
||||
{{< code file="qos-pod-2.yaml" >}}
|
||||
{{< codenew file="pods/qos/qos-pod-2.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/qos-pod-2.yaml --namespace=qos-example
|
||||
kubectl create -f https://k8s.io/examples/pods/qos/qos-pod-2.yaml --namespace=qos-example
|
||||
```
|
||||
|
||||
View detailed information about the Pod:
|
||||
@@ -151,12 +151,12 @@ have any memory or cpu limits or requests.
|
||||
Here is the configuration file for a Pod that has one Container. The Container has no memory or cpu
|
||||
limits or requests:
|
||||
|
||||
{{< code file="qos-pod-3.yaml" >}}
|
||||
{{< codenew file="pods/qos/qos-pod-3.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/qos-pod-3.yaml --namespace=qos-example
|
||||
kubectl create -f https://k8s.io/examples/pods/qos/qos-pod-3.yaml --namespace=qos-example
|
||||
```
|
||||
|
||||
View detailed information about the Pod:
|
||||
@@ -187,7 +187,7 @@ kubectl delete pod qos-demo-3 --namespace=qos-example
|
||||
Here is the configuration file for a Pod that has two Containers. One container specifies a memory
|
||||
request of 200 MiB. The other Container does not specify any requests or limits.
|
||||
|
||||
{{< code file="qos-pod-4.yaml" >}}
|
||||
{{< codenew file="pods/qos/qos-pod-4.yaml" >}}
|
||||
|
||||
Notice that this Pod meets the criteria for QoS class Burstable. That is, it does not meet the
|
||||
criteria for QoS class Guaranteed, and one of its Containers has a memory request.
|
||||
@@ -195,7 +195,7 @@ criteria for QoS class Guaranteed, and one of its Containers has a memory reques
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/qos-pod-4.yaml --namespace=qos-example
|
||||
kubectl create -f https://k8s.io/examples/pods/qos/qos-pod-4.yaml --namespace=qos-example
|
||||
```
|
||||
|
||||
View detailed information about the Pod:
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: ResourceQuota
|
||||
metadata:
|
||||
name: compute-resources
|
||||
spec:
|
||||
hard:
|
||||
pods: "4"
|
||||
requests.cpu: "1"
|
||||
requests.memory: 1Gi
|
||||
limits.cpu: "2"
|
||||
limits.memory: 2Gi
|
||||
@@ -1,13 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: security-context-demo-2
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
containers:
|
||||
- name: sec-ctx-demo-2
|
||||
image: gcr.io/google-samples/node-hello:1.0
|
||||
securityContext:
|
||||
runAsUser: 2000
|
||||
allowPrivilegeEscalation: false
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: security-context-demo-3
|
||||
spec:
|
||||
containers:
|
||||
- name: sec-ctx-3
|
||||
image: gcr.io/google-samples/node-hello:1.0
|
||||
|
||||
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: security-context-demo-4
|
||||
spec:
|
||||
containers:
|
||||
- name: sec-ctx-4
|
||||
image: gcr.io/google-samples/node-hello:1.0
|
||||
securityContext:
|
||||
capabilities:
|
||||
add: ["NET_ADMIN", "SYS_TIME"]
|
||||
@@ -49,7 +49,7 @@ in the Pod specification. The `securityContext` field is a
|
||||
The security settings that you specify for a Pod apply to all Containers in the Pod.
|
||||
Here is a configuration file for a Pod that has a `securityContext` and an `emptyDir` volume:
|
||||
|
||||
{{< code file="security-context.yaml" >}}
|
||||
{{< codenew file="pods/security/security-context.yaml" >}}
|
||||
|
||||
In the configuration file, the `runAsUser` field specifies that for any Containers in
|
||||
the Pod, the first process runs with user ID 1000. The `fsGroup` field specifies that
|
||||
@@ -60,7 +60,7 @@ volume.
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/security-context.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/security/security-context.yaml
|
||||
```
|
||||
|
||||
Verify that the Pod's Container is running:
|
||||
@@ -141,12 +141,12 @@ there is overlap. Container settings do not affect the Pod's Volumes.
|
||||
Here is the configuration file for a Pod that has one Container. Both the Pod
|
||||
and the Container have a `securityContext` field:
|
||||
|
||||
{{< code file="security-context-2.yaml" >}}
|
||||
{{< codenew file="pods/security/security-context-2.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/security-context-2.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/security/security-context-2.yaml
|
||||
```
|
||||
|
||||
Verify that the Pod's Container is running:
|
||||
@@ -194,12 +194,12 @@ of the root user. To add or remove Linux capabilities for a Container, include t
|
||||
First, see what happens when you don't include a `capabilities` field.
|
||||
Here is configuration file that does not add or remove any Container capabilities:
|
||||
|
||||
{{< code file="security-context-3.yaml" >}}
|
||||
{{< codenew file="pods/security/security-context-3.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/security-context-3.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/security/security-context-3.yaml
|
||||
```
|
||||
|
||||
Verify that the Pod's Container is running:
|
||||
@@ -256,12 +256,12 @@ that it has additional capabilities set.
|
||||
Here is the configuration file for a Pod that runs one Container. The configuration
|
||||
adds the `CAP_NET_ADMIN` and `CAP_SYS_TIME` capabilities:
|
||||
|
||||
{{< code file="security-context-4.yaml" >}}
|
||||
{{< codenew file="pods/security/security-context-4.yaml" >}}
|
||||
|
||||
Create the Pod:
|
||||
|
||||
```shell
|
||||
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/security-context-4.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/security/security-context-4.yaml
|
||||
```
|
||||
|
||||
Get a shell into the running Container:
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: security-context-demo
|
||||
spec:
|
||||
securityContext:
|
||||
runAsUser: 1000
|
||||
fsGroup: 2000
|
||||
volumes:
|
||||
- name: sec-ctx-vol
|
||||
emptyDir: {}
|
||||
containers:
|
||||
- name: sec-ctx-demo
|
||||
image: gcr.io/google-samples/node-hello:1.0
|
||||
volumeMounts:
|
||||
- name: sec-ctx-vol
|
||||
mountPath: /data/demo
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
@@ -39,16 +39,21 @@ across the system: `--feature-gates=PodShareProcessNamespace=true`.
|
||||
Process Namespace Sharing is enabled using the `ShareProcessNamespace` field of
|
||||
`v1.PodSpec`. For example:
|
||||
|
||||
{{< code file="share-process-namespace.yaml" >}}
|
||||
{{< codenew file="pods/share-process-namespace.yaml" >}}
|
||||
|
||||
1. Create the pod `nginx` on your cluster:
|
||||
|
||||
$ kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/share-process-namespace.yaml
|
||||
kubectl create -f https://k8s.io/examples/pods/share-process-namespace.yaml
|
||||
|
||||
1. Attach to the `shell` container and run `ps`:
|
||||
|
||||
$ kubectl attach -it nginx -c shell
|
||||
```
|
||||
kubectl attach -it nginx -c shell
|
||||
```
|
||||
|
||||
If you don't see a command prompt, try pressing enter.
|
||||
|
||||
```
|
||||
/ # ps ax
|
||||
PID USER TIME COMMAND
|
||||
1 root 0:00 /pause
|
||||
@@ -56,6 +61,7 @@ Process Namespace Sharing is enabled using the `ShareProcessNamespace` field of
|
||||
14 101 0:00 nginx: worker process
|
||||
15 root 0:00 sh
|
||||
21 root 0:00 ps ax
|
||||
```
|
||||
|
||||
You can signal processes in other containers. For example, send `SIGHUP` to
|
||||
nginx to restart the worker process. This requires the `SYS_PTRACE` capability.
|
||||
|
||||
@@ -1,17 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: nginx
|
||||
spec:
|
||||
shareProcessNamespace: true
|
||||
containers:
|
||||
- name: nginx
|
||||
image: nginx
|
||||
- name: shell
|
||||
image: busybox
|
||||
securityContext:
|
||||
capabilities:
|
||||
add:
|
||||
- SYS_PTRACE
|
||||
stdin: true
|
||||
tty: true
|
||||
@@ -1,11 +0,0 @@
|
||||
kind: PersistentVolumeClaim
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: task-pv-claim
|
||||
spec:
|
||||
storageClassName: manual
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
resources:
|
||||
requests:
|
||||
storage: 3Gi
|
||||
@@ -1,20 +0,0 @@
|
||||
kind: Pod
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: task-pv-pod
|
||||
spec:
|
||||
volumes:
|
||||
- name: task-pv-storage
|
||||
persistentVolumeClaim:
|
||||
claimName: task-pv-claim
|
||||
containers:
|
||||
- name: task-pv-container
|
||||
image: nginx
|
||||
ports:
|
||||
- containerPort: 80
|
||||
name: "http-server"
|
||||
volumeMounts:
|
||||
- mountPath: "/usr/share/nginx/html"
|
||||
name: task-pv-storage
|
||||
|
||||
|
||||
@@ -1,14 +0,0 @@
|
||||
kind: PersistentVolume
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: task-pv-volume
|
||||
labels:
|
||||
type: local
|
||||
spec:
|
||||
storageClassName: manual
|
||||
capacity:
|
||||
storage: 10Gi
|
||||
accessModes:
|
||||
- ReadWriteOnce
|
||||
hostPath:
|
||||
path: "/mnt/data"
|
||||
@@ -1,22 +0,0 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: goproxy
|
||||
labels:
|
||||
app: goproxy
|
||||
spec:
|
||||
containers:
|
||||
- name: goproxy
|
||||
image: k8s.gcr.io/goproxy:0.1
|
||||
ports:
|
||||
- containerPort: 8080
|
||||
readinessProbe:
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
livenessProbe:
|
||||
tcpSocket:
|
||||
port: 8080
|
||||
initialDelaySeconds: 15
|
||||
periodSeconds: 20
|
||||
Reference in New Issue
Block a user