1KUBERNETES(1)(kubernetes)                            KUBERNETES(1)(kubernetes)
2
3
4
5Eric Paris Jan 2015
6
7

NAME

9       kubectl drain - Drain node in preparation for maintenance
10
11
12

SYNOPSIS

14       kubectl drain [OPTIONS]
15
16
17

DESCRIPTION

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/  . Oth‐
25       erwise, it will use normal DELETE  to  delete  the  pods.  The  'drain'
26       evicts  or deletes all pods except mirror pods (which cannot be deleted
27       through the API server).  If there are daemon set-managed  pods,  drain
28       will  not  proceed  without --ignore-daemonsets, and regardless it will
29       not delete any daemon set-managed pods, because those pods would be im‐
30       mediately  replaced  by  the  daemon  set controller, which ignores un‐
31       schedulable markings.  If there are any pods that  are  neither  mirror
32       pods  nor managed by a replication controller, replica set, daemon set,
33       stateful set, or job, then drain will not delete any  pods  unless  you
34       use --force.  --force will also allow deletion to proceed if the manag‐
35       ing resource of one or more pods is missing.
36
37
38       'drain' waits for graceful termination. You should not operate  on  the
39       machine until the command completes.
40
41
42       When  you  are ready to put the node back into service, use kubectl un‐
43       cordon, which will make the node schedulable again.
44
45
46       https://kubernetes.io/images/docs/kubectl_drain.svg
47
48
49

OPTIONS

51       --chunk-size=500      Return large lists in chunks rather than  all  at
52       once.  Pass  0  to disable. This flag is beta and may change in the fu‐
53       ture.
54
55
56       --delete-emptydir-data=false      Continue even if there are pods using
57       emptyDir (local data that will be deleted when the node is drained).
58
59
60       --delete-local-data=false       Continue  even  if there are pods using
61       emptyDir (local data that will be deleted when the node is drained).
62
63
64       --disable-eviction=false      Force drain to use delete, even if  evic‐
65       tion  is supported. This will bypass checking PodDisruptionBudgets, use
66       with caution.
67
68
69       --dry-run="none"      Must be "none", "server", or "client". If  client
70       strategy, only print the object that would be sent, without sending it.
71       If server strategy, submit server-side request without  persisting  the
72       resource.
73
74
75       --force=false       Continue even if there are pods that do not declare
76       a controller.
77
78
79       --grace-period=-1      Period of time in seconds given to each  pod  to
80       terminate  gracefully.  If negative, the default value specified in the
81       pod will be used.
82
83
84       --ignore-daemonsets=false      Ignore DaemonSet-managed pods.
85
86
87       --pod-selector=""      Label selector to filter pods on the node
88
89
90       -l, --selector=""      Selector (label query) to  filter  on,  supports
91       '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). Matching objects
92       must satisfy all of the specified label constraints.
93
94
95       --skip-wait-for-delete-timeout=0      If  pod  DeletionTimestamp  older
96       than N seconds, skip waiting for the pod.  Seconds must be greater than
97       0 to skip.
98
99
100       --timeout=0s      The length of time to wait  before  giving  up,  zero
101       means infinite
102
103
104

OPTIONS INHERITED FROM PARENT COMMANDS

106       --as=""      Username to impersonate for the operation. User could be a
107       regular user or a service account in a namespace.
108
109
110       --as-group=[]      Group to impersonate for the  operation,  this  flag
111       can be repeated to specify multiple groups.
112
113
114       --as-uid=""      UID to impersonate for the operation.
115
116
117       --azure-container-registry-config=""       Path  to the file containing
118       Azure container registry configuration information.
119
120
121       --cache-dir="/builddir/.kube/cache"      Default cache directory
122
123
124       --certificate-authority=""      Path to a cert file for the certificate
125       authority
126
127
128       --client-certificate=""      Path to a client certificate file for TLS
129
130
131       --client-key=""      Path to a client key file for TLS
132
133
134       --cluster=""      The name of the kubeconfig cluster to use
135
136
137       --context=""      The name of the kubeconfig context to use
138
139
140       --insecure-skip-tls-verify=false      If true, the server's certificate
141       will not be checked for validity. This will make your HTTPS connections
142       insecure
143
144
145       --kubeconfig=""       Path  to  the  kubeconfig file to use for CLI re‐
146       quests.
147
148
149       --match-server-version=false       Require  server  version  to   match
150       client version
151
152
153       -n,  --namespace=""       If  present, the namespace scope for this CLI
154       request
155
156
157       --password=""      Password for basic authentication to the API server
158
159
160       --profile="none"        Name   of   profile   to   capture.   One    of
161       (none|cpu|heap|goroutine|threadcreate|block|mutex)
162
163
164       --profile-output="profile.pprof"       Name  of  the  file to write the
165       profile to
166
167
168       --request-timeout="0"      The length of time to wait before giving  up
169       on  a  single  server  request. Non-zero values should contain a corre‐
170       sponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't time‐
171       out requests.
172
173
174       -s, --server=""      The address and port of the Kubernetes API server
175
176
177       --tls-server-name=""       Server  name  to  use for server certificate
178       validation. If it is not provided, the hostname  used  to  contact  the
179       server is used
180
181
182       --token=""      Bearer token for authentication to the API server
183
184
185       --user=""      The name of the kubeconfig user to use
186
187
188       --username=""      Username for basic authentication to the API server
189
190
191       --version=false      Print version information and quit
192
193
194       --warnings-as-errors=false      Treat warnings received from the server
195       as errors and exit with a non-zero exit code
196
197
198

EXAMPLE

200                # Drain node "foo", even if there are pods not managed by a replication controller, replica set, job, daemon set or stateful set on it
201                kubectl drain foo --force
202
203                # 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
204                kubectl drain foo --grace-period=900
205
206
207
208

SEE ALSO

210       kubectl(1),
211
212
213

HISTORY

215       January 2015, Originally compiled by Eric Paris (eparis at  redhat  dot
216       com)  based  on the kubernetes source material, but hopefully they have
217       been automatically generated since!
218
219
220
221Manuals                              User            KUBERNETES(1)(kubernetes)
Impressum