Tidy resource management task pages
Revise tasks within “Manage Memory, CPU, and API Resources”: - reword to avoid implying that API clients can create a container (you can, but its done by creating a Pod) - call a manifest a manifest - use tooltips where relevant - link to new API reference not the old one - other improvements
This commit is contained in:
+51
-32
@@ -6,19 +6,29 @@ weight: 20
|
||||
|
||||
<!-- overview -->
|
||||
|
||||
This page shows how to configure default CPU requests and limits for a namespace.
|
||||
A Kubernetes cluster can be divided into namespaces. If a Container is created in a namespace
|
||||
that has a default CPU limit, and the Container does not specify its own CPU limit, then
|
||||
the Container is assigned the default CPU limit. Kubernetes assigns a default CPU request
|
||||
under certain conditions that are explained later in this topic.
|
||||
This page shows how to configure default CPU requests and limits for a
|
||||
{{< glossary_tooltip text="namespace" term_id="namespace" >}}.
|
||||
|
||||
A Kubernetes cluster can be divided into namespaces. If you create a Pod within a
|
||||
namespace that has a default CPU
|
||||
[limit](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits), and any container in that Pod does not specify
|
||||
its own CPU limit, then the
|
||||
{{< glossary_tooltip text="control plane" term_id="control-plane" >}} assigns the default
|
||||
CPU limit to that container.
|
||||
|
||||
Kubernetes assigns a default CPU
|
||||
[request](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits),
|
||||
but only under certain conditions that are explained later in this page.
|
||||
|
||||
## {{% heading "prerequisites" %}}
|
||||
|
||||
|
||||
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
|
||||
{{< include "task-tutorial-prereqs.md" >}}
|
||||
|
||||
You must have access to create namespaces in your cluster.
|
||||
|
||||
If you're not already familiar with what Kubernetes means by 1.0 CPU,
|
||||
read [meaning of CPU](/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu).
|
||||
|
||||
<!-- steps -->
|
||||
|
||||
@@ -33,8 +43,8 @@ kubectl create namespace default-cpu-example
|
||||
|
||||
## Create a LimitRange and a Pod
|
||||
|
||||
Here's the configuration file for a LimitRange object. The configuration specifies
|
||||
a default CPU request and a default CPU limit.
|
||||
Here's a manifest for an example {{< glossary_tooltip text="LimitRange" term_id="limitrange" >}}.
|
||||
The manifest specifies a default CPU request and a default CPU limit.
|
||||
|
||||
{{< codenew file="admin/resource/cpu-defaults.yaml" >}}
|
||||
|
||||
@@ -44,12 +54,12 @@ Create the LimitRange in the default-cpu-example namespace:
|
||||
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults.yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
Now if a Container is created in the default-cpu-example namespace, and the
|
||||
Container does not specify its own values for CPU request and CPU limit,
|
||||
the Container is given a default CPU request of 0.5 and a default
|
||||
Now if you create a Pod in the default-cpu-example namespace, and any container
|
||||
in that Pod does not specify its own values for CPU request and CPU limit,
|
||||
then the control plane applies default values: a CPU request of 0.5 and a default
|
||||
CPU limit of 1.
|
||||
|
||||
Here's the configuration file for a Pod that has one Container. The Container
|
||||
Here's a manifest for a Pod that has one container. The container
|
||||
does not specify a CPU request and limit.
|
||||
|
||||
{{< codenew file="admin/resource/cpu-defaults-pod.yaml" >}}
|
||||
@@ -66,8 +76,9 @@ View the Pod's specification:
|
||||
kubectl get pod default-cpu-demo --output=yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
The output shows that the Pod's Container has a CPU request of 500 millicpus and
|
||||
a CPU limit of 1 cpu. These are the default values specified by the LimitRange.
|
||||
The output shows that the Pod's only container has a CPU request of 500m `cpu`
|
||||
(which you can read as “500 millicpu”), and a CPU limit of 1 `cpu`.
|
||||
These are the default values specified by the LimitRange.
|
||||
|
||||
```shell
|
||||
containers:
|
||||
@@ -81,9 +92,9 @@ containers:
|
||||
cpu: 500m
|
||||
```
|
||||
|
||||
## What if you specify a Container's limit, but not its request?
|
||||
## What if you specify a container's limit, but not its request?
|
||||
|
||||
Here's the configuration file for a Pod that has one Container. The Container
|
||||
Here's a manifest for a Pod that has one container. The container
|
||||
specifies a CPU limit, but not a request:
|
||||
|
||||
{{< codenew file="admin/resource/cpu-defaults-pod-2.yaml" >}}
|
||||
@@ -95,14 +106,15 @@ Create the Pod:
|
||||
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults-pod-2.yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
View the Pod specification:
|
||||
View the [specification](/docs/concepts/overview/working-with-objects/kubernetes-objects/#object-spec-and-status)
|
||||
of the Pod that you created:
|
||||
|
||||
```
|
||||
kubectl get pod default-cpu-demo-2 --output=yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
The output shows that the Container's CPU request is set to match its CPU limit.
|
||||
Notice that the Container was not assigned the default CPU request value of 0.5 cpu.
|
||||
The output shows that the container's CPU request is set to match its CPU limit.
|
||||
Notice that the container was not assigned the default CPU request value of 0.5 `cpu`:
|
||||
|
||||
```
|
||||
resources:
|
||||
@@ -112,9 +124,9 @@ resources:
|
||||
cpu: "1"
|
||||
```
|
||||
|
||||
## What if you specify a Container's request, but not its limit?
|
||||
## What if you specify a container's request, but not its limit?
|
||||
|
||||
Here's the configuration file for a Pod that has one Container. The Container
|
||||
Here's an example manifest for a Pod that has one container. The container
|
||||
specifies a CPU request, but not a limit:
|
||||
|
||||
{{< codenew file="admin/resource/cpu-defaults-pod-3.yaml" >}}
|
||||
@@ -125,15 +137,16 @@ Create the Pod:
|
||||
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults-pod-3.yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
View the Pod specification:
|
||||
View the specification of the Pod that you created:
|
||||
|
||||
```
|
||||
kubectl get pod default-cpu-demo-3 --output=yaml --namespace=default-cpu-example
|
||||
```
|
||||
|
||||
The output shows that the Container's CPU request is set to the value specified in the
|
||||
Container's configuration file. The Container's CPU limit is set to 1 cpu, which is the
|
||||
default CPU limit for the namespace.
|
||||
The output shows that the container's CPU request is set to the value you specified at
|
||||
the time you created the Pod (in other words: it matches the manifest).
|
||||
However, the same container's CPU limit is set to 1 `cpu`, which is the default CPU limit
|
||||
for that namespace.
|
||||
|
||||
```
|
||||
resources:
|
||||
@@ -145,16 +158,22 @@ resources:
|
||||
|
||||
## Motivation for default CPU limits and requests
|
||||
|
||||
If your namespace has a
|
||||
[resource quota](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/),
|
||||
If your namespace has a CPU {{< glossary_tooltip text="resource quota" term_id="resource-quota" >}}
|
||||
configured,
|
||||
it is helpful to have a default value in place for CPU limit.
|
||||
Here are two of the restrictions that a resource quota imposes on a namespace:
|
||||
Here are two of the restrictions that a CPU resource quota imposes on a namespace:
|
||||
|
||||
* Every Container that runs in the namespace must have its own CPU limit.
|
||||
* The total amount of CPU used by all Containers in the namespace must not exceed a specified limit.
|
||||
* For every Pod that runs in the namespace, each of its containers must have a CPU limit.
|
||||
* CPU limits apply a resource reservation on the node where the Pod in question is scheduled.
|
||||
The total amount of CPU that is reserved for use by all Pods in the namespace must not
|
||||
exceed a specified limit.
|
||||
|
||||
When you add a LimitRange:
|
||||
|
||||
If any Pod in that namespace that includes a container does not specify its own CPU limit,
|
||||
the control plane applies the default CPU limit to that container, and the Pod can be
|
||||
allowed to run in a namespace that is restricted by a CPU ResourceQuota.
|
||||
|
||||
If a Container does not specify its own CPU limit, it is given the default limit, and then
|
||||
it can be allowed to run in a namespace that is restricted by a quota.
|
||||
|
||||
## Clean up
|
||||
|
||||
|
||||
Reference in New Issue
Block a user