Skip to content

Commit c6e9ad0

Browse files
committed
Initial node drain implementation for #3885.
It cordons (marks unschedulable) the given node, and then deletes every pod on it, optionally using a grace period. It will not delete pods managed by neither a ReplicationController nor a DaemonSet without the use of --force. Also add cordon/uncordon, which just toggle node schedulability.
1 parent 547bf75 commit c6e9ad0

File tree

17 files changed

+1621
-2
lines changed

17 files changed

+1621
-2
lines changed

.generated_docs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,15 @@ docs/man/man1/kubectl-config-use-context.1
2020
docs/man/man1/kubectl-config-view.1
2121
docs/man/man1/kubectl-config.1
2222
docs/man/man1/kubectl-convert.1
23+
docs/man/man1/kubectl-cordon.1
2324
docs/man/man1/kubectl-create-namespace.1
2425
docs/man/man1/kubectl-create-secret-docker-registry.1
2526
docs/man/man1/kubectl-create-secret-generic.1
2627
docs/man/man1/kubectl-create-secret.1
2728
docs/man/man1/kubectl-create.1
2829
docs/man/man1/kubectl-delete.1
2930
docs/man/man1/kubectl-describe.1
31+
docs/man/man1/kubectl-drain.1
3032
docs/man/man1/kubectl-edit.1
3133
docs/man/man1/kubectl-exec.1
3234
docs/man/man1/kubectl-explain.1
@@ -43,6 +45,7 @@ docs/man/man1/kubectl-rolling-update.1
4345
docs/man/man1/kubectl-run.1
4446
docs/man/man1/kubectl-scale.1
4547
docs/man/man1/kubectl-stop.1
48+
docs/man/man1/kubectl-uncordon.1
4649
docs/man/man1/kubectl-version.1
4750
docs/man/man1/kubectl.1
4851
docs/user-guide/kubectl/kubectl.md
@@ -61,13 +64,15 @@ docs/user-guide/kubectl/kubectl_config_unset.md
6164
docs/user-guide/kubectl/kubectl_config_use-context.md
6265
docs/user-guide/kubectl/kubectl_config_view.md
6366
docs/user-guide/kubectl/kubectl_convert.md
67+
docs/user-guide/kubectl/kubectl_cordon.md
6468
docs/user-guide/kubectl/kubectl_create.md
6569
docs/user-guide/kubectl/kubectl_create_namespace.md
6670
docs/user-guide/kubectl/kubectl_create_secret.md
6771
docs/user-guide/kubectl/kubectl_create_secret_docker-registry.md
6872
docs/user-guide/kubectl/kubectl_create_secret_generic.md
6973
docs/user-guide/kubectl/kubectl_delete.md
7074
docs/user-guide/kubectl/kubectl_describe.md
75+
docs/user-guide/kubectl/kubectl_drain.md
7176
docs/user-guide/kubectl/kubectl_edit.md
7277
docs/user-guide/kubectl/kubectl_exec.md
7378
docs/user-guide/kubectl/kubectl_explain.md
@@ -83,4 +88,5 @@ docs/user-guide/kubectl/kubectl_replace.md
8388
docs/user-guide/kubectl/kubectl_rolling-update.md
8489
docs/user-guide/kubectl/kubectl_run.md
8590
docs/user-guide/kubectl/kubectl_scale.md
91+
docs/user-guide/kubectl/kubectl_uncordon.md
8692
docs/user-guide/kubectl/kubectl_version.md

build/common.sh

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ function kube::build::source_targets() {
448448
test
449449
third_party
450450
contrib/completions/bash/kubectl
451+
contrib/mesos
451452
.generated_docs
452453
)
453454
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then

contrib/completions/bash/kubectl

Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,125 @@ _kubectl_scale()
11401140
must_have_one_noun=()
11411141
}
11421142

1143+
_kubectl_cordon()
1144+
{
1145+
last_command="kubectl_cordon"
1146+
commands=()
1147+
1148+
flags=()
1149+
two_word_flags=()
1150+
flags_with_completion=()
1151+
flags_completion=()
1152+
1153+
flags+=("--alsologtostderr")
1154+
flags+=("--api-version=")
1155+
flags+=("--certificate-authority=")
1156+
flags+=("--client-certificate=")
1157+
flags+=("--client-key=")
1158+
flags+=("--cluster=")
1159+
flags+=("--context=")
1160+
flags+=("--insecure-skip-tls-verify")
1161+
flags+=("--kubeconfig=")
1162+
flags+=("--log-backtrace-at=")
1163+
flags+=("--log-dir=")
1164+
flags+=("--log-flush-frequency=")
1165+
flags+=("--logtostderr")
1166+
flags+=("--match-server-version")
1167+
flags+=("--namespace=")
1168+
flags+=("--password=")
1169+
flags+=("--server=")
1170+
two_word_flags+=("-s")
1171+
flags+=("--stderrthreshold=")
1172+
flags+=("--token=")
1173+
flags+=("--user=")
1174+
flags+=("--username=")
1175+
flags+=("--v=")
1176+
flags+=("--vmodule=")
1177+
1178+
must_have_one_flag=()
1179+
must_have_one_noun=()
1180+
}
1181+
1182+
_kubectl_drain()
1183+
{
1184+
last_command="kubectl_drain"
1185+
commands=()
1186+
1187+
flags=()
1188+
two_word_flags=()
1189+
flags_with_completion=()
1190+
flags_completion=()
1191+
1192+
flags+=("--force")
1193+
flags+=("--grace-period=")
1194+
flags+=("--alsologtostderr")
1195+
flags+=("--api-version=")
1196+
flags+=("--certificate-authority=")
1197+
flags+=("--client-certificate=")
1198+
flags+=("--client-key=")
1199+
flags+=("--cluster=")
1200+
flags+=("--context=")
1201+
flags+=("--insecure-skip-tls-verify")
1202+
flags+=("--kubeconfig=")
1203+
flags+=("--log-backtrace-at=")
1204+
flags+=("--log-dir=")
1205+
flags+=("--log-flush-frequency=")
1206+
flags+=("--logtostderr")
1207+
flags+=("--match-server-version")
1208+
flags+=("--namespace=")
1209+
flags+=("--password=")
1210+
flags+=("--server=")
1211+
two_word_flags+=("-s")
1212+
flags+=("--stderrthreshold=")
1213+
flags+=("--token=")
1214+
flags+=("--user=")
1215+
flags+=("--username=")
1216+
flags+=("--v=")
1217+
flags+=("--vmodule=")
1218+
1219+
must_have_one_flag=()
1220+
must_have_one_noun=()
1221+
}
1222+
1223+
_kubectl_uncordon()
1224+
{
1225+
last_command="kubectl_uncordon"
1226+
commands=()
1227+
1228+
flags=()
1229+
two_word_flags=()
1230+
flags_with_completion=()
1231+
flags_completion=()
1232+
1233+
flags+=("--alsologtostderr")
1234+
flags+=("--api-version=")
1235+
flags+=("--certificate-authority=")
1236+
flags+=("--client-certificate=")
1237+
flags+=("--client-key=")
1238+
flags+=("--cluster=")
1239+
flags+=("--context=")
1240+
flags+=("--insecure-skip-tls-verify")
1241+
flags+=("--kubeconfig=")
1242+
flags+=("--log-backtrace-at=")
1243+
flags+=("--log-dir=")
1244+
flags+=("--log-flush-frequency=")
1245+
flags+=("--logtostderr")
1246+
flags+=("--match-server-version")
1247+
flags+=("--namespace=")
1248+
flags+=("--password=")
1249+
flags+=("--server=")
1250+
two_word_flags+=("-s")
1251+
flags+=("--stderrthreshold=")
1252+
flags+=("--token=")
1253+
flags+=("--user=")
1254+
flags+=("--username=")
1255+
flags+=("--v=")
1256+
flags+=("--vmodule=")
1257+
1258+
must_have_one_flag=()
1259+
must_have_one_noun=()
1260+
}
1261+
11431262
_kubectl_attach()
11441263
{
11451264
last_command="kubectl_attach"
@@ -2241,6 +2360,9 @@ _kubectl()
22412360
commands+=("logs")
22422361
commands+=("rolling-update")
22432362
commands+=("scale")
2363+
commands+=("cordon")
2364+
commands+=("drain")
2365+
commands+=("uncordon")
22442366
commands+=("attach")
22452367
commands+=("exec")
22462368
commands+=("port-forward")

docs/man/man1/kubectl-cordon.1

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
.TH "KUBERNETES" "1" " kubernetes User Manuals" "Eric Paris" "Jan 2015" ""
2+
3+
4+
.SH NAME
5+
.PP
6+
kubectl cordon \- Mark node as unschedulable
7+
8+
9+
.SH SYNOPSIS
10+
.PP
11+
\fBkubectl cordon\fP [OPTIONS]
12+
13+
14+
.SH DESCRIPTION
15+
.PP
16+
Mark node as unschedulable.
17+
18+
19+
.SH OPTIONS INHERITED FROM PARENT COMMANDS
20+
.PP
21+
\fB\-\-alsologtostderr\fP=false
22+
log to standard error as well as files
23+
24+
.PP
25+
\fB\-\-api\-version\fP=""
26+
The API version to use when talking to the server
27+
28+
.PP
29+
\fB\-\-certificate\-authority\fP=""
30+
Path to a cert. file for the certificate authority.
31+
32+
.PP
33+
\fB\-\-client\-certificate\fP=""
34+
Path to a client certificate file for TLS.
35+
36+
.PP
37+
\fB\-\-client\-key\fP=""
38+
Path to a client key file for TLS.
39+
40+
.PP
41+
\fB\-\-cluster\fP=""
42+
The name of the kubeconfig cluster to use
43+
44+
.PP
45+
\fB\-\-context\fP=""
46+
The name of the kubeconfig context to use
47+
48+
.PP
49+
\fB\-\-insecure\-skip\-tls\-verify\fP=false
50+
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.
51+
52+
.PP
53+
\fB\-\-kubeconfig\fP=""
54+
Path to the kubeconfig file to use for CLI requests.
55+
56+
.PP
57+
\fB\-\-log\-backtrace\-at\fP=:0
58+
when logging hits line file:N, emit a stack trace
59+
60+
.PP
61+
\fB\-\-log\-dir\fP=""
62+
If non\-empty, write log files in this directory
63+
64+
.PP
65+
\fB\-\-log\-flush\-frequency\fP=5s
66+
Maximum number of seconds between log flushes
67+
68+
.PP
69+
\fB\-\-logtostderr\fP=true
70+
log to standard error instead of files
71+
72+
.PP
73+
\fB\-\-match\-server\-version\fP=false
74+
Require server version to match client version
75+
76+
.PP
77+
\fB\-\-namespace\fP=""
78+
If present, the namespace scope for this CLI request.
79+
80+
.PP
81+
\fB\-\-password\fP=""
82+
Password for basic authentication to the API server.
83+
84+
.PP
85+
\fB\-s\fP, \fB\-\-server\fP=""
86+
The address and port of the Kubernetes API server
87+
88+
.PP
89+
\fB\-\-stderrthreshold\fP=2
90+
logs at or above this threshold go to stderr
91+
92+
.PP
93+
\fB\-\-token\fP=""
94+
Bearer token for authentication to the API server.
95+
96+
.PP
97+
\fB\-\-user\fP=""
98+
The name of the kubeconfig user to use
99+
100+
.PP
101+
\fB\-\-username\fP=""
102+
Username for basic authentication to the API server.
103+
104+
.PP
105+
\fB\-\-v\fP=0
106+
log level for V logs
107+
108+
.PP
109+
\fB\-\-vmodule\fP=
110+
comma\-separated list of pattern=N settings for file\-filtered logging
111+
112+
113+
.SH EXAMPLE
114+
.PP
115+
.RS
116+
117+
.nf
118+
# Mark node "foo" as unschedulable.
119+
$ kubectl cordon foo
120+
121+
122+
.fi
123+
.RE
124+
125+
126+
.SH SEE ALSO
127+
.PP
128+
\fBkubectl(1)\fP,
129+
130+
131+
.SH HISTORY
132+
.PP
133+
January 2015, Originally compiled by Eric Paris (eparis at redhat dot com) based on the kubernetes source material, but hopefully they have been automatically generated since!

0 commit comments

Comments
 (0)