Skip to content

Commit

Permalink
Initial node drain implementation for kubernetes#3885.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mml committed Jan 7, 2016
1 parent 547bf75 commit c6e9ad0
Show file tree
Hide file tree
Showing 17 changed files with 1,621 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .generated_docs
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,15 @@ docs/man/man1/kubectl-config-use-context.1
docs/man/man1/kubectl-config-view.1
docs/man/man1/kubectl-config.1
docs/man/man1/kubectl-convert.1
docs/man/man1/kubectl-cordon.1
docs/man/man1/kubectl-create-namespace.1
docs/man/man1/kubectl-create-secret-docker-registry.1
docs/man/man1/kubectl-create-secret-generic.1
docs/man/man1/kubectl-create-secret.1
docs/man/man1/kubectl-create.1
docs/man/man1/kubectl-delete.1
docs/man/man1/kubectl-describe.1
docs/man/man1/kubectl-drain.1
docs/man/man1/kubectl-edit.1
docs/man/man1/kubectl-exec.1
docs/man/man1/kubectl-explain.1
Expand All @@ -43,6 +45,7 @@ docs/man/man1/kubectl-rolling-update.1
docs/man/man1/kubectl-run.1
docs/man/man1/kubectl-scale.1
docs/man/man1/kubectl-stop.1
docs/man/man1/kubectl-uncordon.1
docs/man/man1/kubectl-version.1
docs/man/man1/kubectl.1
docs/user-guide/kubectl/kubectl.md
Expand All @@ -61,13 +64,15 @@ docs/user-guide/kubectl/kubectl_config_unset.md
docs/user-guide/kubectl/kubectl_config_use-context.md
docs/user-guide/kubectl/kubectl_config_view.md
docs/user-guide/kubectl/kubectl_convert.md
docs/user-guide/kubectl/kubectl_cordon.md
docs/user-guide/kubectl/kubectl_create.md
docs/user-guide/kubectl/kubectl_create_namespace.md
docs/user-guide/kubectl/kubectl_create_secret.md
docs/user-guide/kubectl/kubectl_create_secret_docker-registry.md
docs/user-guide/kubectl/kubectl_create_secret_generic.md
docs/user-guide/kubectl/kubectl_delete.md
docs/user-guide/kubectl/kubectl_describe.md
docs/user-guide/kubectl/kubectl_drain.md
docs/user-guide/kubectl/kubectl_edit.md
docs/user-guide/kubectl/kubectl_exec.md
docs/user-guide/kubectl/kubectl_explain.md
Expand All @@ -83,4 +88,5 @@ docs/user-guide/kubectl/kubectl_replace.md
docs/user-guide/kubectl/kubectl_rolling-update.md
docs/user-guide/kubectl/kubectl_run.md
docs/user-guide/kubectl/kubectl_scale.md
docs/user-guide/kubectl/kubectl_uncordon.md
docs/user-guide/kubectl/kubectl_version.md
1 change: 1 addition & 0 deletions build/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ function kube::build::source_targets() {
test
third_party
contrib/completions/bash/kubectl
contrib/mesos
.generated_docs
)
if [ -n "${KUBERNETES_CONTRIB:-}" ]; then
Expand Down
122 changes: 122 additions & 0 deletions contrib/completions/bash/kubectl
Original file line number Diff line number Diff line change
Expand Up @@ -1140,6 +1140,125 @@ _kubectl_scale()
must_have_one_noun=()
}

_kubectl_cordon()
{
last_command="kubectl_cordon"
commands=()

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--certificate-authority=")
flags+=("--client-certificate=")
flags+=("--client-key=")
flags+=("--cluster=")
flags+=("--context=")
flags+=("--insecure-skip-tls-verify")
flags+=("--kubeconfig=")
flags+=("--log-backtrace-at=")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--match-server-version")
flags+=("--namespace=")
flags+=("--password=")
flags+=("--server=")
two_word_flags+=("-s")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--username=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_kubectl_drain()
{
last_command="kubectl_drain"
commands=()

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--force")
flags+=("--grace-period=")
flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--certificate-authority=")
flags+=("--client-certificate=")
flags+=("--client-key=")
flags+=("--cluster=")
flags+=("--context=")
flags+=("--insecure-skip-tls-verify")
flags+=("--kubeconfig=")
flags+=("--log-backtrace-at=")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--match-server-version")
flags+=("--namespace=")
flags+=("--password=")
flags+=("--server=")
two_word_flags+=("-s")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--username=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_kubectl_uncordon()
{
last_command="kubectl_uncordon"
commands=()

flags=()
two_word_flags=()
flags_with_completion=()
flags_completion=()

flags+=("--alsologtostderr")
flags+=("--api-version=")
flags+=("--certificate-authority=")
flags+=("--client-certificate=")
flags+=("--client-key=")
flags+=("--cluster=")
flags+=("--context=")
flags+=("--insecure-skip-tls-verify")
flags+=("--kubeconfig=")
flags+=("--log-backtrace-at=")
flags+=("--log-dir=")
flags+=("--log-flush-frequency=")
flags+=("--logtostderr")
flags+=("--match-server-version")
flags+=("--namespace=")
flags+=("--password=")
flags+=("--server=")
two_word_flags+=("-s")
flags+=("--stderrthreshold=")
flags+=("--token=")
flags+=("--user=")
flags+=("--username=")
flags+=("--v=")
flags+=("--vmodule=")

must_have_one_flag=()
must_have_one_noun=()
}

_kubectl_attach()
{
last_command="kubectl_attach"
Expand Down Expand Up @@ -2241,6 +2360,9 @@ _kubectl()
commands+=("logs")
commands+=("rolling-update")
commands+=("scale")
commands+=("cordon")
commands+=("drain")
commands+=("uncordon")
commands+=("attach")
commands+=("exec")
commands+=("port-forward")
Expand Down
133 changes: 133 additions & 0 deletions docs/man/man1/kubectl-cordon.1
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
.TH "KUBERNETES" "1" " kubernetes User Manuals" "Eric Paris" "Jan 2015" ""


.SH NAME
.PP
kubectl cordon \- Mark node as unschedulable


.SH SYNOPSIS
.PP
\fBkubectl cordon\fP [OPTIONS]


.SH DESCRIPTION
.PP
Mark node as unschedulable.


.SH OPTIONS INHERITED FROM PARENT COMMANDS
.PP
\fB\-\-alsologtostderr\fP=false
log to standard error as well as files

.PP
\fB\-\-api\-version\fP=""
The API version to use when talking to the server

.PP
\fB\-\-certificate\-authority\fP=""
Path to a cert. file for the certificate authority.

.PP
\fB\-\-client\-certificate\fP=""
Path to a client certificate file for TLS.

.PP
\fB\-\-client\-key\fP=""
Path to a client key file for TLS.

.PP
\fB\-\-cluster\fP=""
The name of the kubeconfig cluster to use

.PP
\fB\-\-context\fP=""
The name of the kubeconfig context to use

.PP
\fB\-\-insecure\-skip\-tls\-verify\fP=false
If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure.

.PP
\fB\-\-kubeconfig\fP=""
Path to the kubeconfig file to use for CLI requests.

.PP
\fB\-\-log\-backtrace\-at\fP=:0
when logging hits line file:N, emit a stack trace

.PP
\fB\-\-log\-dir\fP=""
If non\-empty, write log files in this directory

.PP
\fB\-\-log\-flush\-frequency\fP=5s
Maximum number of seconds between log flushes

.PP
\fB\-\-logtostderr\fP=true
log to standard error instead of files

.PP
\fB\-\-match\-server\-version\fP=false
Require server version to match client version

.PP
\fB\-\-namespace\fP=""
If present, the namespace scope for this CLI request.

.PP
\fB\-\-password\fP=""
Password for basic authentication to the API server.

.PP
\fB\-s\fP, \fB\-\-server\fP=""
The address and port of the Kubernetes API server

.PP
\fB\-\-stderrthreshold\fP=2
logs at or above this threshold go to stderr

.PP
\fB\-\-token\fP=""
Bearer token for authentication to the API server.

.PP
\fB\-\-user\fP=""
The name of the kubeconfig user to use

.PP
\fB\-\-username\fP=""
Username for basic authentication to the API server.

.PP
\fB\-\-v\fP=0
log level for V logs

.PP
\fB\-\-vmodule\fP=
comma\-separated list of pattern=N settings for file\-filtered logging


.SH EXAMPLE
.PP
.RS

.nf
# Mark node "foo" as unschedulable.
$ kubectl cordon foo


.fi
.RE


.SH SEE ALSO
.PP
\fBkubectl(1)\fP,


.SH HISTORY
.PP
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!
Loading

0 comments on commit c6e9ad0

Please sign in to comment.