Applied Style Changes (#10043)
* Applied Style Changes * Add a few more light edits
This commit is contained in:
committed by
k8s-ci-robot
parent
22f1f28bfa
commit
1d7e329fd9
@@ -21,28 +21,26 @@ Each node in your cluster must have at least 300 MiB of memory.
|
|||||||
|
|
||||||
A few of the steps on this page require you to run the
|
A few of the steps on this page require you to run the
|
||||||
[metrics-server](https://github.com/kubernetes-incubator/metrics-server)
|
[metrics-server](https://github.com/kubernetes-incubator/metrics-server)
|
||||||
service in your cluster. If you don't have metrics-server
|
service in your cluster. If you do not have the metrics-server
|
||||||
+running, you can skip those steps.
|
running, you can skip those steps.
|
||||||
|
|
||||||
If you are running minikube, run the following command to enable
|
If you are running Minikube, run the following command to enable the
|
||||||
metrics-server:
|
metrics-server:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
minikube addons enable metrics-server
|
minikube addons enable metrics-server
|
||||||
```
|
```
|
||||||
|
|
||||||
To see whether metrics-server (or another provider of the resource metrics
|
To see whether the metrics-server is running, or another provider of the resource metrics
|
||||||
API, `metrics.k8s.io`) is running, enter this command:
|
API (`metrics.k8s.io`), run the following command:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get apiservices
|
kubectl get apiservices
|
||||||
```
|
```
|
||||||
|
|
||||||
If the resource metrics API is available, the output will include a
|
If the resource metrics API is available, the output includes a
|
||||||
reference to `metrics.k8s.io`.
|
reference to `metrics.k8s.io`.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
NAME
|
NAME
|
||||||
v1beta1.metrics.k8s.io
|
v1beta1.metrics.k8s.io
|
||||||
@@ -50,7 +48,6 @@ v1beta1.metrics.k8s.io
|
|||||||
|
|
||||||
{{% /capture %}}
|
{{% /capture %}}
|
||||||
|
|
||||||
|
|
||||||
{{% capture steps %}}
|
{{% capture steps %}}
|
||||||
|
|
||||||
## Create a namespace
|
## Create a namespace
|
||||||
@@ -73,7 +70,7 @@ for the Pod:
|
|||||||
|
|
||||||
{{< codenew file="pods/resource/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 `args` section in the configuration file provides arguments for the Container when it starts.
|
||||||
The `"--vm-bytes", "150M"` arguments tell the Container to attempt to allocate 150 MiB of memory.
|
The `"--vm-bytes", "150M"` arguments tell the Container to attempt to allocate 150 MiB of memory.
|
||||||
|
|
||||||
Create the Pod:
|
Create the Pod:
|
||||||
@@ -82,7 +79,7 @@ Create the Pod:
|
|||||||
kubectl create -f https://k8s.io/examples/pods/resource/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:
|
Verify that the Pod Container is running:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pod memory-demo --namespace=mem-example
|
kubectl get pod memory-demo --namespace=mem-example
|
||||||
@@ -108,7 +105,7 @@ resources:
|
|||||||
...
|
...
|
||||||
```
|
```
|
||||||
|
|
||||||
Use `kubectl top` to fetch the metrics for the pod:
|
Run `kubectl top` to fetch the metrics for the pod:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl top pod memory-demo --namespace=mem-example
|
kubectl top pod memory-demo --namespace=mem-example
|
||||||
@@ -129,22 +126,21 @@ Delete your Pod:
|
|||||||
kubectl delete pod memory-demo --namespace=mem-example
|
kubectl delete pod memory-demo --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
## Exceed a Container's memory limit
|
## Exceed a Container's memory limit
|
||||||
|
|
||||||
A Container can exceed its memory request if the Node has memory available. But a Container
|
A Container can exceed its memory request if the Node has memory available. But a Container
|
||||||
is not allowed to use more than its memory limit. If a Container allocates more memory than
|
is not allowed to use more than its memory limit. If a Container allocates more memory than
|
||||||
its limit, the Container becomes a candidate for termination. If the Container continues to
|
its limit, the Container becomes a candidate for termination. If the Container continues to
|
||||||
consume memory beyond its limit, the Container is terminated. If a terminated Container is
|
consume memory beyond its limit, the Container is terminated. If a terminated Container can be
|
||||||
restartable, the kubelet will restart it, as with any other type of runtime failure.
|
restarted, the kubelet restarts it, as with any other type of runtime failure.
|
||||||
|
|
||||||
In this exercise, you create a Pod that attempts to allocate more memory than its limit.
|
In this exercise, you create a Pod that attempts to allocate more memory than its limit.
|
||||||
Here is the configuration file for a Pod that has one Container. The Container has a
|
Here is the configuration file for a Pod that has one Container with a
|
||||||
memory request of 50 MiB and a memory limit of 100 MiB.
|
memory request of 50 MiB and a memory limit of 100 MiB:
|
||||||
|
|
||||||
{{< codenew file="pods/resource/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
|
In the `args` section of the configuration file, you can see that the Container
|
||||||
will attempt to allocate 250 MiB of memory, which is well above the 100 MiB limit.
|
will attempt to allocate 250 MiB of memory, which is well above the 100 MiB limit.
|
||||||
|
|
||||||
Create the Pod:
|
Create the Pod:
|
||||||
@@ -159,22 +155,20 @@ View detailed information about the Pod:
|
|||||||
kubectl get pod memory-demo-2 --namespace=mem-example
|
kubectl get pod memory-demo-2 --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
At this point, the Container might be running, or it might have been killed. If the
|
At this point, the Container might be running or killed. Repeat the preceding command until the Container is killed:
|
||||||
Container has not yet been killed, repeat the preceding command until you see that
|
|
||||||
the Container has been killed:
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
NAME READY STATUS RESTARTS AGE
|
NAME READY STATUS RESTARTS AGE
|
||||||
memory-demo-2 0/1 OOMKilled 1 24s
|
memory-demo-2 0/1 OOMKilled 1 24s
|
||||||
```
|
```
|
||||||
|
|
||||||
Get a more detailed view of the Container's status:
|
Get a more detailed view of the Container status:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pod memory-demo-2 --output=yaml --namespace=mem-example
|
kubectl get pod memory-demo-2 --output=yaml --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows that the Container has been killed because it is out of memory (OOM).
|
The output shows that the Container was killed because it is out of memory (OOM):
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
lastState:
|
lastState:
|
||||||
@@ -186,14 +180,14 @@ lastState:
|
|||||||
startedAt: null
|
startedAt: null
|
||||||
```
|
```
|
||||||
|
|
||||||
The Container in this exercise is restartable, so the kubelet will restart it. Enter
|
The Container in this exercise can be restarted, so the kubelet restarts it. Repeat
|
||||||
this command several times to see that the Container gets repeatedly killed and restarted:
|
this command several times to see that the Container is repeatedly killed and restarted:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pod memory-demo-2 --namespace=mem-example
|
kubectl get pod memory-demo-2 --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows that the Container gets killed, restarted, killed again, restarted again, and so on:
|
The output shows that the Container is killed, restarted, killed again, restarted again, and so on:
|
||||||
|
|
||||||
```
|
```
|
||||||
stevepe@sperry-1:~/steveperry-53.github.io$ kubectl get pod memory-demo-2 --namespace=mem-example
|
stevepe@sperry-1:~/steveperry-53.github.io$ kubectl get pod memory-demo-2 --namespace=mem-example
|
||||||
@@ -204,8 +198,7 @@ NAME READY STATUS RESTARTS AGE
|
|||||||
memory-demo-2 1/1 Running 2 40s
|
memory-demo-2 1/1 Running 2 40s
|
||||||
```
|
```
|
||||||
|
|
||||||
View detailed information about the Pod's history:
|
View detailed information about the Pod history:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl describe pod memory-demo-2 --namespace=mem-example
|
kubectl describe pod memory-demo-2 --namespace=mem-example
|
||||||
@@ -213,7 +206,6 @@ kubectl describe pod memory-demo-2 --namespace=mem-example
|
|||||||
|
|
||||||
The output shows that the Container starts and fails repeatedly:
|
The output shows that the Container starts and fails repeatedly:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
... Normal Created Created container with id 66a3a20aa7980e61be4922780bf9d24d1a1d8b7395c09861225b0eba1b1f8511
|
... Normal Created Created container with id 66a3a20aa7980e61be4922780bf9d24d1a1d8b7395c09861225b0eba1b1f8511
|
||||||
... Warning BackOff Back-off restarting failed container
|
... Warning BackOff Back-off restarting failed container
|
||||||
@@ -221,7 +213,6 @@ The output shows that the Container starts and fails repeatedly:
|
|||||||
|
|
||||||
View detailed information about your cluster's Nodes:
|
View detailed information about your cluster's Nodes:
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl describe nodes
|
kubectl describe nodes
|
||||||
```
|
```
|
||||||
@@ -250,7 +241,7 @@ has enough available memory to satisfy the Pod's memory request.
|
|||||||
|
|
||||||
In this exercise, you create a Pod that has a memory request so big that it exceeds the
|
In this exercise, you create a Pod that has a memory request so big that it exceeds the
|
||||||
capacity of any Node in your cluster. Here is the configuration file for a Pod that has one
|
capacity of any Node in your cluster. Here is the configuration file for a Pod that has one
|
||||||
Container. The Container requests 1000 GiB of memory, which is likely to exceed the capacity
|
Container with a request for 1000 GiB of memory, which likely exceeds the capacity
|
||||||
of any Node in your cluster.
|
of any Node in your cluster.
|
||||||
|
|
||||||
{{< codenew file="pods/resource/memory-request-limit-3.yaml" >}}
|
{{< codenew file="pods/resource/memory-request-limit-3.yaml" >}}
|
||||||
@@ -261,15 +252,13 @@ Create the Pod:
|
|||||||
kubectl create -f https://k8s.io/examples/pods/resource/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:
|
View the Pod status:
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl get pod memory-demo-3 --namespace=mem-example
|
kubectl get pod memory-demo-3 --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows that the Pod's status is PENDING. That is, the Pod has not been
|
The output shows that the Pod status is PENDING. That is, the Pod is not scheduled to run on any Node, and it will remain in the PENDING state indefinitely:
|
||||||
scheduled to run on any Node, and it will remain in the PENDING state indefinitely:
|
|
||||||
|
|
||||||
|
|
||||||
```
|
```
|
||||||
kubectl get pod memory-demo-3 --namespace=mem-example
|
kubectl get pod memory-demo-3 --namespace=mem-example
|
||||||
@@ -279,14 +268,12 @@ memory-demo-3 0/1 Pending 0 25s
|
|||||||
|
|
||||||
View detailed information about the Pod, including events:
|
View detailed information about the Pod, including events:
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl describe pod memory-demo-3 --namespace=mem-example
|
kubectl describe pod memory-demo-3 --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
The output shows that the Container cannot be scheduled because of insufficient memory on the Nodes:
|
The output shows that the Container cannot be scheduled because of insufficient memory on the Nodes:
|
||||||
|
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
Events:
|
Events:
|
||||||
... Reason Message
|
... Reason Message
|
||||||
@@ -310,9 +297,9 @@ Delete your Pod:
|
|||||||
kubectl delete pod memory-demo-3 --namespace=mem-example
|
kubectl delete pod memory-demo-3 --namespace=mem-example
|
||||||
```
|
```
|
||||||
|
|
||||||
## If you don’t specify a memory limit
|
## If you do not specify a memory limit
|
||||||
|
|
||||||
If you don’t specify a memory limit for a Container, then one of these situations applies:
|
If you do not specify a memory limit for a Container, one of the following situations applies:
|
||||||
|
|
||||||
* The Container has no upper bound on the amount of memory it uses. The Container
|
* The Container has no upper bound on the amount of memory it uses. The Container
|
||||||
could use all of the memory available on the Node where it is running.
|
could use all of the memory available on the Node where it is running.
|
||||||
|
|||||||
Reference in New Issue
Block a user