1KUBERNETES(1)(kubernetes) KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7
9 kubectl drain - Drain node in preparation for maintenance
10
11
12
14 kubectl drain [OPTIONS]
15
16
17
19 Drain node in preparation for maintenance.
20
21
22 The given node will be marked unschedulable to prevent new pods from
23 arriving. 'drain' evicts the pods if the API server supports
24 https://kubernetes.io/docs/concepts/workloads/pods/disruptions/ evic‐
25 tion https://kubernetes.io/docs/concepts/workloads/pods/disruptions/ .
26 Otherwise, it will use normal DELETE to delete the pods. The 'drain'
27 evicts or deletes all pods except mirror pods (which cannot be deleted
28 through the API server). If there are daemon set-managed pods, drain
29 will not proceed without --ignore-daemonsets, and regardless it will
30 not delete any daemon set-managed pods, because those pods would be im‐
31 mediately replaced by the daemon set controller, which ignores un‐
32 schedulable markings. If there are any pods that are neither mirror
33 pods nor managed by a replication controller, replica set, daemon set,
34 stateful set, or job, then drain will not delete any pods unless you
35 use --force. --force will also allow deletion to proceed if the manag‐
36 ing resource of one or more pods is missing.
37
38
39 'drain' waits for graceful termination. You should not operate on the
40 machine until the command completes.
41
42
43 When you are ready to put the node back into service, use kubectl un‐
44 cordon, which will make the node schedulable again.
45
46
47 https://kubernetes.io/images/docs/kubectl_drain.svg Workflowhttps://ku‐
48 bernetes.io/images/docs/kubectl_drain.svg
49
50
51
53 --chunk-size=500 Return large lists in chunks rather than all at
54 once. Pass 0 to disable. This flag is beta and may change in the fu‐
55 ture.
56
57
58 --delete-emptydir-data=false Continue even if there are pods using
59 emptyDir (local data that will be deleted when the node is drained).
60
61
62 --delete-local-data=false Continue even if there are pods using
63 emptyDir (local data that will be deleted when the node is drained).
64
65
66 --disable-eviction=false Force drain to use delete, even if evic‐
67 tion is supported. This will bypass checking PodDisruptionBudgets, use
68 with caution.
69
70
71 --dry-run="none" Must be "none", "server", or "client". If client
72 strategy, only print the object that would be sent, without sending it.
73 If server strategy, submit server-side request without persisting the
74 resource.
75
76
77 --force=false Continue even if there are pods that do not declare
78 a controller.
79
80
81 --grace-period=-1 Period of time in seconds given to each pod to
82 terminate gracefully. If negative, the default value specified in the
83 pod will be used.
84
85
86 --ignore-daemonsets=false Ignore DaemonSet-managed pods.
87
88
89 --pod-selector="" Label selector to filter pods on the node
90
91
92 -l, --selector="" Selector (label query) to filter on, supports
93 '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects
94 must satisfy all of the specified label constraints.
95
96
97 --skip-wait-for-delete-timeout=0 If pod DeletionTimestamp older
98 than N seconds, skip waiting for the pod. Seconds must be greater than
99 0 to skip.
100
101
102 --timeout=0s The length of time to wait before giving up, zero
103 means infinite
104
105
106
108 --as="" Username to impersonate for the operation. User could be a
109 regular user or a service account in a namespace.
110
111
112 --as-group=[] Group to impersonate for the operation, this flag
113 can be repeated to specify multiple groups.
114
115
116 --as-uid="" UID to impersonate for the operation.
117
118
119 --azure-container-registry-config="" Path to the file containing
120 Azure container registry configuration information.
121
122
123 --cache-dir="/builddir/.kube/cache" Default cache directory
124
125
126 --certificate-authority="" Path to a cert file for the certificate
127 authority
128
129
130 --client-certificate="" Path to a client certificate file for TLS
131
132
133 --client-key="" Path to a client key file for TLS
134
135
136 --cluster="" The name of the kubeconfig cluster to use
137
138
139 --context="" The name of the kubeconfig context to use
140
141
142 --disable-compression=false If true, opt-out of response compres‐
143 sion for all requests to the server
144
145
146 --insecure-skip-tls-verify=false If true, the server's certificate
147 will not be checked for validity. This will make your HTTPS connections
148 insecure
149
150
151 --kubeconfig="" Path to the kubeconfig file to use for CLI re‐
152 quests.
153
154
155 --match-server-version=false Require server version to match
156 client version
157
158
159 -n, --namespace="" If present, the namespace scope for this CLI
160 request
161
162
163 --password="" Password for basic authentication to the API server
164
165
166 --profile="none" Name of profile to capture. One of
167 (none|cpu|heap|goroutine|threadcreate|block|mutex)
168
169
170 --profile-output="profile.pprof" Name of the file to write the
171 profile to
172
173
174 --request-timeout="0" The length of time to wait before giving up
175 on a single server request. Non-zero values should contain a corre‐
176 sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
177 out requests.
178
179
180 -s, --server="" The address and port of the Kubernetes API server
181
182
183 --tls-server-name="" Server name to use for server certificate
184 validation. If it is not provided, the hostname used to contact the
185 server is used
186
187
188 --token="" Bearer token for authentication to the API server
189
190
191 --user="" The name of the kubeconfig user to use
192
193
194 --username="" Username for basic authentication to the API server
195
196
197 --version=false Print version information and quit
198
199
200 --warnings-as-errors=false Treat warnings received from the server
201 as errors and exit with a non-zero exit code
202
203
204
206 # Drain node "foo", even if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set on it
207 kubectl drain foo --force
208
209 # As above, but abort if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set, and use a grace period of 15 minutes
210 kubectl drain foo --grace-period=900
211
212
213
214
216 kubectl(1),
217
218
219
221 January 2015, Originally compiled by Eric Paris (eparis at redhat dot
222 com) based on the kubernetes source material, but hopefully they have
223 been automatically generated since!
224
225
226
227Manuals User KUBERNETES(1)(kubernetes)