Skip to content

Commit 5ab064c

Browse files
author
Tim Bannister
committed
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
1 parent 239eb65 commit 5ab064c

File tree

6 files changed

+225
-155
lines changed

6 files changed

+225
-155
lines changed

content/en/docs/tasks/administer-cluster/manage-resources/cpu-constraint-namespace.md

Lines changed: 35 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@ weight: 40
77

88
<!-- overview -->
99

10-
This page shows how to set minimum and maximum values for the CPU resources used by Containers
11-
and Pods in a namespace. You specify minimum and maximum CPU values in a
12-
[LimitRange](/docs/reference/generated/kubernetes-api/{{< param "version" >}}/#limitrange-v1-core)
10+
This page shows how to set minimum and maximum values for the CPU resources used by containers
11+
and Pods in a {{< glossary_tooltip text="namespace" term_id="namespace" >}}. You specify minimum
12+
and maximum CPU values in a
13+
[LimitRange](/docs/reference/kubernetes-api/policy-resources/limit-range-v1/)
1314
object. If a Pod does not meet the constraints imposed by the LimitRange, it cannot be created
1415
in the namespace.
1516

@@ -19,11 +20,13 @@ in the namespace.
1920
## {{% heading "prerequisites" %}}
2021

2122

22-
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
23-
24-
Your cluster must have at least 1 CPU available for use to run the task examples.
23+
{{< include "task-tutorial-prereqs.md" >}}
2524

25+
You must have access to create namespaces in your cluster.
2626

27+
Your cluster must have at least 1.0 CPU available for use to run the task examples.
28+
See [meaning of CPU](/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu)
29+
to learn what Kubernetes means by “1 CPU”.
2730

2831

2932
<!-- steps -->
@@ -39,7 +42,7 @@ kubectl create namespace constraints-cpu-example
3942

4043
## Create a LimitRange and a Pod
4144

42-
Here's the configuration file for a LimitRange:
45+
Here's an example manifest for a LimitRange:
4346

4447
{{< codenew file="admin/resource/cpu-constraints.yaml" >}}
4548

@@ -72,23 +75,23 @@ limits:
7275
type: Container
7376
```
7477
75-
Now whenever a Container is created in the constraints-cpu-example namespace, Kubernetes
76-
performs these steps:
78+
Now whenever you create a Pod in the constraints-cpu-example namespace (or some other client
79+
of the Kubernetes API creates an equivalent Pod), Kubernetes performs these steps:
7780
78-
* If the Container does not specify its own CPU request and limit, assign the default
79-
CPU request and limit to the Container.
81+
* If any container in that Pod does not specify its own CPU request and limit, the control plane
82+
assigns the default CPU request and limit to that container.
8083
81-
* Verify that the Container specifies a CPU request that is greater than or equal to 200 millicpu.
84+
* Verify that every container in that Pod specifies a CPU request that is greater than or equal to 200 millicpu.
8285
83-
* Verify that the Container specifies a CPU limit that is less than or equal to 800 millicpu.
86+
* Verify that every container in that Pod specifies a CPU limit that is less than or equal to 800 millicpu.
8487
8588
{{< note >}}
8689
When creating a `LimitRange` object, you can specify limits on huge-pages
8790
or GPUs as well. However, when both `default` and `defaultRequest` are specified
8891
on these resources, the two values must be the same.
8992
{{< /note >}}
9093

91-
Here's the configuration file for a Pod that has one Container. The Container manifest
94+
Here's a manifest for a Pod that has one container. The container manifest
9295
specifies a CPU request of 500 millicpu and a CPU limit of 800 millicpu. These satisfy the
9396
minimum and maximum CPU constraints imposed by the LimitRange.
9497

@@ -100,7 +103,7 @@ Create the Pod:
100103
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-constraints-pod.yaml --namespace=constraints-cpu-example
101104
```
102105

103-
Verify that the Pod's Container is running:
106+
Verify that the Pod is running and that its container is healthy:
104107

105108
```shell
106109
kubectl get pod constraints-cpu-demo --namespace=constraints-cpu-example
@@ -112,7 +115,7 @@ View detailed information about the Pod:
112115
kubectl get pod constraints-cpu-demo --output=yaml --namespace=constraints-cpu-example
113116
```
114117

115-
The output shows that the Container has a CPU request of 500 millicpu and CPU limit
118+
The output shows that the Pod's only container has a CPU request of 500 millicpu and CPU limit
116119
of 800 millicpu. These satisfy the constraints imposed by the LimitRange.
117120

118121
```yaml
@@ -131,7 +134,7 @@ kubectl delete pod constraints-cpu-demo --namespace=constraints-cpu-example
131134

132135
## Attempt to create a Pod that exceeds the maximum CPU constraint
133136

134-
Here's the configuration file for a Pod that has one Container. The Container specifies a
137+
Here's a manifest for a Pod that has one container. The container specifies a
135138
CPU request of 500 millicpu and a cpu limit of 1.5 cpu.
136139

137140
{{< codenew file="admin/resource/cpu-constraints-pod-2.yaml" >}}
@@ -142,8 +145,8 @@ Attempt to create the Pod:
142145
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-constraints-pod-2.yaml --namespace=constraints-cpu-example
143146
```
144147

145-
The output shows that the Pod does not get created, because the Container specifies a CPU limit that is
146-
too large:
148+
The output shows that the Pod does not get created, because it defines an unacceptable container.
149+
That container is not acceptable because it specifies a CPU limit that is too large:
147150

148151
```
149152
Error from server (Forbidden): error when creating "examples/admin/resource/cpu-constraints-pod-2.yaml":
@@ -152,7 +155,7 @@ pods "constraints-cpu-demo-2" is forbidden: maximum cpu usage per Container is 8
152155

153156
## Attempt to create a Pod that does not meet the minimum CPU request
154157

155-
Here's the configuration file for a Pod that has one Container. The Container specifies a
158+
Here's a manifest for a Pod that has one container. The container specifies a
156159
CPU request of 100 millicpu and a CPU limit of 800 millicpu.
157160

158161
{{< codenew file="admin/resource/cpu-constraints-pod-3.yaml" >}}
@@ -163,8 +166,9 @@ Attempt to create the Pod:
163166
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-constraints-pod-3.yaml --namespace=constraints-cpu-example
164167
```
165168

166-
The output shows that the Pod does not get created, because the Container specifies a CPU
167-
request that is too small:
169+
The output shows that the Pod does not get created, because it defines an unacceptable container.
170+
That container is not acceptable because it specifies a CPU limit that is lower than the
171+
enforced minimum:
168172

169173
```
170174
Error from server (Forbidden): error when creating "examples/admin/resource/cpu-constraints-pod-3.yaml":
@@ -173,8 +177,8 @@ pods "constraints-cpu-demo-3" is forbidden: minimum cpu usage per Container is 2
173177

174178
## Create a Pod that does not specify any CPU request or limit
175179

176-
Here's the configuration file for a Pod that has one Container. The Container does not
177-
specify a CPU request, and it does not specify a CPU limit.
180+
Here's a manifest for a Pod that has one container. The container does not
181+
specify a CPU request, nor does it specify a CPU limit.
178182

179183
{{< codenew file="admin/resource/cpu-constraints-pod-4.yaml" >}}
180184

@@ -190,8 +194,9 @@ View detailed information about the Pod:
190194
kubectl get pod constraints-cpu-demo-4 --namespace=constraints-cpu-example --output=yaml
191195
```
192196

193-
The output shows that the Pod's Container has a CPU request of 800 millicpu and a CPU limit of 800 millicpu.
194-
How did the Container get those values?
197+
The output shows that the Pod's single container has a CPU request of 800 millicpu and a
198+
CPU limit of 800 millicpu.
199+
How did that container get those values?
195200

196201
```yaml
197202
resources:
@@ -201,11 +206,12 @@ resources:
201206
cpu: 800m
202207
```
203208

204-
Because your Container did not specify its own CPU request and limit, it was given the
209+
Because that container did not specify its own CPU request and limit, the control plane
210+
applied the
205211
[default CPU request and limit](/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace/)
206-
from the LimitRange.
212+
from the LimitRange for this namespace.
207213

208-
At this point, your Container might be running or it might not be running. Recall that a prerequisite for this task is that your cluster must have at least 1 CPU available for use. If each of your Nodes has only 1 CPU, then there might not be enough allocatable CPU on any Node to accommodate a request of 800 millicpu. If you happen to be using Nodes with 2 CPU, then you probably have enough CPU to accommodate the 800 millicpu request.
214+
At this point, your Pod might be running or it might not be running. Recall that a prerequisite for this task is that your cluster must have at least 1 CPU available for use. If each of your Nodes has only 1 CPU, then there might not be enough allocatable CPU on any Node to accommodate a request of 800 millicpu. If you happen to be using Nodes with 2 CPU, then you probably have enough CPU to accommodate the 800 millicpu request.
209215

210216
Delete your Pod:
211217

content/en/docs/tasks/administer-cluster/manage-resources/cpu-default-namespace.md

Lines changed: 51 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,29 @@ weight: 20
66

77
<!-- overview -->
88

9-
This page shows how to configure default CPU requests and limits for a namespace.
10-
A Kubernetes cluster can be divided into namespaces. If a Container is created in a namespace
11-
that has a default CPU limit, and the Container does not specify its own CPU limit, then
12-
the Container is assigned the default CPU limit. Kubernetes assigns a default CPU request
13-
under certain conditions that are explained later in this topic.
9+
This page shows how to configure default CPU requests and limits for a
10+
{{< glossary_tooltip text="namespace" term_id="namespace" >}}.
1411

12+
A Kubernetes cluster can be divided into namespaces. If you create a Pod within a
13+
namespace that has a default CPU
14+
[limit](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits), and any container in that Pod does not specify
15+
its own CPU limit, then the
16+
{{< glossary_tooltip text="control plane" term_id="control-plane" >}} assigns the default
17+
CPU limit to that container.
1518

19+
Kubernetes assigns a default CPU
20+
[request](/docs/concepts/configuration/manage-resources-containers/#requests-and-limits),
21+
but only under certain conditions that are explained later in this page.
1622

1723
## {{% heading "prerequisites" %}}
1824

1925

20-
{{< include "task-tutorial-prereqs.md" >}} {{< version-check >}}
26+
{{< include "task-tutorial-prereqs.md" >}}
2127

28+
You must have access to create namespaces in your cluster.
29+
30+
If you're not already familiar with what Kubernetes means by 1.0 CPU,
31+
read [meaning of CPU](/docs/concepts/configuration/manage-resources-containers/#meaning-of-cpu).
2232

2333
<!-- steps -->
2434

@@ -33,8 +43,8 @@ kubectl create namespace default-cpu-example
3343

3444
## Create a LimitRange and a Pod
3545

36-
Here's the configuration file for a LimitRange object. The configuration specifies
37-
a default CPU request and a default CPU limit.
46+
Here's a manifest for an example {{< glossary_tooltip text="LimitRange" term_id="limitrange" >}}.
47+
The manifest specifies a default CPU request and a default CPU limit.
3848

3949
{{< codenew file="admin/resource/cpu-defaults.yaml" >}}
4050

@@ -44,12 +54,12 @@ Create the LimitRange in the default-cpu-example namespace:
4454
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults.yaml --namespace=default-cpu-example
4555
```
4656

47-
Now if a Container is created in the default-cpu-example namespace, and the
48-
Container does not specify its own values for CPU request and CPU limit,
49-
the Container is given a default CPU request of 0.5 and a default
57+
Now if you create a Pod in the default-cpu-example namespace, and any container
58+
in that Pod does not specify its own values for CPU request and CPU limit,
59+
then the control plane applies default values: a CPU request of 0.5 and a default
5060
CPU limit of 1.
5161

52-
Here's the configuration file for a Pod that has one Container. The Container
62+
Here's a manifest for a Pod that has one container. The container
5363
does not specify a CPU request and limit.
5464

5565
{{< codenew file="admin/resource/cpu-defaults-pod.yaml" >}}
@@ -66,8 +76,9 @@ View the Pod's specification:
6676
kubectl get pod default-cpu-demo --output=yaml --namespace=default-cpu-example
6777
```
6878

69-
The output shows that the Pod's Container has a CPU request of 500 millicpus and
70-
a CPU limit of 1 cpu. These are the default values specified by the LimitRange.
79+
The output shows that the Pod's only container has a CPU request of 500m `cpu`
80+
(which you can read as “500 millicpu”), and a CPU limit of 1 `cpu`.
81+
These are the default values specified by the LimitRange.
7182

7283
```shell
7384
containers:
@@ -81,9 +92,9 @@ containers:
8192
cpu: 500m
8293
```
8394

84-
## What if you specify a Container's limit, but not its request?
95+
## What if you specify a container's limit, but not its request?
8596

86-
Here's the configuration file for a Pod that has one Container. The Container
97+
Here's a manifest for a Pod that has one container. The container
8798
specifies a CPU limit, but not a request:
8899

89100
{{< codenew file="admin/resource/cpu-defaults-pod-2.yaml" >}}
@@ -95,14 +106,15 @@ Create the Pod:
95106
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults-pod-2.yaml --namespace=default-cpu-example
96107
```
97108

98-
View the Pod specification:
109+
View the [specification](/docs/concepts/overview/working-with-objects/kubernetes-objects/#object-spec-and-status)
110+
of the Pod that you created:
99111

100112
```
101113
kubectl get pod default-cpu-demo-2 --output=yaml --namespace=default-cpu-example
102114
```
103115

104-
The output shows that the Container's CPU request is set to match its CPU limit.
105-
Notice that the Container was not assigned the default CPU request value of 0.5 cpu.
116+
The output shows that the container's CPU request is set to match its CPU limit.
117+
Notice that the container was not assigned the default CPU request value of 0.5 `cpu`:
106118

107119
```
108120
resources:
@@ -112,9 +124,9 @@ resources:
112124
cpu: "1"
113125
```
114126

115-
## What if you specify a Container's request, but not its limit?
127+
## What if you specify a container's request, but not its limit?
116128

117-
Here's the configuration file for a Pod that has one Container. The Container
129+
Here's an example manifest for a Pod that has one container. The container
118130
specifies a CPU request, but not a limit:
119131

120132
{{< codenew file="admin/resource/cpu-defaults-pod-3.yaml" >}}
@@ -125,15 +137,16 @@ Create the Pod:
125137
kubectl apply -f https://k8s.io/examples/admin/resource/cpu-defaults-pod-3.yaml --namespace=default-cpu-example
126138
```
127139

128-
View the Pod specification:
140+
View the specification of the Pod that you created:
129141

130142
```
131143
kubectl get pod default-cpu-demo-3 --output=yaml --namespace=default-cpu-example
132144
```
133145

134-
The output shows that the Container's CPU request is set to the value specified in the
135-
Container's configuration file. The Container's CPU limit is set to 1 cpu, which is the
136-
default CPU limit for the namespace.
146+
The output shows that the container's CPU request is set to the value you specified at
147+
the time you created the Pod (in other words: it matches the manifest).
148+
However, the same container's CPU limit is set to 1 `cpu`, which is the default CPU limit
149+
for that namespace.
137150

138151
```
139152
resources:
@@ -145,16 +158,22 @@ resources:
145158

146159
## Motivation for default CPU limits and requests
147160

148-
If your namespace has a
149-
[resource quota](/docs/tasks/administer-cluster/manage-resources/quota-memory-cpu-namespace/),
161+
If your namespace has a CPU {{< glossary_tooltip text="resource quota" term_id="resource-quota" >}}
162+
configured,
150163
it is helpful to have a default value in place for CPU limit.
151-
Here are two of the restrictions that a resource quota imposes on a namespace:
164+
Here are two of the restrictions that a CPU resource quota imposes on a namespace:
165+
166+
* For every Pod that runs in the namespace, each of its containers must have a CPU limit.
167+
* CPU limits apply a resource reservation on the node where the Pod in question is scheduled.
168+
The total amount of CPU that is reserved for use by all Pods in the namespace must not
169+
exceed a specified limit.
170+
171+
When you add a LimitRange:
152172

153-
* Every Container that runs in the namespace must have its own CPU limit.
154-
* The total amount of CPU used by all Containers in the namespace must not exceed a specified limit.
173+
If any Pod in that namespace that includes a container does not specify its own CPU limit,
174+
the control plane applies the default CPU limit to that container, and the Pod can be
175+
allowed to run in a namespace that is restricted by a CPU ResourceQuota.
155176

156-
If a Container does not specify its own CPU limit, it is given the default limit, and then
157-
it can be allowed to run in a namespace that is restricted by a quota.
158177

159178
## Clean up
160179

0 commit comments

Comments
 (0)