You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: content/en/docs/tasks/administer-cluster/safely-drain-node.md
+39-40Lines changed: 39 additions & 40 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -6,23 +6,21 @@ reviewers:
6
6
- kow3ns
7
7
title: Safely Drain a Node while Respecting the PodDisruptionBudget
8
8
content_type: task
9
+
min-kubernetes-server-version: 1.5
9
10
---
10
11
11
12
<!-- overview -->
12
-
This page shows how to safely drain a node, respecting the PodDisruptionBudget you have defined.
13
-
13
+
This page shows how to safely drain a {{< glossary_tooltip text="node" term_id="node" >}},
14
+
respecting the PodDisruptionBudget you have defined.
14
15
15
16
## {{% heading "prerequisites" %}}
16
17
17
-
18
-
This task assumes that you have met the following prerequisites:
19
-
20
-
* You are using Kubernetes release >= 1.5.
21
-
* Either:
18
+
{{% version-check %}}
19
+
This task also assumes that you have met the following prerequisites:
22
20
1. You do not require your applications to be highly available during the
23
21
node drain, or
24
-
1. You have read about the [PodDisruptionBudget concept](/docs/concepts/workloads/pods/disruptions/)
25
-
and [Configured PodDisruptionBudgets](/docs/tasks/run-application/configure-pdb/) for
22
+
1. You have read about the [PodDisruptionBudget](/docs/concepts/workloads/pods/disruptions/) concept,
23
+
and have [configured PodDisruptionBudgets](/docs/tasks/run-application/configure-pdb/) for
26
24
applications that need them.
27
25
28
26
@@ -35,10 +33,10 @@ You can use `kubectl drain` to safely evict all of your pods from a
35
33
node before you perform maintenance on the node (e.g. kernel upgrade,
36
34
hardware maintenance, etc.). Safe evictions allow the pod's containers
37
35
to [gracefully terminate](/docs/concepts/workloads/pods/pod-lifecycle/#pod-termination)
38
-
and will respect the `PodDisruptionBudgets` you have specified.
36
+
and will respect the PodDisruptionBudgets you have specified.
39
37
40
38
{{< note >}}
41
-
By default `kubectl drain`will ignore certain system pods on the node
39
+
By default `kubectl drain`ignores certain system pods on the node
42
40
that cannot be killed; see
43
41
the [kubectl drain](/docs/reference/generated/kubectl/kubectl-commands/#drain)
44
42
documentation for more details.
@@ -78,29 +76,29 @@ The `kubectl drain` command should only be issued to a single node at a
78
76
time. However, you can run multiple `kubectl drain` commands for
79
77
different nodes in parallel, in different terminals or in the
80
78
background. Multiple drain commands running concurrently will still
81
-
respect the `PodDisruptionBudget` you specify.
79
+
respect the PodDisruptionBudget you specify.
82
80
83
81
For example, if you have a StatefulSet with three replicas and have
84
-
set a `PodDisruptionBudget` for that set specifying `minAvailable:
85
-
2`. `kubectl drain` will only evict a pod from the StatefulSet if all
86
-
three pods are ready, and if you issue multiple drain commands in
87
-
parallel, Kubernetes will respect the PodDisruptionBudget and ensure
88
-
that only one pod is unavailable at any given time. Any drains that
89
-
would cause the number of ready replicas to fall below the specified
90
-
budget are blocked.
82
+
set a PodDisruptionBudget for that set specifying `minAvailable: 2`,
83
+
`kubectl drain` only evicts a pod from the StatefulSet if all three
84
+
replicas pods are ready; if then you issue multiple drain commands in
85
+
parallel, Kubernetes respects the PodDisruptionBudget and ensure
86
+
that only 1 (calculated as `replicas - minAvailable`) Pod is unavailable
87
+
at any given time. Any drains that would cause the number of ready
88
+
replicas to fall below the specified budget are blocked.
91
89
92
-
## The Eviction API
90
+
## The Eviction API {#eviction-api}
93
91
94
92
If you prefer not to use [kubectl drain](/docs/reference/generated/kubectl/kubectl-commands/#drain) (such as
95
93
to avoid calling to an external command, or to get finer control over the pod
96
94
eviction process), you can also programmatically cause evictions using the eviction API.
97
95
98
-
You should first be familiar with using [Kubernetes language clients](/docs/tasks/administer-cluster/access-cluster-api/#programmatic-access-to-the-api).
96
+
You should first be familiar with using [Kubernetes language clients](/docs/tasks/administer-cluster/access-cluster-api/#programmatic-access-to-the-api) to access the API.
99
97
100
98
The eviction subresource of a
101
-
pod can be thought of as a kind of policy-controlled DELETE operation on the pod
102
-
itself. To attempt an eviction (perhaps more REST-precisely, to attempt to
103
-
*create* an eviction), you POST an attempted operation. Here's an example:
99
+
Pod can be thought of as a kind of policy-controlled DELETE operation on the Pod
100
+
itself. To attempt an eviction (more precisely: to attempt to
101
+
*create* an Eviction), you POST an attempted operation. Here's an example:
104
102
105
103
```json
106
104
{
@@ -116,21 +114,19 @@ itself. To attempt an eviction (perhaps more REST-precisely, to attempt to
0 commit comments