diff --git a/static/docs/reference/generated/kubectl/kubectl-commands.html b/static/docs/reference/generated/kubectl/kubectl-commands.html index 97b6efc8e80cc..c060bb0cef3b6 100644 --- a/static/docs/reference/generated/kubectl/kubectl-commands.html +++ b/static/docs/reference/generated/kubectl/kubectl-commands.html @@ -11,7 +11,7 @@ - +

GETTING STARTED

@@ -25,71 +25,26 @@ WORKING WITH APPS section to inspect them.


-

run

-
-

Start a single instance of nginx.

-
-
kubectl run nginx --image=nginx
-
-
-

Start a single instance of hazelcast and let the container expose port 5701 .

-
-
kubectl run hazelcast --image=hazelcast --port=5701
-
-
-

Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container.

-
-
kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
-
-
-

Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.

-
-
kubectl run hazelcast --image=nginx --labels="app=hazelcast,env=prod"
-
-
-

Start a replicated instance of nginx.

-
-
kubectl run nginx --image=nginx --replicas=5
-
-
-

Dry run. Print the corresponding API objects without creating them.

-
-
kubectl run nginx --image=nginx --dry-run
-
-
-

Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON.

-
-
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
-
-
-

Start a pod of busybox and keep it in the foreground, don't restart it if it exits.

-
-
kubectl run -i -t busybox --image=busybox --restart=Never
-
-
-

Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.

-
-
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
-
+

create

-

Start the nginx container using a different command and custom arguments.

+

Create a pod using the data in pod.json.

-
kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
+
kubectl create -f ./pod.json
 
-

Start the perl container to compute π to 2000 places and print it out.

+

Create a pod based on the JSON passed into stdin.

-
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
cat pod.json | kubectl create -f -
 
-

Start the cron job to compute π to 2000 places and print it out every 5 minutes.

+

Edit the data in docker-registry.yaml in JSON then create the resource using the edited data.

-
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
kubectl create -f docker-registry.yaml --edit -o json
 
-

Create and run a particular image, possibly replicated.

-

Creates a deployment or job to manage the created container(s).

+

Create a resource from a file or from stdin.

+

JSON and YAML formats are accepted.

Usage

-

$ run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]

+

$ create -f FILENAME

Flags

@@ -108,154 +63,166 @@

Flags

- - - - - - - - - - - - - - - - - - - + - - - - - - - + - - - - + + + + - - + + - + - + - + - + - - + + - - - - + + + + - + - + - - + + - + - + - - - - - - - + - - + - + + - - + - + + + +
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
attachfalseIf true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned.
commandfalseIf true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default.
dry-run false If true, only print the object that would be sent, without sending it.
env[]Environment variables to set in the container
exposeedit falseIf true, a public, external service is created for the container(s) which are run
generatorThe name of the API generator to use, see http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators for a list. Edit the API resource before creating
hostport-1The host port mapping for the container port. To demonstrate a single-machine container. filenamef[]Filename, directory, or URL to files to use to create the resource
imageoutputo The image for the container to run. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
image-pull-policyraw The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server Raw URI to POST to the server. Uses the transport specified by the kubeconfig file.
include-extended-apisrecord trueIf true, include definitions of new APIs via calls to the API server. [default true] falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
labelslComma separated labels to apply to the pod(s). Will override previous values. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
leave-stdin-opensave-config falseIf the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes. If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
limitsselectorl The resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges. Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
no-headerstemplate falseWhen using the default or custom-column output format, don't print headers (default print headers).
outputo Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
output-versionvalidate DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). trueIf true, use a schema to validate the input before sending it
overrideswindows-line-endings An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. falseOnly relevant if --edit=true. Defaults to the line ending native to your platform.
+
+

clusterrole

+
+

Create a ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" on pods

+
+
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods
+
+
+

Create a ClusterRole named "pod-reader" with ResourceName specified

+
+
kubectl create clusterrole pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod
+
+
+

Create a ClusterRole named "foo" with API Group specified

+
+
kubectl create clusterrole foo --verb=get,list,watch --resource=rs.extensions
+
+
+

Create a ClusterRole named "foo" with SubResource specified

+
+
kubectl create clusterrole foo --verb=get,list,watch --resource=pods,pods/status
+
+
+

Create a ClusterRole name "foo" with NonResourceURL specified

+
+
kubectl create clusterrole "foo" --verb=get --non-resource-url=/logs/*
+
+
+

Create a ClusterRole name "monitoring" with AggregationRule specified

+
+
kubectl create clusterrole monitoring --aggregation-rule="rbac.example.com/aggregate-to-monitoring=true"
+
+

Create a ClusterRole.

+

Usage

+

$ clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run]

+

Flags

+ + - - - - + + + + + + - + - + - + - - + + - + - + - - - - + + + + - - + + - + - + - - + + - + - - + + @@ -264,52 +231,93 @@

Flags

- + - + - + - - + + - - + - + + - - - - - + +
pod-running-timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running NameShorthandDefaultUsage
portaggregation-rule The port that this container exposes. If --expose is true, this is also the port used by the service that is created. An aggregation label selector for combining ClusterRoles.
quietallow-missing-template-keys falseIf true, suppress prompt messages. trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
recorddry-run falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. If true, only print the object that would be sent, without sending it.
replicasr1Number of replicas to create for this container. Default is 1. non-resource-url[]A partial url that user should have access to.
requestsoutputo The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
restartresource AlwaysThe restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For the latter two --replicas must be 1. Default 'Always', for CronJobs Never. []Resource that the rule applies to
rmresource-name falseIf true, delete resources created in this command for attached containers. []Resource in the white list that the rule applies to, repeat this flag for multiple items
save-config If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
scheduletemplate A schedule in the Cron format the job should be run with. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
service-generatorvalidate service/v2The name of the generator to use for creating a service. Only used if --expose is true trueIf true, use a schema to validate the input before sending it
service-overridesverb An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true. []Verb that applies to the resources contained in the rule
serviceaccountService account to set in the pod spec
+
+

clusterrolebinding

+
+

Create a ClusterRoleBinding for user1, user2, and group1 using the cluster-admin ClusterRole

+
+
kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1
+
+

Create a ClusterRoleBinding for a particular ClusterRole.

+

Usage

+

$ clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

+

Flags

+ + + + + + + + + - - + + - + - + + + + + + + - + - + + + + + + - + + - - + + + + + + + + - + + + + + + + @@ -318,79 +326,46 @@

Flags

- - - - + + + +
NameShorthandDefaultUsage
show-allaallow-missing-template-keys trueWhen printing, show all resources (default show all pods including terminated one.) If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
show-labelsclusterroleClusterRole this ClusterRoleBinding should reference
dry-run falseWhen printing, show all labels as the last column (default hide labels column) If true, only print the object that would be sent, without sending it.
sort-bygenerator clusterrolebinding.rbac.authorization.k8s.io/v1alpha1The name of the API generator to use.
group If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. []Groups to bind to the role
stdinioutputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
save-config falseKeep stdin open on the container(s) in the pod, even if nothing is attached. If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
serviceaccount[]Service accounts to bind to the role, in the format :
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
ttytfalseAllocated a TTY for each container in the pod. validatetrueIf true, use a schema to validate the input before sending it

-

run-container

-
-

Start a single instance of nginx.

-
-
kubectl run nginx --image=nginx
-
-
-

Start a single instance of hazelcast and let the container expose port 5701 .

-
-
kubectl run hazelcast --image=hazelcast --port=5701
-
-
-

Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container.

-
-
kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
-
-
-

Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.

-
-
kubectl run hazelcast --image=nginx --labels="app=hazelcast,env=prod"
-
-
-

Start a replicated instance of nginx.

-
-
kubectl run nginx --image=nginx --replicas=5
-
-
-

Dry run. Print the corresponding API objects without creating them.

-
-
kubectl run nginx --image=nginx --dry-run
-
-
-

Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON.

-
-
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
-
+

configmap

-

Start a pod of busybox and keep it in the foreground, don't restart it if it exits.

+

Create a new configmap named my-config based on folder bar

-
kubectl run -i -t busybox --image=busybox --restart=Never
+
kubectl create configmap my-config --from-file=path/to/bar
 
-

Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.

+

Create a new configmap named my-config with specified keys instead of file basenames on disk

-
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
+
kubectl create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt
 
-

Start the nginx container using a different command and custom arguments.

+

Create a new configmap named my-config with key1=config1 and key2=config2

-
kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
+
kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2
 
-

Start the perl container to compute π to 2000 places and print it out.

+

Create a new configmap named my-config from the key=value pairs in the file

-
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
kubectl create configmap my-config --from-file=path/to/bar
 
-

Start the cron job to compute π to 2000 places and print it out every 5 minutes.

+

Create a new configmap named my-config from an env file

-
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
kubectl create configmap my-config --from-env-file=path/to/bar.env
 
-

Create and run a particular image, possibly replicated.

-

Creates a deployment or job to manage the created container(s).

+

Create a configmap based on a file, directory, or specified literal value.

+

A single configmap may package one or more key/value pairs.

+

When creating a configmap based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key, you may specify an alternate key.

+

When creating a configmap based on a directory, each file whose basename is a valid key in the directory will be packaged into the configmap. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).

Usage

-

$ run-container

+

$ configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]

Flags

@@ -409,88 +384,111 @@

Flags

- + - + - + - + - + - - + + - + - + - + - - + + - - + + - + + - - + - - + - + + - + - + - + - + + + +
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
attachappend-hash falseIf true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned. Append a hash of the configmap to its name.
commanddry-run falseIf true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default. If true, only print the object that would be sent, without sending it.
dry-runfrom-env-file falseIf true, only print the object that would be sent, without sending it. Specify the path to a file to read lines of key=val pairs to create a configmap (i.e. a Docker .env file).
envfrom-file []Environment variables to set in the container Key file can be specified using its file path, in which case file basename will be used as configmap key, or optionally with a key and file path, in which case the given key will be used. Specifying a directory will iterate each named file in the directory whose basename is a valid configmap key.
exposefrom-literal falseIf true, a public, external service is created for the container(s) which are run []Specify a key and literal value to insert in configmap (i.e. mykey=somevalue)
generator The name of the API generator to use, see http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators for a list. configmap/v1The name of the API generator to use.
hostportoutputo -1The host port mapping for the container port. To demonstrate a single-machine container. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
imagesave-config The image for the container to run. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
image-pull-policytemplate The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
include-extended-apisvalidate trueIf true, include definitions of new APIs via calls to the API server. [default true] If true, use a schema to validate the input before sending it
+
+

deployment

+
+

Create a new deployment named my-dep that runs the busybox image.

+
+
kubectl create deployment my-dep --image=busybox
+
+

Create a deployment with the specified name.

+

Usage

+

$ deployment NAME --image=image [--dry-run]

+

Flags

+ + + + + + + + + - - + - + + - + - + - + - + - + - - + + @@ -499,64 +497,69 @@

Flags

- - + - + + - - + - - - - - - + - - + - - - - - - - + + + +
NameShorthandDefaultUsage
labelslallow-missing-template-keys Comma separated labels to apply to the pod(s). Will override previous values. trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
leave-stdin-opendry-run falseIf the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes. If true, only print the object that would be sent, without sending it.
limitsgenerator The resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges. The name of the API generator to use.
no-headersimage falseWhen using the default or custom-column output format, don't print headers (default print headers). []Image name to run.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionsave-config DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
overridestemplate An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
pod-running-timeout 1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
portvalidate The port that this container exposes. If --expose is true, this is also the port used by the service that is created.
quietfalseIf true, suppress prompt messages. trueIf true, use a schema to validate the input before sending it
+
+

job

+
+

Create a job from a CronJob named "a-cronjob"

+
+
kubectl create job test-job --from=cronjob/a-cronjob
+
+

Create a job with the specified name.

+

Usage

+

$ job NAME [--from=CRONJOB]

+

Flags

+ + - - - - + + + + + + - - - - + + + + - - + - + + - + - - + + - + + - - + @@ -565,52 +568,69 @@

Flags

- + - + - + - - + + + +
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. NameShorthandDefaultUsage
replicasr1Number of replicas to create for this container. Default is 1. allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
requestsdry-run The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. falseIf true, only print the object that would be sent, without sending it.
restartfrom AlwaysThe restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For the latter two --replicas must be 1. Default 'Always', for CronJobs Never. The name of the resource to create a Job from (only cronjob is supported).
rmoutputo falseIf true, delete resources created in this command for attached containers. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
save-config If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
scheduletemplate A schedule in the Cron format the job should be run with. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
service-generatorvalidate service/v2The name of the generator to use for creating a service. Only used if --expose is true trueIf true, use a schema to validate the input before sending it
+
+

namespace

+
+

Create a new namespace named my-namespace

+
+
kubectl create namespace my-namespace
+
+

Create a namespace with the specified name.

+

Usage

+

$ namespace NAME [--dry-run]

+

Flags

+ + - - - - + + + + + + - - + - - - - - - + - + - + - + + + + + + + - + - - + + - + @@ -619,56 +639,28 @@

Flags

- - - - + + + +
service-overridesAn inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true. NameShorthandDefaultUsage
serviceaccountallow-missing-template-keys Service account to set in the pod spec
show-alla trueWhen printing, show all resources (default show all pods including terminated one.) If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
show-labelsdry-run falseWhen printing, show all labels as the last column (default hide labels column) If true, only print the object that would be sent, without sending it.
sort-bygenerator namespace/v1The name of the API generator to use.
outputo If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
stdinisave-config falseKeep stdin open on the container(s) in the pod, even if nothing is attached. If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
ttytfalseAllocated a TTY for each container in the pod. validatetrueIf true, use a schema to validate the input before sending it

-

expose

-
-

Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.

-
-
kubectl expose rc nginx --port=80 --target-port=8000
-
-
-

Create a service for a replication controller identified by type and name specified in "nginx-controller.yaml", which serves on port 80 and connects to the containers on port 8000.

-
-
kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000
-
-
-

Create a service for a pod valid-pod, which serves on port 444 with the name "frontend"

-
-
kubectl expose pod valid-pod --port=444 --name=frontend
-
-
-

Create a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"

-
-
kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
-
-
-

Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.

-
-
kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
-
+

poddisruptionbudget

-

Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on port 8000.

+

Create a pod disruption budget named my-pdb that will select all pods with the app=rails label # and require at least one of them being available at any point in time.

-
kubectl expose rs nginx --port=80 --target-port=8000
+
kubectl create poddisruptionbudget my-pdb --selector=app=rails --min-available=1
 
-

Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.

+

Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label # and require at least half of the pods selected to be available at any point in time.

-
kubectl expose deployment nginx --port=80 --target-port=8000
+
kubectl create pdb my-pdb --selector=app=nginx --min-available=50%
 
-

Expose a resource as a new Kubernetes service.

-

Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A deployment or replica set will be exposed as a service only if its selector is convertible to a selector that service supports, i.e. when the selector contains only the matchLabels component. Note that if no port is specified via --port and the exposed resource has multiple ports, all will be re-used by the new service. Also if no labels are specified, the new service will re-use the labels from the resource it exposes.

-

Possible resources include (case insensitive):

-

pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)

+

Create a pod disruption budget with the specified name, selector, and desired minimum available pods

Usage

-

$ expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]

+

$ poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry-run]

Flags

@@ -687,64 +679,28 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - + - + - - + - - - - - - + @@ -753,42 +709,6 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -798,132 +718,37 @@

Flags

- + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + +
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
cluster-ipClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to 'None' to create a headless service.
container-portSynonym for --target-port
dry-run false If true, only print the object that would be sent, without sending it.
external-ipAdditional external IP address (not managed by Kubernetes) to accept for the service. If this IP is routed to a node, the service can be accessed by this IP in addition to its generated service IP.
filenamef[]Filename, directory, or URL to files identifying the resource to expose a service
generator service/v2The name of the API generator to use. There are 2 generators: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Default is 'service/v2'.
labelslLabels to apply to the service created by this call. poddisruptionbudget/v1beta1/v2The name of the API generator to use.
load-balancer-ipmax-unavailable IP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used (cloud-provider specific). The maximum number or percentage of unavailable pods this budget requires.
namemin-available The name for the newly created object.
no-headers falseWhen using the default or custom-column output format, don't print headers (default print headers). The minimum number or percentage of available pods this budget requires.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
overridesAn inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
portThe port that the service should serve on. Copied from the resource being exposed, if unspecified
protocolThe network protocol for the service to be created. Default is 'TCP'.
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-config false selector A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.) A label selector to use for this budget. Only equality-based selector requirements are supported.
session-affinitytemplate If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP' Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
target-portName or number for the port on the container that the service should direct traffic to. Optional.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
typevalidate Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'. trueIf true, use a schema to validate the input before sending it
-

APP MANAGEMENT

-

This section contains commands for creating, updating, deleting, and -viewing your workloads in a Kubernetes cluster.


-

annotate

-
-

Update pod 'foo' with the annotation 'description' and the value 'my frontend'. # If the same annotation is set multiple times, only the last value will be applied

-
-
kubectl annotate pods foo description='my frontend'
-
-
-

Update a pod identified by type and name in "pod.json"

-
-
kubectl annotate -f pod.json description='my frontend'
-
-
-

Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value.

-
-
kubectl annotate --overwrite pods foo description='my frontend running nginx'
-
-
-

Update all pods in the namespace

-
-
kubectl annotate pods --all description='my frontend running nginx'
-
+

priorityclass

-

Update pod 'foo' only if the resource is unchanged from version 1.

+

Create a priorityclass named high-priority

-
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
+
kubectl create priorityclass default-priority --value=1000 --description="high priority"
 
-

Update pod 'foo' by removing an annotation named 'description' if it exists. # Does not require the --overwrite flag.

+

Create a priorityclass named default-priority that considered as the global default priority

-
kubectl annotate pods foo description-
+
kubectl create priorityclass default-priority --value=1000 --global-default=true --description="default priority"
 
-

Update the annotations on one or more resources

-

All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary string values such as structured JSON. Tools and system extensions may use annotations to store their own data.

-

Attempting to set an annotation that already exists will fail unless --overwrite is set. If --resource-version is specified and does not match the current resource version on the server the command will fail.

-

Valid resource types include:

-
    -
  • all
  • -
  • certificatesigningrequests (aka 'csr')
  • -
  • clusterrolebindings
  • -
  • clusterroles
  • -
  • componentstatuses (aka 'cs')
  • -
  • configmaps (aka 'cm')
  • -
  • controllerrevisions
  • -
  • cronjobs
  • -
  • customresourcedefinition (aka 'crd')
  • -
  • daemonsets (aka 'ds')
  • -
  • deployments (aka 'deploy')
  • -
  • endpoints (aka 'ep')
  • -
  • events (aka 'ev')
  • -
  • horizontalpodautoscalers (aka 'hpa')
  • -
  • ingresses (aka 'ing')
  • -
  • jobs
  • -
  • limitranges (aka 'limits')
  • -
  • namespaces (aka 'ns')
  • -
  • networkpolicies (aka 'netpol')
  • -
  • nodes (aka 'no')
  • -
  • persistentvolumeclaims (aka 'pvc')
  • -
  • persistentvolumes (aka 'pv')
  • -
  • poddisruptionbudgets (aka 'pdb')
  • -
  • podpreset
  • -
  • pods (aka 'po')
  • -
  • podsecuritypolicies (aka 'psp')
  • -
  • podtemplates
  • -
  • replicasets (aka 'rs')
  • -
  • replicationcontrollers (aka 'rc')
  • -
  • resourcequotas (aka 'quota')
  • -
  • rolebindings
  • -
  • roles
  • -
  • secrets
  • -
  • serviceaccounts (aka 'sa')
  • -
  • services (aka 'svc')
  • -
  • statefulsets (aka 'sts')
  • -
  • storageclasses (aka 'sc')
  • -
+

Create a priorityclass with the specified name, value, globalDefault and description

Usage

-

$ annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

+

$ priorityclass NAME --value=VALUE --global-default=BOOL [--dry-run]

Flags

@@ -936,112 +761,134 @@

Flags

- - - - - - + + + + + + - - - - - - - + - - + + - + - + - + + - - + - + - + - - + - + + - - + - + + - + - - + + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types.
allow-missing-template-keys true If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
descriptiondescription is an arbitrary string that usually provides guidelines on when this priority class should be used.
dry-run false If true, only print the object that would be sent, without sending it.
filenamef[]Filename, directory, or URL to files identifying the resource to update the annotation
include-extended-apisgenerator trueIf true, include definitions of new APIs via calls to the API server. [default true] priorityclass/v1alpha1The name of the API generator to use.
include-uninitializedglobal-default falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. global-default specifies whether this PriorityClass should be considered as the default priority.
localoutputo falseIf true, annotation will NOT contact api-server but run locally. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
no-headerssave-config falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
outputotemplate Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
output-versionvalidate DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). trueIf true, use a schema to validate the input before sending it
overwritevalue falseIf true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations. 0the value of this priority class.
+
+

quota

+
+

Create a new resourcequota named my-quota

+
+
kubectl create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10
+
+
+

Create a new resourcequota named best-effort

+
+
kubectl create quota best-effort --hard=pods=100 --scopes=BestEffort
+
+

Create a resourcequota with the specified name, hard limits and optional scopes

+

Usage

+

$ quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=bool]

+

Flags

+ + + + + + + + + - + - - + + - - + + - + - - + - + + - - + - + + - - - - + + + + - + - + - + - + @@ -1049,24 +896,39 @@

Flags

+ + + + + +
NameShorthandDefaultUsage
recordallow-missing-template-keys falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
recursiveRdry-run falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. If true, only print the object that would be sent, without sending it.
resource-versiongenerator If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource. resourcequotas/v1The name of the API generator to use.
selectorlhard Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). A comma-delimited set of resource=quantity pairs that define a hard limit.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
show-labelssave-config falseWhen printing, show all labels as the last column (default hide labels column) If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
sort-byscopes If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. A comma-delimited set of quota scopes that must all match each object tracked by the quota.
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validatetrueIf true, use a schema to validate the input before sending it

-

autoscale

+

role

-

Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used:

+

Create a Role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods

-
kubectl autoscale deployment foo --min=2 --max=10
+
kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods
 
-

Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:

+

Create a Role named "pod-reader" with ResourceName specified

-
kubectl autoscale rc foo --max=5 --cpu-percent=80
+
kubectl create role pod-reader --verb=get --resource=pods --resource-name=readablepod --resource-name=anotherpod
 
-

Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.

-

Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference. An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.

+
+

Create a Role named "foo" with API Group specified

+
+
kubectl create role foo --verb=get,list,watch --resource=rs.extensions
+
+
+

Create a Role named "foo" with SubResource specified

+
+
kubectl create role foo --verb=get,list,watch --resource=pods,pods/status
+
+

Create a role with single rule.

Usage

-

$ autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU]

+

$ role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run]

Flags

@@ -1085,106 +947,129 @@

Flags

- - - - - - - - - - - - - + + - - + - + - - + + - + - - + + - + - - + + - + - + - + - - + + - - + - + + + + +
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
cpu-percent-1The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used.
dry-run false If true, only print the object that would be sent, without sending it.
filenamef[]Filename, directory, or URL to files identifying the resource to autoscale.
generatoroutputo horizontalpodautoscaler/v1The name of the API generator to use. Currently there is only 1 generator. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
include-extended-apisresource trueIf true, include definitions of new APIs via calls to the API server. [default true] []Resource that the rule applies to
maxresource-name -1The upper limit for the number of pods that can be set by the autoscaler. Required. []Resource in the white list that the rule applies to, repeat this flag for multiple items
minsave-config -1The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
nametemplate The name for the newly created object. If not specified, the name of the input resource will be used. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
no-headersvalidate falseWhen using the default or custom-column output format, don't print headers (default print headers). trueIf true, use a schema to validate the input before sending it
outputoverb Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. []Verb that applies to the resources contained in the rule
+
+

rolebinding

+
+

Create a RoleBinding for user1, user2, and group1 using the admin ClusterRole

+
+
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1
+
+

Create a RoleBinding for a particular Role or ClusterRole.

+

Usage

+

$ rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

+

Flags

+ + + + + + + + + - + + + + + + + - + - + - + - - - - + + + + - + - - + + - - - - + + + + - + - - + + - + + + + + + - + + @@ -1192,30 +1077,36 @@

Flags

+ + + + + +
NameShorthandDefaultUsage
output-versionallow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
clusterrole DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). ClusterRole this RoleBinding should reference
recorddry-run falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. If true, only print the object that would be sent, without sending it.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. generatorrolebinding.rbac.authorization.k8s.io/v1alpha1The name of the API generator to use.
save-configgroup falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. []Groups to bind to the role
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
show-labelsrole falseWhen printing, show all labels as the last column (default hide labels column) Role this RoleBinding should reference
sort-bysave-config falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
serviceaccount If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. []Service accounts to bind to the role, in the format :
template Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validatetrueIf true, use a schema to validate the input before sending it

-

convert

-
-

Convert 'pod.yaml' to latest version and print to stdout.

-
-
kubectl convert -f pod.yaml
-
-
-

Convert the live state of the resource specified by 'pod.yaml' to the latest version # and print to stdout in JSON format.

-
-
kubectl convert -f pod.yaml --local -o json
-
+

secret

+

Create a secret using specified subcommand.

+

Usage

+

$ secret

+
+

secret docker-registry

-

Convert all files under current directory to latest version and create them all.

+

If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using:

-
kubectl convert -f . | kubectl create -f -
+
kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
 
-

Convert config files between different API versions. Both YAML and JSON formats are accepted.

-

The command takes filename, directory, or URL as input, and convert it into format of version specified by --output-version flag. If target version is not specified or not supported, convert to latest version.

-

The default output will be printed to stdout in YAML format. One can use -o option to change to output destination.

+

Create a new secret for use with Docker registries.

+

Dockercfg secrets are used to authenticate against Docker registries.

+

When using the Docker command line to push images, you can authenticate to a given registry by running: + '$ docker login DOCKER_REGISTRY_SERVER --username=DOCKER_USER --password=DOCKER_PASSWORD --email=DOCKER_EMAIL'.

+

That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' commands to authenticate to the registry. The email address is optional.

+

When creating applications, you may have a Docker registry that requires authentication. In order for the + nodes to pull images on your behalf, they have to have the credentials. You can provide this information + by creating a dockercfg secret and attaching it to your service account.

Usage

-

$ convert -f FILENAME

+

$ docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]

Flags

@@ -1234,64 +1125,64 @@

Flags

- - - - - - - + - - + + - + - - + + - + - - + + - - + - + + - + - + - - + + - + - - - - + + + + - + - - + + - + + + + + + - + + @@ -1308,26 +1199,38 @@

Flags

If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
filenamef[]Filename, directory, or URL to files to need to get converted.
include-extended-apisappend-hash trueIf true, include definitions of new APIs via calls to the API server. [default true] falseAppend a hash of the secret to its name.
localdocker-email trueIf true, convert will NOT try to contact api-server but run locally. Email for Docker registry
no-headersdocker-password falseWhen using the default or custom-column output format, don't print headers (default print headers). Password for Docker registry authentication
outputodocker-server Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. https://index.docker.io/v1/Server location for Docker registry
output-versiondocker-username Output the formatted object with the given group version (for ex: 'extensions/v1beta1').) Username for Docker registry authentication
recursiveRdry-run falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. If true, only print the object that would be sent, without sending it.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) from-file[]Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key.
show-labelsgenerator falseWhen printing, show all labels as the last column (default hide labels column) secret-for-docker-registry/v1The name of the API generator to use.
sort-byoutputo Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
save-config If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
template

-

create

+

secret generic

-

Create a pod using the data in pod.json.

+

Create a new secret named my-secret with keys for each file in folder bar

-
kubectl create -f ./pod.json
+
kubectl create secret generic my-secret --from-file=path/to/bar
 
-

Create a pod based on the JSON passed into stdin.

+

Create a new secret named my-secret with specified keys instead of names on disk

-
cat pod.json | kubectl create -f -
+
kubectl create secret generic my-secret --from-file=ssh-privatekey=~/.ssh/id_rsa --from-file=ssh-publickey=~/.ssh/id_rsa.pub
+
+
+

Create a new secret named my-secret with key1=supersecret and key2=topsecret

+
+
kubectl create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret
 
-

Edit the data in docker-registry.yaml in JSON using the v1 API format then create the resource using the edited data.

+

Create a new secret named my-secret using a combination of a file and a literal

-
kubectl create -f docker-registry.yaml --edit --output-version=v1 -o json
+
kubectl create secret generic my-secret --from-file=ssh-privatekey=~/.ssh/id_rsa --from-literal=passphrase=topsecret
 
-

Create a resource from a file or from stdin.

-

JSON and YAML formats are accepted.

+
+

Create a new secret named my-secret from an env file

+
+
kubectl create secret generic my-secret --from-env-file=path/to/bar.env
+
+

Create a secret based on a file, directory, or specified literal value.

+

A single secret may package one or more key/value pairs.

+

When creating a secret based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key or you wish to chose your own, you may specify an alternate key.

+

When creating a secret based on a directory, each file whose basename is a valid key in the directory will be packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).

Usage

-

$ create -f FILENAME

+

$ generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]

Flags

@@ -1346,34 +1249,40 @@

Flags

+ + + + + + - + - - + + - - + + - + - + - - + + - + - - + + @@ -1382,64 +1291,22 @@

Flags

- - + - + + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + @@ -1447,44 +1314,19 @@

Flags

- - - - - -
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
append-hashfalseAppend a hash of the secret to its name.
dry-run false If true, only print the object that would be sent, without sending it.
editfrom-env-file falseEdit the API resource before creating Specify the path to a file to read lines of key=val pairs to create a secret (i.e. a Docker .env file).
filenameffrom-file []Filename, directory, or URL to files to use to create the resource Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key.
include-extended-apisfrom-literal trueIf true, include definitions of new APIs via calls to the API server. [default true] []Specify a key and literal value to insert in secret (i.e. mykey=somevalue)
no-headersgenerator falseWhen using the default or custom-column output format, don't print headers (default print headers). secret/v1The name of the API generator to use.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionsave-config DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
rawtemplate Raw URI to POST to the server. Uses the transport specified by the kubeconfig file. Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-configfalseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templatetype Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. The type of secret to create
validate true If true, use a schema to validate the input before sending it
windows-line-endingsfalseOnly relevant if --edit=true. Defaults to the line ending native to your platform.

-

clusterrole

-
-

Create a ClusterRole named "pod-reader" that allows user to perform "get", "watch" and "list" on pods

-
-
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods
-
-
-

Create a ClusterRole named "pod-reader" with ResourceName specified

-
-
kubectl create clusterrole pod-reader --verb=get,list,watch --resource=pods --resource-name=readablepod --resource-name=anotherpod
-
-
-

Create a ClusterRole named "foo" with API Group specified

-
-
kubectl create clusterrole foo --verb=get,list,watch --resource=rs.extensions
-
-
-

Create a ClusterRole named "foo" with SubResource specified

-
-
kubectl create clusterrole foo --verb=get,list,watch --resource=pods,pods/status
-
+

secret tls

-

Create a ClusterRole name "foo" with NonResourceURL specified

+

Create a new TLS secret named tls-secret with the given key pair:

-
kubectl create clusterrole "foo" --verb=get --non-resource-url=/logs/*
+
kubectl create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key
 
-

Create a ClusterRole.

+

Create a TLS secret from the given public/private key pair.

+

The public/private key pair must exist before hand. The public key certificate must be .PEM encoded and match the given private key.

Usage

-

$ clusterrole NAME --verb=verb --resource=resource.group [--resource-name=resourcename] [--dry-run]

+

$ tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run]

Flags

@@ -1503,46 +1345,40 @@

Flags

- + - + - + - - - - - - - + - - + - + + - - + - + + - + - - + + - + + - - + @@ -1551,24 +1387,6 @@

Flags

- - - - - - - - - - - - - - - - - - @@ -1580,24 +1398,28 @@

Flags

- - - - - -
If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runappend-hash falseIf true, only print the object that would be sent, without sending it. Append a hash of the secret to its name.
no-headerscert falseWhen using the default or custom-column output format, don't print headers (default print headers).
non-resource-url []A partial url that user should have access to. Path to PEM encoded public key certificate.
outputodry-run Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. falseIf true, only print the object that would be sent, without sending it.
output-versiongenerator DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). secret-for-tls/v1The name of the API generator to use.
resourcekey []Resource that the rule applies to Path to private key associated with given certificate.
resource-nameoutputo []Resource in the white list that the rule applies to, repeat this flag for multiple items Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
save-config If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
template true If true, use a schema to validate the input before sending it
verb[]Verb that applies to the resources contained in the rule

-

clusterrolebinding

+

service

+

Create a service using specified subcommand.

+

Usage

+

$ service

+
+

service clusterip

-

Create a ClusterRoleBinding for user1, user2, and group1 using the cluster-admin ClusterRole

+

Create a new ClusterIP service named my-cs

-
kubectl create clusterrolebinding cluster-admin --clusterrole=cluster-admin --user=user1 --user=user2 --group=group1
+
kubectl create service clusterip my-cs --tcp=5678:8080
 
-

Create a ClusterRoleBinding for a particular ClusterRole.

+
+

Create a new ClusterIP service named my-cs (in headless mode)

+
+
kubectl create service clusterip my-cs --clusterip="None"
+
+

Create a ClusterIP service with the specified name.

Usage

-

$ clusterrolebinding NAME --clusterrole=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

+

$ clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run]

Flags

@@ -1616,10 +1438,10 @@

Flags

- + - + @@ -1630,62 +1452,26 @@

Flags

- + - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + @@ -1702,38 +1488,16 @@

Flags

If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
clusterroleclusterip ClusterRole this ClusterRoleBinding should reference Assign your own ClusterIP or set to 'None' for a 'headless' service (no loadbalancing).
dry-run
generator clusterrolebinding.rbac.authorization.k8s.io/v1alpha1service-clusterip/v1 The name of the API generator to use.
group[]Groups to bind to the role
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
serviceaccounttcp []Service accounts to bind to the role, in the format :
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Port pairs can be specified as ':'.
template

-

configmap

-
-

Create a new configmap named my-config based on folder bar

-
-
kubectl create configmap my-config --from-file=path/to/bar
-
-
-

Create a new configmap named my-config with specified keys instead of file basenames on disk

-
-
kubectl create configmap my-config --from-file=key1=/path/to/bar/file1.txt --from-file=key2=/path/to/bar/file2.txt
-
-
-

Create a new configmap named my-config with key1=config1 and key2=config2

-
-
kubectl create configmap my-config --from-literal=key1=config1 --from-literal=key2=config2
-
-
-

Create a new configmap named my-config from the key=value pairs in the file

-
-
kubectl create configmap my-config --from-file=path/to/bar
-
+

service externalname

-

Create a new configmap named my-config from an env file

+

Create a new ExternalName service named my-ns

-
kubectl create configmap my-config --from-env-file=path/to/bar.env
+
kubectl create service externalname my-ns --external-name bar.com
 
-

Create a configmap based on a file, directory, or specified literal value.

-

A single configmap may package one or more key/value pairs.

-

When creating a configmap based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key, you may specify an alternate key.

-

When creating a configmap based on a directory, each file whose basename is a valid key in the directory will be packaged into the configmap. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).

+

Create an ExternalName service with the specified name.

+

ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference services that exist off platform, on other clusters, or locally.

Usage

-

$ configmap NAME [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]

+

$ externalname NAME --external-name external.name [--dry-run]

Flags

@@ -1752,82 +1516,40 @@

Flags

- - - - - - - + - + - + - - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + @@ -1844,15 +1566,15 @@

Flags

If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
append-hashfalseAppend a hash of the configmap to its name.
dry-run false If true, only print the object that would be sent, without sending it.
from-env-fileexternal-name Specify the path to a file to read lines of key=val pairs to create a configmap (i.e. a Docker .env file). External name of service
from-filegenerator []Key file can be specified using its file path, in which case file basename will be used as configmap key, or optionally with a key and file path, in which case the given key will be used. Specifying a directory will iterate each named file in the directory whose basename is a valid configmap key.
from-literal[]Specify a key and literal value to insert in configmap (i.e. mykey=somevalue)
generatorconfigmap/v1service-externalname/v1 The name of the API generator to use.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-bytcp If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. []Port pairs can be specified as ':'.
template

-

deployment

+

service loadbalancer

-

Create a new deployment named my-dep that runs the busybox image.

+

Create a new LoadBalancer service named my-lbs

-
kubectl create deployment my-dep --image=busybox
+
kubectl create service loadbalancer my-lbs --tcp=5678:8080
 
-

Create a deployment with the specified name.

+

Create a LoadBalancer service with the specified name.

Usage

-

$ deployment NAME --image=image [--dry-run]

+

$ loadbalancer NAME [--tcp=port:targetPort] [--dry-run]

Flags

@@ -1879,56 +1601,26 @@

Flags

- + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + + @@ -1945,15 +1637,15 @@

Flags

generator deployment-basic/v1beta1service-loadbalancer/v1 The name of the API generator to use.
image[]Image name to run.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-bytcp If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. []Port pairs can be specified as ':'.
template

-

job

+

service nodeport

-

Create a job from a CronJob named "a-cronjob"

+

Create a new NodePort service named my-ns

-
kubectl create job --from=cronjob/a-cronjob
+
kubectl create service nodeport my-ns --tcp=5678:8080
 
-

Create a job with the specified name.

+

Create a NodePort service with the specified name.

Usage

-

$ job NAME [--from-cronjob=CRONJOB]

+

$ nodeport NAME [--tcp=port:targetPort] [--dry-run]

Flags

@@ -1972,16 +1664,22 @@

Flags

- + + + + + + - + + - + - - + + @@ -1990,34 +1688,16 @@

Flags

- - - - - - - - - - - - - - - - - - - - + - + + @@ -2034,15 +1714,15 @@

Flags

If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
fromdry-run falseIf true, only print the object that would be sent, without sending it.
generator The name of the resource to create a Job from (only cronjob is supported). service-nodeport/v1The name of the API generator to use.
no-headersnode-port falseWhen using the default or custom-column output format, don't print headers (default print headers). 0Port used to expose the service on each node in a cluster.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-bytcp If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. []Port pairs can be specified as ':'.
template

-

namespace

+

serviceaccount

-

Create a new namespace named my-namespace

+

Create a new service account named my-service-account

-
kubectl create namespace my-namespace
+
kubectl create serviceaccount my-service-account
 
-

Create a namespace with the specified name.

+

Create a service account with the specified name.

Usage

-

$ namespace NAME [--dry-run]

+

$ serviceaccount NAME [--dry-run]

Flags

@@ -2069,52 +1749,22 @@

Flags

- + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - @@ -2129,20 +1779,59 @@

Flags

generator namespace/v1serviceaccount/v1 The name of the API generator to use.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config false If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
template

-

poddisruptionbudget

+

get

-

Create a pod disruption budget named my-pdb that will select all pods with the app=rails label # and require at least one of them being available at any point in time.

+

List all pods in ps output format.

-
kubectl create poddisruptionbudget my-pdb --selector=app=rails --min-available=1
+
kubectl get pods
 
-

Create a pod disruption budget named my-pdb that will select all pods with the app=nginx label # and require at least half of the pods selected to be available at any point in time.

+

List all pods in ps output format with more information (such as node name).

-
kubectl create pdb my-pdb --selector=app=nginx --min-available=50%
+
kubectl get pods -o wide
 
-

Create a pod disruption budget with the specified name, selector, and desired minimum available pods

+
+

List a single replication controller with specified NAME in ps output format.

+
+
kubectl get replicationcontroller web
+
+
+

List deployments in JSON output format, in the "v1" version of the "apps" API group:

+
+
kubectl get deployments.v1.apps -o json
+
+
+

List a single pod in JSON output format.

+
+
kubectl get -o json pod web-pod-13je7
+
+
+

List a pod identified by type and name specified in "pod.yaml" in JSON output format.

+
+
kubectl get -f pod.yaml -o json
+
+
+

Return only the phase value of the specified pod.

+
+
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
+
+
+

List all replication controllers and services together in ps output format.

+
+
kubectl get rc,services
+
+
+

List one or more resources by their type and names.

+
+
kubectl get rc/web service/frontend pods/web-pod-13je7
+
+

Display one or many resources

+

Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current namespace unless you pass --all-namespaces.

+

Uninitialized objects are not shown unless --include-uninitialized is passed.

+

By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources.

+

Use "kubectl api-resources" for a complete list of supported resources.

Usage

-

$ poddisruptionbudget NAME --selector=SELECTOR --min-available=N [--dry-run]

+

$ get [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (TYPE[.VERSION][.GROUP] [NAME | -l label] | TYPE[.VERSION][.GROUP]/NAME ...) [flags]

Flags

@@ -2155,37 +1844,61 @@

Flags

+ + + + + + - + - - + + - + - - + + - + - + - - - - + + + + - + + + + + + + + + + + + + + + + + + + @@ -2197,22 +1910,28 @@

Flags

- + - + - - + + - + + + + + + - + + @@ -2221,6 +1940,12 @@

Flags

+ + + + + + @@ -2239,28 +1964,91 @@

Flags

- + - - + + + + + + + + + + + + + +
all-namespacesfalseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
allow-missing-template-keys true If true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runchunk-size falseIf true, only print the object that would be sent, without sending it. 500Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future.
generatorexport poddisruptionbudget/v1beta1/v2The name of the API generator to use. falseIf true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.
max-unavailablefield-selector The maximum number or percentage of unavailable pods this budget requires. Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
min-availableThe minimum number or percentage of available pods this budget requires. filenamef[]Filename, directory, or URL to files identifying the resource to get from a server.
no-headersignore-not-foundfalseIf the requested object does not exist the command will return exit code 0.
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
label-columnsL[]Accepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2...
no-headers false When using the default or custom-column output format, don't print headers (default print headers). Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionraw DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). Raw URI to request from the server. Uses the transport specified by the kubeconfig file.
save-configrecursiveR falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
selectorl Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
server-print A label selector to use for this budget. Only equality-based selector requirements are supported. trueIf true, have the server return the appropriate table output. Supports extension APIs and CRDs.
show-all When printing, show all resources (default show all pods including terminated one.)
show-kindfalseIf present, list the resource type for the requested object(s).
show-labels false Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validateuse-openapi-print-columns trueIf true, use a schema to validate the input before sending it falseIf true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource.
watchwfalseAfter listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided.
watch-onlyfalseWatch for changes to the requested object(s), without listing/getting first.

-

priorityclass

+

run

-

Create a priorityclass named high-priority

+

Start a single instance of nginx.

-
kubectl create priorityclass default-priority --value=1000 --description="high priority"
+
kubectl run nginx --image=nginx
 
-

Create a priorityclass named default-priority that considered as the global default priority

+

Start a single instance of hazelcast and let the container expose port 5701 .

-
kubectl create priorityclass default-priority --value=1000 --global-default=true --description="default priority"
+
kubectl run hazelcast --image=hazelcast --port=5701
 
-

Create a priorityclass with the specified name, value, globalDefault and description

+
+

Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container.

+
+
kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
+
+
+

Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.

+
+
kubectl run hazelcast --image=nginx --labels="app=hazelcast,env=prod"
+
+
+

Start a replicated instance of nginx.

+
+
kubectl run nginx --image=nginx --replicas=5
+
+
+

Dry run. Print the corresponding API objects without creating them.

+
+
kubectl run nginx --image=nginx --dry-run
+
+
+

Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON.

+
+
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
+
+
+

Start a pod of busybox and keep it in the foreground, don't restart it if it exits.

+
+
kubectl run -i -t busybox --image=busybox --restart=Never
+
+
+

Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.

+
+
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
+
+
+

Start the nginx container using a different command and custom arguments.

+
+
kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
+
+
+

Start the perl container to compute π to 2000 places and print it out.

+
+
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
+
+

Start the cron job to compute π to 2000 places and print it out every 5 minutes.

+
+
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
+

Create and run a particular image, possibly replicated.

+

Creates a deployment or job to manage the created container(s).

Usage

-

$ priorityclass NAME --value=VALUE --global-default=BOOL [--dry-run]

+

$ run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [--command] -- [COMMAND] [args...]

Flags

@@ -2273,16 +2061,22 @@

Flags

- + - - + + - + + + + + + - + + @@ -2291,146 +2085,142 @@

Flags

- + - - + + - + - + - - - - + + + + - - + - + + - + - + - + - - - - - - - - + + - + - - + + - + - + - + - + - + + - - + - + - - + + - -
allow-missing-template-keysattach trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. falseIf true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned.
descriptioncascade trueIf true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.
command description is an arbitrary string that usually provides guidelines on when this priority class should be used. falseIf true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default.
dry-run If true, only print the object that would be sent, without sending it.
generatorenv priorityclass/v1alpha1The name of the API generator to use. []Environment variables to set in the container
global-defaultexpose falseglobal-default specifies whether this PriorityClass should be considered as the default priority. If true, a public, external service is created for the container(s) which are run
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers). filenamef[]to use to replace the resource.
outputoforce Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. falseOnly used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
output-versiongenerator DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). The name of the API generator to use, see http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators for a list.
save-configgrace-period falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
show-labelshostport falseWhen printing, show all labels as the last column (default hide labels column) -1The host port mapping for the container port. To demonstrate a single-machine container.
sort-byimage If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. The image for the container to run.
templateimage-pull-policy Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. The image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server
validatelabelsl trueIf true, use a schema to validate the input before sending it Comma separated labels to apply to the pod(s). Will override previous values.
valueleave-stdin-open 0the value of this priority class. falseIf the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes.
-
-

quota

-
-

Create a new resourcequota named my-quota

-
-
kubectl create quota my-quota --hard=cpu=1,memory=1G,pods=2,services=3,replicationcontrollers=2,resourcequotas=1,secrets=5,persistentvolumeclaims=10
-
-
-

Create a new resourcequota named best-effort

-
-
kubectl create quota best-effort --hard=pods=100 --scopes=BestEffort
-
-

Create a resourcequota with the specified name, hard limits and optional scopes

-

Usage

-

$ quota NAME [--hard=key1=value1,key2=value2] [--scopes=Scope1,Scope2] [--dry-run=bool]

-

Flags

- - - - - - + + + + - - - + + - - + - + - - + + - + - - + + - + - + - + - + - - + - + + - + + + + + + + + + + + + + + + + + + + + + + + + - + + @@ -2439,68 +2229,98 @@

Flags

- + - + - - - - + + + + - + - - + + - + - + - - + + + + + + + - + + - + + + + + + + - - + +
NameShorthandDefaultUsagelimitsThe resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges.
allow-missing-template-keysoutputo trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
dry-runoverrides falseIf true, only print the object that would be sent, without sending it. An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
generatorpod-running-timeout resourcequotas/v1The name of the API generator to use. 1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
hardport A comma-delimited set of resource=quantity pairs that define a hard limit. The port that this container exposes. If --expose is true, this is also the port used by the service that is created.
no-headersquiet falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, suppress prompt messages.
outputorecord Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
output-versionrecursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
replicasr1Number of replicas to create for this container. Default is 1.
requestsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.
restart AlwaysThe restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For the latter two --replicas must be 1. Default 'Always', for CronJobs Never.
rm DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). falseIf true, delete resources created in this command for attached containers.
save-config If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
scopesschedule A comma-delimited set of quota scopes that must all match each object tracked by the quota. A schedule in the Cron format the job should be run with.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) service-generatorservice/v2The name of the generator to use for creating a service. Only used if --expose is true
show-labelsservice-overrides falseWhen printing, show all labels as the last column (default hide labels column) An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true.
sort-byserviceaccount If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Service account to set in the pod spec
templatestdinifalseKeep stdin open on the container(s) in the pod, even if nothing is attached.
timeout Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
validatettytfalseAllocated a TTY for each container in the pod.
wait trueIf true, use a schema to validate the input before sending it falseIf true, wait for resources to be gone before returning. This waits for finalizers.

-

role

+

expose

-

Create a Role named "pod-reader" that allows user to perform "get", "watch" and "list" on pods

+

Create a service for a replicated nginx, which serves on port 80 and connects to the containers on port 8000.

-
kubectl create role pod-reader --verb=get --verb=list --verb=watch --resource=pods
+
kubectl expose rc nginx --port=80 --target-port=8000
 
-

Create a Role named "pod-reader" with ResourceName specified

+

Create a service for a replication controller identified by type and name specified in "nginx-controller.yaml", which serves on port 80 and connects to the containers on port 8000.

-
kubectl create role pod-reader --verb=get,list,watch --resource=pods --resource-name=readablepod --resource-name=anotherpod
+
kubectl expose -f nginx-controller.yaml --port=80 --target-port=8000
 
-

Create a Role named "foo" with API Group specified

+

Create a service for a pod valid-pod, which serves on port 444 with the name "frontend"

-
kubectl create role foo --verb=get,list,watch --resource=rs.extensions
+
kubectl expose pod valid-pod --port=444 --name=frontend
 
-

Create a Role named "foo" with SubResource specified

+

Create a second service based on the above service, exposing the container port 8443 as port 443 with the name "nginx-https"

-
kubectl create role foo --verb=get,list,watch --resource=pods,pods/status
+
kubectl expose service nginx --port=443 --target-port=8443 --name=nginx-https
 
-

Create a role with single rule.

+
+

Create a service for a replicated streaming application on port 4100 balancing UDP traffic and named 'video-stream'.

+
+
kubectl expose rc streamer --port=4100 --protocol=udp --name=video-stream
+
+
+

Create a service for a replicated nginx using replica set, which serves on port 80 and connects to the containers on port 8000.

+
+
kubectl expose rs nginx --port=80 --target-port=8000
+
+
+

Create a service for an nginx deployment, which serves on port 80 and connects to the containers on port 8000.

+
+
kubectl expose deployment nginx --port=80 --target-port=8000
+
+

Expose a resource as a new Kubernetes service.

+

Looks up a deployment, service, replica set, replication controller or pod by name and uses the selector for that resource as the selector for a new service on the specified port. A deployment or replica set will be exposed as a service only if its selector is convertible to a selector that service supports, i.e. when the selector contains only the matchLabels component. Note that if no port is specified via --port and the exposed resource has multiple ports, all will be re-used by the new service. Also if no labels are specified, the new service will re-use the labels from the resource it exposes.

+

Possible resources include (case insensitive):

+

pod (po), service (svc), replicationcontroller (rc), deployment (deploy), replicaset (rs)

Usage

-

$ role NAME --verb=verb --resource=resource.group/subresource [--resource-name=resourcename] [--dry-run]

+

$ expose (-f FILENAME | TYPE NAME) [--port=port] [--protocol=TCP|UDP] [--target-port=number-or-name] [--name=name] [--external-ip=external-ip-of-service] [--type=type]

Flags

@@ -2513,230 +2333,171 @@

Flags

- + - - - - - - - + - + - - - - - - - + - - + - + + - + - - + + - - + + - + - + - - - - - - - - + + - + + - - + - + - + - + - + - + + - - + - + - - - - -
allow-missing-template-keyscluster-ip trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-run falseIf true, only print the object that would be sent, without sending it. ClusterIP to be assigned to the service. Leave empty to auto-allocate, or set to 'None' to create a headless service.
no-headerscontainer-port falseWhen using the default or custom-column output format, don't print headers (default print headers).
outputo Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. Synonym for --target-port
output-versiondry-run DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). falseIf true, only print the object that would be sent, without sending it.
resourceexternal-ip []Resource that the rule applies to Additional external IP address (not managed by Kubernetes) to accept for the service. If this IP is routed to a node, the service can be accessed by this IP in addition to its generated service IP.
resource-namefilenamef []Resource in the white list that the rule applies to, repeat this flag for multiple items Filename, directory, or URL to files identifying the resource to expose a service
save-configgenerator falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) service/v2The name of the API generator to use. There are 2 generators: 'service/v1' and 'service/v2'. The only difference between them is that service port in v1 is named 'default', while it is left unnamed in v2. Default is 'service/v2'.
show-labelslabelsl falseWhen printing, show all labels as the last column (default hide labels column) Labels to apply to the service created by this call.
sort-byload-balancer-ip If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. IP to assign to the LoadBalancer. If empty, an ephemeral IP will be created and used (cloud-provider specific).
templatename Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. The name for the newly created object.
validateoutputo trueIf true, use a schema to validate the input before sending it Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
verboverrides []Verb that applies to the resources contained in the rule
-
-

rolebinding

-
-

Create a RoleBinding for user1, user2, and group1 using the admin ClusterRole

-
-
kubectl create rolebinding admin --clusterrole=admin --user=user1 --user=user2 --group=group1
-
-

Create a RoleBinding for a particular Role or ClusterRole.

-

Usage

-

$ rolebinding NAME --clusterrole=NAME|--role=NAME [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

-

Flags

- - - - - - - - - - - - - - + - + - + - + - - - - - - - + - + - - + + - - + + - + - - + - + + - + - + - + - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + - - + - - - - - - +
NameShorthandDefaultUsage
allow-missing-template-keys trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
clusterroleport ClusterRole this RoleBinding should reference The port that the service should serve on. Copied from the resource being exposed, if unspecified
dry-runprotocol falseIf true, only print the object that would be sent, without sending it.
generator rolebinding.rbac.authorization.k8s.io/v1alpha1The name of the API generator to use. The network protocol for the service to be created. Default is 'TCP'.
grouprecord []Groups to bind to the role falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
no-headersrecursiveR falseWhen using the default or custom-column output format, don't print headers (default print headers). Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
outputosave-config Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
output-versionselector DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). A label selector to use for this service. Only equality-based selector requirements are supported. If empty (the default) infer the selector from the replication controller or replica set.)
rolesession-affinity Role this RoleBinding should reference
save-configfalseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
serviceaccount[]Service accounts to bind to the role, in the format :
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column) If non-empty, set the session affinity for the service to this; legal values: 'None', 'ClientIP'
sort-bytarget-port If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Name or number for the port on the container that the service should direct traffic to. Optional.
templatetype Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validate trueIf true, use a schema to validate the input before sending it Type for this service: ClusterIP, NodePort, LoadBalancer, or ExternalName. Default is 'ClusterIP'.

-

secret

-

Create a secret using specified subcommand.

-

Usage

-

$ secret

-
-

secret docker-registry

+

delete

-

If you don't already have a .dockercfg file, you can create a dockercfg secret directly by using:

+

Delete a pod using the type and name specified in pod.json.

-
kubectl create secret docker-registry my-secret --docker-server=DOCKER_REGISTRY_SERVER --docker-username=DOCKER_USER --docker-password=DOCKER_PASSWORD --docker-email=DOCKER_EMAIL
+
kubectl delete -f ./pod.json
+
+
+

Delete a pod based on the type and name in the JSON passed into stdin.

+
+
cat pod.json | kubectl delete -f -
+
+
+

Delete pods and services with same names "baz" and "foo"

+
+
kubectl delete pod,service baz foo
+
+
+

Delete pods and services with label name=myLabel.

+
+
kubectl delete pods,services -l name=myLabel
+
+
+

Delete a pod with minimal delay

+
+
kubectl delete pod foo --now
+
+
+

Force delete a pod on a dead node

+
+
kubectl delete pod foo --grace-period=0 --force
+
+
+

Delete all pods

+
+
kubectl delete pods --all
 
-

Create a new secret for use with Docker registries.

-

Dockercfg secrets are used to authenticate against Docker registries.

-

When using the Docker command line to push images, you can authenticate to a given registry by running: '$ docker login DOCKER REGISTRY SERVER --username=DOCKER USER --password=DOCKER PASSWORD --email=DOCKER _EMAIL'.

-

That produces a ~/.dockercfg file that is used by subsequent 'docker push' and 'docker pull' commands to

-

authenticate to the registry. The email address is optional.

-

When creating applications, you may have a Docker registry that requires authentication. In order for the nodes to pull images on your behalf, they have to have the credentials. You can provide this information by creating a dockercfg secret and attaching it to your service account.

+

Delete resources by filenames, stdin, resources and names, or by resources and label selector.

+

JSON and YAML formats are accepted. Only one type of the arguments may be specified: filenames, resources and names, or resources and label selector.

+

Some resources, such as pods, support graceful deletion. These resources define a default period before they are forcibly terminated (the grace period) but you may override that value with the --grace-period flag, or pass --now to set a grace-period of 1. Because these resources often represent entities in the cluster, deletion may not be acknowledged immediately. If the node hosting a pod is down or cannot reach the API server, termination may take significantly longer than the grace period. To force delete a resource, you must pass a grace period of 0 and specify the --force flag.

+

IMPORTANT: Force deleting pods does not wait for confirmation that the pod's processes have been terminated, which can leave those processes running until the node detects the deletion and completes graceful deletion. If your processes use shared storage or talk to a remote API and depend on the name of the pod to identify themselves, force deleting those pods may result in multiple processes running on different machines using the same identification which may lead to data corruption or inconsistency. Only force delete pods when you are sure the pod is terminated, or if your application can tolerate multiple copies of the same pod running at once. Also, if you force delete pods the scheduler may place new pods on those nodes before the node has released those resources and causing those pods to be evicted immediately.

+

Note that the delete command does NOT do resource version checks, so if someone submits an update to a resource right when you submit a delete, their update will be lost along with the rest of the resource.

Usage

-

$ docker-registry NAME --docker-username=user --docker-password=password --docker-email=email [--docker-server=string] [--from-literal=key1=value1] [--dry-run]

+

$ delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)])

Flags

@@ -2749,148 +2510,121 @@

Flags

- - - - - - - + - + - - + - + + - + - + - - - - + + + + - - + - + + - + - - + + - + - - + + - + - - + + - + - + - - - - - - - - - - - - - - - - - - - + - - + + - + - - + + - + - - + - + + - + - +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
append-hashall falseAppend a hash of the secret to its name. Delete all resources, including uninitialized ones, in the namespace of the specified resource types.
docker-emailcascade Email for Docker registry trueIf true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.
docker-passwordfield-selector Password for Docker registry authentication Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
docker-serverhttps://index.docker.io/v1/Server location for Docker registry filenamef[]containing the resource to delete.
docker-usernameforce Username for Docker registry authentication falseOnly used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
dry-rungrace-period falseIf true, only print the object that would be sent, without sending it. -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
generatorignore-not-found secret-for-docker-registry/v1The name of the API generator to use. falseTreat "resource not found" as a successful delete. Defaults to "true" when --all is specified.
include-extended-apisinclude-uninitialized trueIf true, include definitions of new APIs via calls to the API server. [default true] falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
no-headersnow falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, resources are signaled for immediate shutdown (same as --grace-period=1).
output o Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-configfalseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Output mode. Use "-o name" for shorter output (resource/name).
show-labelsrecursiveR falseWhen printing, show all labels as the last column (default hide labels column) Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
sort-byselectorl If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Selector (label query) to filter on, not including uninitialized ones.
templatetimeout Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
validatewait trueIf true, use a schema to validate the input before sending it If true, wait for resources to be gone before returning. This waits for finalizers.
+

APP MANAGEMENT

+

This section contains commands for creating, updating, deleting, and +viewing your workloads in a Kubernetes cluster.


-

secret generic

-
-

Create a new secret named my-secret with keys for each file in folder bar

-
-
kubectl create secret generic my-secret --from-file=path/to/bar
-
+

apply

-

Create a new secret named my-secret with specified keys instead of names on disk

+

Apply the configuration in pod.json to a pod.

-
kubectl create secret generic my-secret --from-file=ssh-privatekey=~/.ssh/id_rsa --from-file=ssh-publickey=~/.ssh/id_rsa.pub
+
kubectl apply -f ./pod.json
 
-

Create a new secret named my-secret with key1=supersecret and key2=topsecret

+

Apply the JSON passed into stdin to a pod.

-
kubectl create secret generic my-secret --from-literal=key1=supersecret --from-literal=key2=topsecret
+
cat pod.json | kubectl apply -f -
 
-

Create a new secret named my-secret using a combination of a file and a literal

+

Note: --prune is still in Alpha # Apply the configuration in manifest.yaml that matches label app=nginx and delete all the other resources that are not in the file and match label app=nginx.

-
kubectl create secret generic my-secret --from-file=ssh-privatekey=~/.ssh/id_rsa --from-literal=passphrase=topsecret
+
kubectl apply --prune -f manifest.yaml -l app=nginx
 
-

Create a new secret named my-secret from an env file

+

Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.

-
kubectl create secret generic my-secret --from-env-file=path/to/bar.env
+
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
 
-

Create a secret based on a file, directory, or specified literal value.

-

A single secret may package one or more key/value pairs.

-

When creating a secret based on a file, the key will default to the basename of the file, and the value will default to the file content. If the basename is an invalid key or you wish to chose your own, you may specify an alternate key.

-

When creating a secret based on a directory, each file whose basename is a valid key in the directory will be packaged into the secret. Any directory entries except regular files are ignored (e.g. subdirectories, symlinks, devices, pipes, etc).

+

Apply a configuration to a resource by filename or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.

+

JSON and YAML formats are accepted.

+

Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.

Usage

-

$ generic NAME [--type=string] [--from-file=[key=]source] [--from-literal=key1=value1] [--dry-run]

+

$ apply -f FILENAME

Flags

@@ -2903,16 +2637,16 @@

Flags

- + - - + + - + - - + + @@ -2921,34 +2655,34 @@

Flags

- - - - + + + + - + - - + + - + - - + + - + - - + + - + - - + + @@ -2957,46 +2691,46 @@

Flags

- - + - + + - + - + - - - - + + + + - + - + - - - - + + + + - - + + - + - - + - + + @@ -3004,19 +2738,33 @@

Flags

+ + + + + +
allow-missing-template-keysall trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. falseSelect all resources in the namespace of the specified resource types.
append-hashcascade falseAppend a hash of the secret to its name. trueIf true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.
dry-run If true, only print the object that would be sent, without sending it.
from-env-fileSpecify the path to a file to read lines of key=val pairs to create a secret (i.e. a Docker .env file). filenamef[]that contains the configuration to apply
from-fileforce []Key files can be specified using their file path, in which case a default name will be given to them, or optionally with a name and file path, in which case the given name will be used. Specifying a directory will iterate each named file in the directory that is a valid secret key. falseOnly used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
from-literalgrace-period []Specify a key and literal value to insert in secret (i.e. mykey=somevalue) -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
generatorinclude-uninitialized secret/v1The name of the API generator to use. falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
no-headersopenapi-patch falseWhen using the default or custom-column output format, don't print headers (default print headers). trueIf true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionoverwrite DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). trueAutomatically resolve conflicts between the modified and live configuration by using values from the modified configuration
save-configprune falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. Automatically delete resource objects, including the uninitialized ones, that do not appear in the configs and are created by either apply or create --save-config. Should be used with either -l or --all.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) prune-whitelist[]Overwrite the default whitelist with for --prune
show-labelsrecord falseWhen printing, show all labels as the last column (default hide labels column) Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
templateselectorl Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
typetimeout The type of secret to create 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
validate true If true, use a schema to validate the input before sending it
waitfalseIf true, wait for resources to be gone before returning. This waits for finalizers.

-

secret tls

+

edit-last-applied

-

Create a new TLS secret named tls-secret with the given key pair:

+

Edit the last-applied-configuration annotations by type/name in YAML.

-
kubectl create secret tls tls-secret --cert=path/to/tls.cert --key=path/to/tls.key
+
kubectl apply edit-last-applied deployment/nginx
 
-

Create a TLS secret from the given public/private key pair.

-

The public/private key pair must exist before hand. The public key certificate must be .PEM encoded and match the given private key.

+
+

Edit the last-applied-configuration annotations by file in JSON.

+
+
kubectl apply edit-last-applied -f deploy.yaml -o json
+
+

Edit the latest last-applied-configuration annotations of resources from the default editor.

+

The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command line tools. It will open the editor defined by your KUBE _EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.

+

The default format is YAML. To edit in JSON, specify "-o json".

+

The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.

+

In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version.

Usage

-

$ tls NAME --cert=path/to/cert/file --key=path/to/key/file [--dry-run]

+

$ edit-last-applied (RESOURCE/NAME | -f FILENAME)

Flags

@@ -3029,117 +2777,63 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + - + - + - - - - - - - - + + - + - - - - - - - + - - + + - - - - - - - - - - - - - + - + - - + +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
append-hashfalseAppend a hash of the secret to its name.
certPath to PEM encoded public key certificate.
dry-runfalseIf true, only print the object that would be sent, without sending it.
generatorsecret-for-tls/v1The name of the API generator to use.
keyPath to private key associated with given certificate. filenamef[]Filename, directory, or URL to files to use to edit the resource
no-headersinclude-uninitialized falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
output oOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). yamlOutput format. One of: yaml|json.
save-configrecord falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
show-labelsrecursiveR falseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
validatewindows-line-endings trueIf true, use a schema to validate the input before sending it falseDefaults to the line ending native to your platform.

-

service

-

Create a service using specified subcommand.

-

Usage

-

$ service

-
-

service clusterip

+

set-last-applied

-

Create a new ClusterIP service named my-cs

+

Set the last-applied-configuration of a resource to match the contents of a file.

-
kubectl create service clusterip my-cs --tcp=5678:8080
+
kubectl apply set-last-applied -f deploy.yaml
 
-

Create a new ClusterIP service named my-cs (in headless mode)

+

Execute set-last-applied against each configuration file in a directory.

-
kubectl create service clusterip my-cs --clusterip="None"
+
kubectl apply set-last-applied -f path/
 
-

Create a ClusterIP service with the specified name.

+
+

Set the last-applied-configuration of a resource to match the contents of a file, will create the annotation if it does not already exist.

+
+
kubectl apply set-last-applied -f deploy.yaml --create-annotation=true
+
+

Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without updating any other parts of the object.

Usage

-

$ clusterip NAME [--tcp=<port>:<targetPort>] [--dry-run]

+

$ set-last-applied -f FILENAME

Flags

@@ -3152,16 +2846,10 @@

Flags

- - - - - - - - + - + + @@ -3170,16 +2858,10 @@

Flags

- - - - - - - - - - + + + + @@ -3187,67 +2869,105 @@

Flags

+ +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
clusteripcreate-annotation Assign your own ClusterIP or set to 'None' for a 'headless' service (no loadbalancing). falseWill create 'last-applied-configuration' annotations if current objects doesn't have one
dry-run If true, only print the object that would be sent, without sending it.
generatorservice-clusterip/v1The name of the API generator to use.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers). filenamef[]Filename, directory, or URL to files that contains the last-applied-configuration annotations
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
+
+

view-last-applied

+
+

View the last-applied-configuration annotations by type/name in YAML.

+
+
kubectl apply view-last-applied deployment/nginx
+
+
+

View the last-applied-configuration annotations by file in JSON

+
+
kubectl apply view-last-applied -f deploy.yaml -o json
+
+

View the latest last-applied-configuration annotations by type/name or file.

+

The default output will be printed to stdout in YAML format. One can use -o option to change output format.

+

Usage

+

$ view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)

+

Flags

+ + - - - - + + + + + + - + - + - - - - + + + + - - - - + + + + - - - - + + + + - - - - - - - - - - - - - + + - - +
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). NameShorthandDefaultUsage
save-configall falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. Select all resources in the namespace of the specified resource types
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) filenamef[]Filename, directory, or URL to files that contains the last-applied-configuration annotations
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column) outputoyamlOutput format. Must be one of yaml|json
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
tcp[]Port pairs can be specified as ':'.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validateselectorl trueIf true, use a schema to validate the input before sending it Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)

-

service externalname

+

annotate

-

Create a new ExternalName service named my-ns

+

Update pod 'foo' with the annotation 'description' and the value 'my frontend'. # If the same annotation is set multiple times, only the last value will be applied

-
kubectl create service externalname my-ns --external-name bar.com
+
kubectl annotate pods foo description='my frontend'
 
-

Create an ExternalName service with the specified name.

-

ExternalName service references to an external DNS address instead of only pods, which will allow application authors to reference services that exist off platform, on other clusters, or locally.

+
+

Update a pod identified by type and name in "pod.json"

+
+
kubectl annotate -f pod.json description='my frontend'
+
+
+

Update pod 'foo' with the annotation 'description' and the value 'my frontend running nginx', overwriting any existing value.

+
+
kubectl annotate --overwrite pods foo description='my frontend running nginx'
+
+
+

Update all pods in the namespace

+
+
kubectl annotate pods --all description='my frontend running nginx'
+
+
+

Update pod 'foo' only if the resource is unchanged from version 1.

+
+
kubectl annotate pods foo description='my frontend running nginx' --resource-version=1
+
+
+

Update pod 'foo' by removing an annotation named 'description' if it exists. # Does not require the --overwrite flag.

+
+
kubectl annotate pods foo description-
+
+

Update the annotations on one or more resources

+

All Kubernetes objects support the ability to store additional data with the object as annotations. Annotations are key/value pairs that can be larger than labels and include arbitrary string values such as structured JSON. Tools and system extensions may use annotations to store their own data.

+

Attempting to set an annotation that already exists will fail unless --overwrite is set. If --resource-version is specified and does not match the current resource version on the server the command will fail.

+

Use "kubectl api-resources" for a complete list of supported resources.

Usage

-

$ externalname NAME --external-name external.name [--dry-run]

+

$ annotate [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

Flags

@@ -3260,10 +2980,10 @@

Flags

- + - - + + @@ -3272,22 +2992,28 @@

Flags

- + - + - + + + + + + + - - + + - + - + @@ -3296,65 +3022,53 @@

Flags

- - - - - - - + - - - - - - - + - + - - - - - - - + - - - - + + + + - + - + - + + - - +
allow-missing-template-keysall trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types.
dry-run If true, only print the object that would be sent, without sending it.
external-namefield-selector External name of service Selector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
generatorfilenamef[]Filename, directory, or URL to files identifying the resource to update the annotation
include-uninitialized service-externalname/v1The name of the API generator to use. falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
no-headerslocal falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, annotation will NOT contact api-server but run locally.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-configoverwrite falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) If true, allow annotations to be overwritten, otherwise reject annotation updates that overwrite existing annotations.
show-labelsrecord falseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
tcp[]Port pairs can be specified as ':'. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
templateresource-version Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. If non-empty, the annotation update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
validateselectorl trueIf true, use a schema to validate the input before sending it Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).

-

service loadbalancer

+

autoscale

-

Create a new LoadBalancer service named my-lbs

+

Auto scale a deployment "foo", with the number of pods between 2 and 10, no target CPU utilization specified so a default autoscaling policy will be used:

-
kubectl create service loadbalancer my-lbs --tcp=5678:8080
+
kubectl autoscale deployment foo --min=2 --max=10
 
-

Create a LoadBalancer service with the specified name.

+
+

Auto scale a replication controller "foo", with the number of pods between 1 and 5, target CPU utilization at 80%:

+
+
kubectl autoscale rc foo --max=5 --cpu-percent=80
+
+

Creates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster.

+

Looks up a Deployment, ReplicaSet, or ReplicationController by name and creates an autoscaler that uses the given resource as a reference. An autoscaler can automatically increase or decrease number of pods deployed within the system as needed.

Usage

-

$ loadbalancer NAME [--tcp=port:targetPort] [--dry-run]

+

$ autoscale (-f FILENAME | TYPE NAME | TYPE/NAME) [--min=MINPODS] --max=MAXPODS [--cpu-percent=CPU]

Flags

@@ -3367,10 +3081,10 @@

Flags

- + - - + + @@ -3379,83 +3093,83 @@

Flags

- - - - + + + + - + - - + + - - + - + + - - + - + + - + - - - - - - - - - - - - - + - - + + - + - + - - + + - - - - + + + + - + - - + +
allow-missing-template-keyscpu-percent trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. -1The target average CPU utilization (represented as a percent of requested CPU) over all the pods. If it's not specified or negative, a default autoscaling policy will be used.
dry-run If true, only print the object that would be sent, without sending it.
generatorservice-loadbalancer/v1The name of the API generator to use. filenamef[]Filename, directory, or URL to files identifying the resource to autoscale.
no-headersgenerator falseWhen using the default or custom-column output format, don't print headers (default print headers). horizontalpodautoscaler/v1The name of the API generator to use. Currently there is only 1 generator.
outputomax Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. -1The upper limit for the number of pods that can be set by the autoscaler. Required.
output-versionmin DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). -1The lower limit for the number of pods that can be set by the autoscaler. If it's not specified or negative, the server will apply a default value.
save-configname falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labels falseWhen printing, show all labels as the last column (default hide labels column) The name for the newly created object. If not specified, the name of the input resource will be used.
sort-byoutputo If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
tcprecord []Port pairs can be specified as ':'. falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
validatesave-config trueIf true, use a schema to validate the input before sending it falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.

-

service nodeport

+

convert

-

Create a new NodePort service named my-ns

+

Convert 'pod.yaml' to latest version and print to stdout.

-
kubectl create service nodeport my-ns --tcp=5678:8080
+
kubectl convert -f pod.yaml
 
-

Create a NodePort service with the specified name.

+
+

Convert the live state of the resource specified by 'pod.yaml' to the latest version # and print to stdout in JSON format.

+
+
kubectl convert -f pod.yaml --local -o json
+
+
+

Convert all files under current directory to latest version and create them all.

+
+
kubectl convert -f . | kubectl create -f -
+
+

Convert config files between different API versions. Both YAML and JSON formats are accepted.

+

The command takes filename, directory, or URL as input, and convert it into format of version specified by --output-version flag. If target version is not specified or not supported, convert to latest version.

+

The default output will be printed to stdout in YAML format. One can use -o option to change to output destination.

Usage

-

$ nodeport NAME [--tcp=port:targetPort] [--dry-run]

+

$ convert -f FILENAME

Flags

@@ -3468,82 +3182,34 @@

Flags

- + + + + + + + - + - - - - + + + + - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - - - - - - - + @@ -3554,15 +3220,35 @@

Flags

allow-missing-template-keysfilenamef[]Filename, directory, or URL to files to need to get converted.
local trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. If true, convert will NOT try to contact api-server but run locally.
dry-runfalseIf true, only print the object that would be sent, without sending it. outputoyamlOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
generatoroutput-version service-nodeport/v1The name of the API generator to use.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
node-port0Port used to expose the service on each node in a cluster.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-config falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Output the formatted object with the given group version (for ex: 'extensions/v1beta1').)
show-labelsrecursiveR falseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
tcp[]Port pairs can be specified as ':'.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
validate

-

serviceaccount

+

edit

-

Create a new service account named my-service-account

+

Edit the service named 'docker-registry':

-
kubectl create serviceaccount my-service-account
+
kubectl edit svc/docker-registry
 
-

Create a service account with the specified name.

+
+

Use an alternative editor

+
+
KUBE_EDITOR="nano" kubectl edit svc/docker-registry
+
+
+

Edit the job 'myjob' in JSON using the v1 API format:

+
+
kubectl edit job.v1.batch/myjob -o json
+
+
+

Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation:

+
+
kubectl edit deployment/mydeployment -o yaml --save-config
+
+

Edit a resource from the default editor.

+

The edit command allows you to directly edit any API resource you can retrieve via the command line tools. It will open the editor defined by your KUBE _EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.

+

Editing is done with the API version used to fetch the resource. To edit using a specific API version, fully-qualify the resource, version, and group.

+

The default format is YAML. To edit in JSON, specify "-o json".

+

The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.

+

In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version.

Usage

-

$ serviceaccount NAME [--dry-run]

+

$ edit (RESOURCE/NAME | -f FILENAME)

Flags

@@ -3575,34 +3261,16 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - + + + + - + - + @@ -3611,40 +3279,28 @@

Flags

- - - - - - - + - - - - - - - + - + - + - - - - + + + + - - + - + + @@ -3652,52 +3308,55 @@

Flags

+ + + + + +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runfalseIf true, only print the object that would be sent, without sending it.
generatorserviceaccount/v1The name of the API generator to use.
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true] filenamef[]Filename, directory, or URL to files to use to edit the resource
no-headersinclude-uninitialized falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
save-configoutput-patch falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Output the patch if the resource is edited.
show-labelsrecord falseWhen printing, show all labels as the last column (default hide labels column) Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
templatesave-config Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
validate true If true, use a schema to validate the input before sending it
windows-line-endingsfalseDefaults to the line ending native to your platform.

-

delete

-
-

Delete a pod using the type and name specified in pod.json.

-
-
kubectl delete -f ./pod.json
-
+

label

-

Delete a pod based on the type and name in the JSON passed into stdin.

+

Update pod 'foo' with the label 'unhealthy' and the value 'true'.

-
cat pod.json | kubectl delete -f -
+
kubectl label pods foo unhealthy=true
 
-

Delete pods and services with same names "baz" and "foo"

+

Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.

-
kubectl delete pod,service baz foo
+
kubectl label --overwrite pods foo status=unhealthy
 
-

Delete pods and services with label name=myLabel.

+

Update all pods in the namespace

-
kubectl delete pods,services -l name=myLabel
+
kubectl label pods --all status=unhealthy
 
-

Delete a pod with minimal delay

+

Update a pod identified by the type and name in "pod.json"

-
kubectl delete pod foo --now
+
kubectl label -f pod.json status=unhealthy
 
-

Force delete a pod on a dead node

+

Update pod 'foo' only if the resource is unchanged from version 1.

-
kubectl delete pod foo --grace-period=0 --force
+
kubectl label pods foo status=unhealthy --resource-version=1
 
-

Delete all pods

+

Update pod 'foo' by removing a label named 'bar' if it exists. # Does not require the --overwrite flag.

-
kubectl delete pods --all
+
kubectl label pods foo bar-
 
-

Delete resources by filenames, stdin, resources and names, or by resources and label selector.

-

JSON and YAML formats are accepted. Only one type of the arguments may be specified: filenames, resources and names, or resources and label selector.

-

Some resources, such as pods, support graceful deletion. These resources define a default period before they are forcibly terminated (the grace period) but you may override that value with the --grace-period flag, or pass --now to set a grace-period of 1. Because these resources often represent entities in the cluster, deletion may not be acknowledged immediately. If the node hosting a pod is down or cannot reach the API server, termination may take significantly longer than the grace period. To force delete a resource, you must pass a grace period of 0 and specify the --force flag.

-

IMPORTANT: Force deleting pods does not wait for confirmation that the pod's processes have been terminated, which can leave those processes running until the node detects the deletion and completes graceful deletion. If your processes use shared storage or talk to a remote API and depend on the name of the pod to identify themselves, force deleting those pods may result in multiple processes running on different machines using the same identification which may lead to data corruption or inconsistency. Only force delete pods when you are sure the pod is terminated, or if your application can tolerate multiple copies of the same pod running at once. Also, if you force delete pods the scheduler may place new pods on those nodes before the node has released those resources and causing those pods to be evicted immediately.

-

Note that the delete command does NOT do resource version checks, so if someone submits an update to a resource right when you submit a delete, their update will be lost along with the rest of the resource.

+

Update the labels on a resource.

+
    +
  • A label key and value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters each.
  • +
  • Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app
  • +
  • If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error.
  • +
  • If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.
  • +

Usage

-

$ delete ([-f FILENAME] | TYPE [(NAME | -l label | --all)])

+

$ label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

Flags

@@ -3713,61 +3372,61 @@

Flags

- + - + - - + + + + + + + + - + - + - + - + - - + + - + - + - + + - - + - + - + - + - - - - - - - + @@ -3776,49 +3435,51 @@

Flags

- - + - + + - + + - - +
all falseDelete all resources, including uninitialized ones, in the namespace of the specified resource types. Select all resources, including uninitialized ones, in the namespace of the specified resource types
cascadedry-run trueIf true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true. falseIf true, only print the object that would be sent, without sending it.
field-selectorSelector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type.
filename f []Filename, directory, or URL to files containing the resource to delete. Filename, directory, or URL to files identifying the resource to update the labels
forceinclude-uninitialized falseImmediate deletion of some resources may result in inconsistency or data loss and requires confirmation. If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
grace-periodlist -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. falseIf true, display the labels for a given resource.
ignore-not-foundlocal falseTreat "resource not found" as a successful delete. Defaults to "true" when --all is specified. If true, label will NOT contact api-server but run locally.
include-extended-apisoutputo trueIf true, include definitions of new APIs via calls to the API server. [default true] Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
include-uninitializedoverwrite falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. If true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels.
nowrecord falseIf true, resources are signaled for immediate shutdown (same as --grace-period=1).
outputoOutput mode. Use "-o name" for shorter output (resource/name). Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
selectorlresource-version Selector (label query) to filter on, not including uninitialized ones. If non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
timeoutselectorl 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2).

-

edit

+

patch

-

Edit the service named 'docker-registry':

+

Partially update a node using a strategic merge patch. Specify the patch as JSON.

-
kubectl edit svc/docker-registry
+
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
 
-

Use an alternative editor

+

Partially update a node using a strategic merge patch. Specify the patch as YAML.

-
KUBE_EDITOR="nano" kubectl edit svc/docker-registry
+
kubectl patch node k8s-node-1 -p $'spec:\n unschedulable: true'
 
-

Edit the job 'myjob' in JSON using the v1 API format:

+

Partially update a node identified by the type and name specified in "node.json" using strategic merge patch.

-
kubectl edit job.v1.batch/myjob -o json
+
kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}'
 
-

Edit the deployment 'mydeployment' in YAML and save the modified config in its annotation:

+

Update a container's image; spec.containers[*].name is required because it's a merge key.

-
kubectl edit deployment/mydeployment -o yaml --save-config
+
kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
 
-

Edit a resource from the default editor.

-

The edit command allows you to directly edit any API resource you can retrieve via the command line tools. It will open the editor defined by your KUBE _EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.

-

Editing is done with the API version used to fetch the resource. To edit using a specific API version, fully-qualify the resource, version, and group.

-

The default format is YAML. To edit in JSON, specify "-o json".

-

The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.

-

In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version.

+
+

Update a container's image using a json patch with positional arrays.

+
+
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
+
+

Update field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.

+

JSON and YAML formats are accepted.

+

Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.

Usage

-

$ edit (RESOURCE/NAME | -f FILENAME)

+

$ patch (-f FILENAME | TYPE NAME) -p PATCH

Flags

@@ -3831,34 +3492,34 @@

Flags

+ + + + + + - - - - - - - + - + - + - - + + - + + - - + @@ -3873,118 +3534,41 @@

Flags

- - - - - - - - - - - - - + - - + +
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f []Filename, directory, or URL to files to use to edit the resource
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true] Filename, directory, or URL to files identifying the resource to update
include-uninitializedlocal falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. If true, patch will operate on the content of the file, not the server-side resource.
output oyamlOutput format. One of: yaml|json. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-patchpatchp falseOutput the patch if the resource is edited. The patch to be applied to the resource JSON file.
record Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-configfalseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
validatetrueIf true, use a schema to validate the input before sending it
windows-line-endingstype falseDefaults to the line ending native to your platform. strategicThe type of patch being provided; one of [json merge strategic]

-

get

-
-

List all pods in ps output format.

-
-
kubectl get pods
-
-
-

List all pods in ps output format with more information (such as node name).

-
-
kubectl get pods -o wide
-
-
-

List a single replication controller with specified NAME in ps output format.

-
-
kubectl get replicationcontroller web
-
-
-

List a single pod in JSON output format.

-
-
kubectl get -o json pod web-pod-13je7
-
-
-

List a pod identified by type and name specified in "pod.yaml" in JSON output format.

-
-
kubectl get -f pod.yaml -o json
-
+

replace

-

Return only the phase value of the specified pod.

+

Replace a pod using the data in pod.json.

-
kubectl get -o template pod/web-pod-13je7 --template={{.status.phase}}
+
kubectl replace -f ./pod.json
 
-

List all replication controllers and services together in ps output format.

+

Replace a pod based on the JSON passed into stdin.

-
kubectl get rc,services
+
cat pod.json | kubectl replace -f -
 
-

List one or more resources by their type and names.

+

Update a single-container pod's image version (tag) to v4

-
kubectl get rc/web service/frontend pods/web-pod-13je7
+
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
 
-

List all resources with different types.

+

Force replace, delete and then re-create the resource

-
kubectl get all
+
kubectl replace --force -f ./pod.json
 
-

Display one or many resources

-

Prints a table of the most important information about the specified resources. You can filter the list using a label selector and the --selector flag. If the desired resource type is namespaced you will only see results in your current namespace unless you pass --all-namespaces.

-

Uninitialized objects are not shown unless --include-uninitialized is passed.

-

By specifying the output as 'template' and providing a Go template as the value of the --template flag, you can filter the attributes of the fetched resources.

-

Valid resource types include:

-
    -
  • all
  • -
  • certificatesigningrequests (aka 'csr')
  • -
  • clusterrolebindings
  • -
  • clusterroles
  • -
  • componentstatuses (aka 'cs')
  • -
  • configmaps (aka 'cm')
  • -
  • controllerrevisions
  • -
  • cronjobs
  • -
  • customresourcedefinition (aka 'crd')
  • -
  • daemonsets (aka 'ds')
  • -
  • deployments (aka 'deploy')
  • -
  • endpoints (aka 'ep')
  • -
  • events (aka 'ev')
  • -
  • horizontalpodautoscalers (aka 'hpa')
  • -
  • ingresses (aka 'ing')
  • -
  • jobs
  • -
  • limitranges (aka 'limits')
  • -
  • namespaces (aka 'ns')
  • -
  • networkpolicies (aka 'netpol')
  • -
  • nodes (aka 'no')
  • -
  • persistentvolumeclaims (aka 'pvc')
  • -
  • persistentvolumes (aka 'pv')
  • -
  • poddisruptionbudgets (aka 'pdb')
  • -
  • podpreset
  • -
  • pods (aka 'po')
  • -
  • podsecuritypolicies (aka 'psp')
  • -
  • podtemplates
  • -
  • replicasets (aka 'rs')
  • -
  • replicationcontrollers (aka 'rc')
  • -
  • resourcequotas (aka 'quota')
  • -
  • rolebindings
  • -
  • roles
  • -
  • secrets
  • -
  • serviceaccounts (aka 'sa')
  • -
  • services (aka 'svc')
  • -
  • statefulsets (aka 'sts')
  • -
  • storageclasses (aka 'sc')
  • -
+

Replace a resource by filename or stdin.

+

JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by

+

$ kubectl get TYPE NAME -o yaml

+

Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.

Usage

-

$ get [(-o|--output=)json|yaml|wide|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=...] (TYPE [NAME | -l label] | TYPE/NAME ...) [flags]

+

$ replace -f FILENAME

Flags

@@ -3997,76 +3581,28 @@

Flags

- - - - - - - + - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - + - + - - - - - - - + - + - - + + @@ -4075,120 +3611,73 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - + - - + - + + - + - - - - - - - + - + - +
all-namespacesfalseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
allow-missing-template-keyscascade trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
chunk-size500Return large lists in chunks rather than all at once. Pass 0 to disable. This flag is beta and may change in the future.
experimental-server-printfalseIf true, have the server return the appropriate table output. Supports extension APIs and CRD. Experimental.
exportfalseIf true, use 'export' for the resources. Exported resources are stripped of cluster-specific information.
field-selectorSelector (field query) to filter on, supports '=', '==', and '!='.(e.g. --field-selector key1=value1,key2=value2). The server only supports a limited number of field queries per type. If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.
filename f []Filename, directory, or URL to files identifying the resource to get from a server.
ignore-not-foundfalseIf the requested object does not exist the command will return exit code 0.
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true] to use to replace the resource.
include-uninitializedforce falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
label-columnsL[]Accepts a comma separated list of labels that are going to be presented as columns. Names are case-sensitive. You can also use multiple flag options like -L label1 -L label2... Only used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
no-headersgrace-period falseWhen using the default or custom-column output format, don't print headers (default print headers). -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
rawRaw URI to request from the server. Uses the transport specified by the kubeconfig file.
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-kindfalseIf present, list the resource type for the requested object(s).
show-labelssave-config falseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
templatetimeout Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. 0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
use-openapi-print-columnsvalidate trueIf true, use x-kubernetes-print-column metadata (if present) from the OpenAPI schema for displaying a resource.
watchwfalseAfter listing/getting the requested object, watch for changes. Uninitialized objects are excluded if no object name is provided. If true, use a schema to validate the input before sending it
watch-onlywait falseWatch for changes to the requested object(s), without listing/getting first. If true, wait for resources to be gone before returning. This waits for finalizers.

-

label

+

rollout

-

Update pod 'foo' with the label 'unhealthy' and the value 'true'.

+

Rollback to the previous deployment

-
kubectl label pods foo unhealthy=true
+
kubectl rollout undo deployment/abc
 
-

Update pod 'foo' with the label 'status' and the value 'unhealthy', overwriting any existing value.

+

Check the rollout status of a daemonset

-
kubectl label --overwrite pods foo status=unhealthy
-
-
-

Update all pods in the namespace

-
-
kubectl label pods --all status=unhealthy
-
-
-

Update a pod identified by the type and name in "pod.json"

-
-
kubectl label -f pod.json status=unhealthy
+
kubectl rollout status daemonset/foo
 
+

Manage the rollout of a resource.

+

Valid resource types include:

+
    +
  • deployments
  • +
  • daemonsets
  • +
  • statefulsets
  • +
+

Usage

+

$ rollout SUBCOMMAND

+
+

history

-

Update pod 'foo' only if the resource is unchanged from version 1.

+

View the rollout history of a deployment

-
kubectl label pods foo status=unhealthy --resource-version=1
+
kubectl rollout history deployment/abc
 
-

Update pod 'foo' by removing a label named 'bar' if it exists. # Does not require the --overwrite flag.

+

View the details of daemonset revision 3

-
kubectl label pods foo bar-
+
kubectl rollout history daemonset/abc --revision=3
 
-

Update the labels on a resource.

-
    -
  • A label key and value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters each.
  • -
  • Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app
  • -
  • If --overwrite is true, then existing labels can be overwritten, otherwise attempting to overwrite a label will result in an error.
  • -
  • If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used.
  • -
+

View previous rollout revisions and configurations.

Usage

-

$ label [--overwrite] (-f FILENAME | TYPE NAME) KEY_1=VAL_1 ... KEY_N=VAL_N [--resource-version=version]

+

$ history (TYPE NAME | TYPE/NAME) [flags]

Flags

@@ -4201,82 +3690,88 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - + + - + - + - - + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f []Filename, directory, or URL to files identifying the resource to update the labels
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true]
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. Filename, directory, or URL to files identifying the resource to get from a server.
listrecursiveR falseIf true, display the labels for a given resource. Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
localrevision falseIf true, label will NOT contact api-server but run locally. 0See the details, including podTemplate of the revision specified
+
+

pause

+
+

Mark the nginx deployment as paused. Any current state of # the deployment will continue its function, new updates to the deployment will not # have an effect as long as the deployment is paused.

+
+
kubectl rollout pause deployment/nginx
+
+

Mark the provided resource as paused

+

Paused resources will not be reconciled by a controller. Use "kubectl rollout resume" to resume a paused resource. Currently only deployments support being paused.

+

Usage

+

$ pause RESOURCE

+

Flags

+ + - - - - + + + + + + - - - - + + + + - - - - + + + + + +
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers). NameShorthandDefaultUsage
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. filenamef[]Filename, directory, or URL to files identifying the resource to get from a server.
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
+
+

resume

+
+

Resume an already paused deployment

+
+
kubectl rollout resume deployment/nginx
+
+

Resume a paused resource

+

Paused resources will not be reconciled by a controller. By resuming a resource, we allow it to be reconciled again. Currently only deployments support being resumed.

+

Usage

+

$ resume RESOURCE

+

Flags

+ + - - - - + + + + + + - - - - + + + + @@ -4284,76 +3779,76 @@

Flags

+ +
overwritefalseIf true, allow labels to be overwritten, otherwise reject label updates that overwrite existing labels. NameShorthandDefaultUsage
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. filenamef[]Filename, directory, or URL to files identifying the resource to get from a server.
recursive false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
+
+

status

+
+

Watch the rollout status of a deployment

+
+
kubectl rollout status deployment/nginx
+
+

Show the status of the rollout.

+

By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for.

+

Usage

+

$ status (TYPE NAME | TYPE/NAME) [flags]

+

Flags

+ + - - - - - - - - - - + + + + + + - - - - + + + + - - + + - + - - + - + + - - - - + + + +
resource-versionIf non-empty, the labels update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
selectorlSelector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2). NameShorthandDefaultUsage
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) filenamef[]Filename, directory, or URL to files identifying the resource to get from a server.
show-labelsrecursiveR falseWhen printing, show all labels as the last column (default hide labels column) Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
sort-byrevision If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. 0Pin to a specific revision for showing its status. Defaults to 0 (last revision).
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. watchwtrueWatch the status of the rollout until it's done.

-

patch

-
-

Partially update a node using a strategic merge patch. Specify the patch as JSON.

-
-
kubectl patch node k8s-node-1 -p '{"spec":{"unschedulable":true}}'
-
-
-

Partially update a node using a strategic merge patch. Specify the patch as YAML.

-
-
kubectl patch node k8s-node-1 -p $'spec:\n unschedulable: true'
-
+

undo

-

Partially update a node identified by the type and name specified in "node.json" using strategic merge patch.

+

Rollback to the previous deployment

-
kubectl patch -f node.json -p '{"spec":{"unschedulable":true}}'
+
kubectl rollout undo deployment/abc
 
-

Update a container's image; spec.containers[*].name is required because it's a merge key.

+

Rollback to daemonset revision 3

-
kubectl patch pod valid-pod -p '{"spec":{"containers":[{"name":"kubernetes-serve-hostname","image":"new image"}]}}'
+
kubectl rollout undo daemonset/abc --to-revision=3
 
-

Update a container's image using a json patch with positional arrays.

+

Rollback to the previous deployment with dry-run

-
kubectl patch pod valid-pod --type='json' -p='[{"op": "replace", "path": "/spec/containers/0/image", "value":"new image"}]'
+
kubectl rollout undo --dry-run=true deployment/abc
 
-

Update field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch.

-

JSON and YAML formats are accepted.

-

Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.

+

Rollback to a previous rollout.

Usage

-

$ patch (-f FILENAME | TYPE NAME) -p PATCH

+

$ undo (TYPE NAME | TYPE/NAME) [flags]

Flags

@@ -4366,58 +3861,16 @@

Flags

- + - - + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -4426,65 +3879,45 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - + - - + +
allow-missing-template-keysdry-run trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. falseIf true, only print the object that would be sent, without sending it.
filename f []Filename, directory, or URL to files identifying the resource to update
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true]
localfalseIf true, patch will operate on the content of the file, not the server-side resource.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
patchpThe patch to be applied to the resource JSON file.
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. Filename, directory, or URL to files identifying the resource to get from a server.
recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
typeto-revision strategicThe type of patch being provided; one of [json merge strategic] 0The revision to rollback to. Default to 0 (last revision).

-

replace

+

scale

-

Replace a pod using the data in pod.json.

+

Scale a replicaset named 'foo' to 3.

-
kubectl replace -f ./pod.json
+
kubectl scale --replicas=3 rs/foo
 
-

Replace a pod based on the JSON passed into stdin.

+

Scale a resource identified by type and name specified in "foo.yaml" to 3.

-
cat pod.json | kubectl replace -f -
+
kubectl scale --replicas=3 -f foo.yaml
 
-

Update a single-container pod's image version (tag) to v4

+

If the deployment named mysql's current size is 2, scale mysql to 3.

-
kubectl get pod mypod -o yaml | sed 's/\(image: myimage\):.*$/\1:v4/' | kubectl replace -f -
+
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
 
-

Force replace, delete and then re-create the resource

+

Scale multiple replication controllers.

-
kubectl replace --force -f ./pod.json
+
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
 
-

Replace a resource by filename or stdin.

-

JSON and YAML formats are accepted. If replacing an existing resource, the complete resource spec must be provided. This can be obtained by

-

$ kubectl get TYPE NAME -o yaml

-

Please refer to the models in https://htmlpreview.github.io/?https://github.com/kubernetes/kubernetes/blob/HEAD/docs/api-reference/v1/definitions.html to find if a field is mutable.

+
+

Scale statefulset named 'web' to 3.

+
+
kubectl scale --replicas=3 statefulset/web
+
+

Set a new size for a Deployment, ReplicaSet, Replication Controller, or StatefulSet.

+

Scale also allows users to specify one or more preconditions for the scale action.

+

If --current-replicas or --resource-version is specified, it is validated before the scale is attempted, and it is guaranteed that the precondition holds true when the scale is sent to the server.

Usage

-

$ replace -f FILENAME

+

$ scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)

Flags

@@ -4497,40 +3930,28 @@

Flags

- - - - - - - - - - - - - + - + - + - + - - - - + + + + - + @@ -4545,57 +3966,101 @@

Flags

- + - - + + - + - - + + - + + - - + + + + + + +
cascadefalseOnly relevant during a force replace. If true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController).
filenamef[]Filename, directory, or URL to files to use to replace the resource.
forceall falseDelete and re-create the specified resource Select all resources in the namespace of the specified resource types
grace-periodcurrent-replicas -1Only relevant during a force replace. Period of time in seconds given to the old resource to terminate gracefully. Ignored if negative. Precondition for current size. Requires that the current size of the resource match this value in order to scale.
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true] filenamef[]Filename, directory, or URL to files identifying the resource to set a new size
output o Output mode. Use "-o name" for shorter output (resource/name). Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
record Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
save-configreplicas falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future. 0The new desired number of replicas. Required.
timeoutresource-version 0sOnly relevant during a force replace. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). Precondition for resource version. Requires that the current resource version match this value in order to scale.
validateselectorl trueIf true, use a schema to validate the input before sending it Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
timeout0sThe length of time to wait before giving up on a scale operation, zero means don't wait. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).

-

rolling-update

+

set

+

Configure application resources

+

These commands help you make changes to existing application resources.

+

Usage

+

$ set SUBCOMMAND

+
+

env

-

Update pods of frontend-v1 using new replication controller data in frontend-v2.json.

+

Update deployment 'registry' with a new environment variable

-
kubectl rolling-update frontend-v1 -f frontend-v2.json
+
kubectl set env deployment/registry STORAGE_DIR=/local
 
-

Update pods of frontend-v1 using JSON data passed into stdin.

+

List the environment variables defined on a deployments 'sample-build'

-
cat frontend-v2.json | kubectl rolling-update frontend-v1 -f -
+
kubectl set env deployment/sample-build --list
 
-

Update the pods of frontend-v1 to frontend-v2 by just changing the image, and switching the # name of the replication controller.

+

List the environment variables defined on all pods

-
kubectl rolling-update frontend-v1 frontend-v2 --image=image:v2
+
kubectl set env pods --all --list
 
-

Update the pods of frontend by just changing the image, and keeping the old name.

+

Output modified deployment in YAML, and does not alter the object on the server

-
kubectl rolling-update frontend --image=image:v2
+
kubectl set env deployment/sample-build STORAGE_DIR=/data -o yaml
 
-

Abort and reverse an existing rollout in progress (from frontend-v1 to frontend-v2).

+

Update all containers in all replication controllers in the project to have ENV=prod

-
kubectl rolling-update frontend-v1 frontend-v2 --rollback
+
kubectl set env rc --all ENV=prod
 
-

Perform a rolling update of the given ReplicationController.

-

Replaces the specified replication controller with a new replication controller by updating one pod at a time to use the new PodTemplate. The new-controller.json must specify the same namespace as the existing replication controller and overwrite at least one (common) label in its replicaSelector.

-

! http://kubernetes.io/images/docs/kubectl_rollingupdate.svg

+
+

Import environment from a secret

+
+
kubectl set env --from=secret/mysecret deployment/myapp
+
+
+

Import environment from a config map with a prefix

+
+
kubectl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp
+
+
+

Import specific keys from a config map

+
+
kubectl set env --keys=my-example-key --from=configmap/myconfigmap deployment/myapp
+
+
+

Remove the environment variable ENV from container 'c1' in all deployment configs

+
+
kubectl set env deployments --all --containers="c1" ENV-
+
+
+

Remove the environment variable ENV from a deployment definition on disk and # update the deployment config on the server

+
+
kubectl set env -f deploy.json ENV-
+
+
+

Set some of the local shell environment into a deployment config on the server

+
+
env | grep RAILS_ | kubectl set env -e - deployment/registry
+
+

Update environment variables on a pod template.

+

List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (within replication controllers or deployment configurations). View or modify the environment variable definitions on all containers in the specified pods or pod templates, or just those that match a wildcard.

+

If "--env -" is passed, environment variables can be read from STDIN using the standard env syntax.

+

Possible resources include (case insensitive):

+

pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs)

Usage

-

$ rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)

+

$ env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N

Flags

@@ -4608,22 +4073,16 @@

Flags

- - - - - - - - + - + + - - - - + + + + @@ -4632,34 +4091,40 @@

Flags

+ + + + + + - + - + - + - - + - + + - + - - + + - + - + @@ -4668,103 +4133,64 @@

Flags

- - - - - - - - - - - - - + - - - - - - - - - - - - - - - - - - - + - + - + - - - - + + + + - + - - + + - + + - - +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
containerall Container name which will have its image upgraded. Only relevant when --image is specified, ignored otherwise. Required when using --image on a multi-container pod falseIf true, select all resources in the namespace of the specified resource types
deployment-label-keydeploymentThe key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise containersc*The names of containers in the selected pod templates to change - may use wildcards
dry-run If true, only print the object that would be sent, without sending it.
enve[]Specify a key-value pair for an environment variable to set into each container.
filename f []Filename or URL to file to use to create the new replication controller. Filename, directory, or URL to files the resource to update the env
imagefrom Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f The name of a resource from which to inject environment variables
image-pull-policykeys Explicit policy for when to pull container images. Required when --image is same as existing image, ignored otherwise. []Comma-separated list of keys to import from specified resource
include-extended-apislist trueIf true, include definitions of new APIs via calls to the API server. [default true] falseIf true, display the environment and any changes in the standard format. this flag will removed when we have kubectl view env.
no-headerslocal falseWhen using the default or custom-column output format, don't print headers (default print headers). If true, set env will NOT contact api-server but run locally.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
poll-interval3sTime delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
rollbackoverwrite falseIf true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout
show-alla trueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. If true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment.
templateprefix Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Prefix to append to variable names
timeout5m0sMax time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
update-periodresolve 1m0sTime to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h". falseIf true, show secret or configmap references when listing variables
validateselectorl trueIf true, use a schema to validate the input before sending it Selector (label query) to filter on

-

rollout

+

image

-

Rollback to the previous deployment

+

Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox'.

-
kubectl rollout undo deployment/abc
+
kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
 
-

Check the rollout status of a daemonset

+

Update all deployments' and rc's nginx container's image to 'nginx:1.9.1'

-
kubectl rollout status daemonset/foo
+
kubectl set image deployments,rc nginx=nginx:1.9.1 --all
 
-

Manage the rollout of a resource.

-

Valid resource types include:

-
    -
  • deployments
  • -
  • daemonsets
  • -
  • statefulsets
  • -
-

Usage

-

$ rollout SUBCOMMAND

-
-

history

-

View the rollout history of a deployment

+

Update image of all containers of daemonset abc to 'nginx:1.9.1'

-
kubectl rollout history deployment/abc
+
kubectl set image daemonset abc *=nginx:1.9.1
 
-

View the details of daemonset revision 3

+

Print result (in yaml format) of updating nginx container image from local file, without hitting the server

-
kubectl rollout history daemonset/abc --revision=3
+
kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml
 
-

View previous rollout revisions and configurations.

+

Update existing container image(s) of resources.

+

Possible resources include (case insensitive):

+

pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), replicaset (rs)

Usage

-

$ history (TYPE NAME | TYPE/NAME) [flags]

+

$ image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N

Flags

@@ -4777,36 +4203,88 @@

Flags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - + + - - +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to get from a server.
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
localfalseIf true, set image will NOT contact api-server but run locally.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
revisionselectorl 0See the details, including podTemplate of the revision specified Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)

-

pause

+

resources

-

Mark the nginx deployment as paused. Any current state of # the deployment will continue its function, new updates to the deployment will not # have an effect as long as the deployment is paused.

+

Set a deployments nginx container cpu limits to "200m" and memory to "512Mi"

-
kubectl rollout pause deployment/nginx
+
kubectl set resources deployment nginx -c=nginx --limits=cpu=200m,memory=512Mi
 
-

Mark the provided resource as paused

-

Paused resources will not be reconciled by a controller. Use "kubectl rollout resume" to resume a paused resource. Currently only deployments support being paused.

+
+

Set the resource request and limits for all containers in nginx

+
+
kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
+
+
+

Remove the resource requests for resources on containers in nginx

+
+
kubectl set resources deployment nginx --limits=cpu=0,memory=0 --requests=cpu=0,memory=0
+
+
+

Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server

+
+
kubectl set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --local -o yaml
+
+

Specify compute resource requirements (cpu, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to its specified limits.

+

for each compute resource, if a limit is specified and a request is omitted, the request will default to the limit.

+

Possible resources include (case insensitive): Use "kubectl api-resources" for a complete list of supported resources..

Usage

-

$ pause RESOURCE

+

$ resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --requests=REQUESTS]

Flags

@@ -4819,30 +4297,91 @@

Flags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
containersc*The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to get from a server.
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
limitsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.
localfalseIf true, set resources will NOT contact api-server but run locally.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
requestsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.
selectorlSelector (label query) to filter on, not including uninitialized ones,supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)

-

resume

+

selector

-

Resume an already paused deployment

+

set the labels and selector before creating a deployment/service pair.

-
kubectl rollout resume deployment/nginx
+
kubectl create service clusterip my-svc --clusterip="None" -o yaml --dry-run | kubectl set selector --local -f - 'environment=qa' -o yaml | kubectl create -f -
+kubectl create deployment my-dep -o yaml --dry-run | kubectl label --local -f - environment=qa -o yaml | kubectl create -f -
 
-

Resume a paused resource

-

Paused resources will not be reconciled by a controller. By resuming a resource, we allow it to be reconciled again. Currently only deployments support being resumed.

+

Set the selector on a resource. Note that the new selector will overwrite the old selector if the resource had one prior to the invocation of 'set selector'.

+

A selector must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. Note: currently selectors can only be set on Service objects.

Usage

-

$ resume RESOURCE

+

$ selector (-f FILENAME | TYPE NAME) EXPRESSIONS [--resource-version=version]

Flags

@@ -4855,30 +4394,78 @@

Flags

+ + + + + + + + + + + + - + - - + + - + - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
allfalseSelect all resources in the namespace of the specified resource types
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f []Filename, directory, or URL to files identifying the resource to get from a server. identifying the resource.
recursiveRinclude-uninitialized falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
localfalseIf true, annotation will NOT contact api-server but run locally.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRtrueProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
resource-versionIf non-empty, the selectors update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.

-

status

+

serviceaccount

-

Watch the rollout status of a deployment

+

Set Deployment nginx-deployment's ServiceAccount to serviceaccount1

-
kubectl rollout status deployment/nginx
+
kubectl set serviceaccount deployment nginx-deployment serviceaccount1
 
-

Show the status of the rollout.

-

By default 'rollout status' will watch the status of the latest rollout until it's done. If you don't want to wait for the rollout to finish then you can use --watch=false. Note that if a new rollout starts in-between, then 'rollout status' will continue watching the latest revision. If you want to pin to a specific revision and abort if it is rolled over by another revision, use --revision=N where N is the revision you need to watch for.

+
+

Print the result (in yaml format) of updated nginx deployment with serviceaccount from local file, without hitting apiserver

+
+
kubectl set sa -f nginx-deployment.yaml serviceaccount1 --local --dry-run -o yaml
+
+

Update ServiceAccount of pod template resources.

+

Possible resources (case insensitive) can be:

+

replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset

Usage

-

$ status (TYPE NAME | TYPE/NAME) [flags]

+

$ serviceaccount (-f FILENAME | TYPE NAME) SERVICE_ACCOUNT

Flags

@@ -4891,51 +4478,75 @@

Flags

+ + + + + + + + + + + + - - + + - + - + - - + + - - - - + + + + + + + + + + + + + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f [] Filename, directory, or URL to files identifying the resource to get from a server.
recursiveRinclude-uninitialized falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
revisionlocal 0Pin to a specific revision for showing its status. Defaults to 0 (last revision). falseIf true, set serviceaccount will NOT contact api-server but run locally.
watchwtrueWatch the status of the rollout until it's done. outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.

-

undo

+

subject

-

Rollback to the previous deployment

+

Update a ClusterRoleBinding for serviceaccount1

-
kubectl rollout undo deployment/abc
+
kubectl set subject clusterrolebinding admin --serviceaccount=namespace:serviceaccount1
 
-

Rollback to daemonset revision 3

+

Update a RoleBinding for user1, user2, and group1

-
kubectl rollout undo daemonset/abc --to-revision=3
+
kubectl set subject rolebinding admin --user=user1 --user=user2 --group=group1
 
-

Rollback to the previous deployment with dry-run

+

Print the result (in yaml format) of updating rolebinding subjects from a local, without hitting the server

-
kubectl rollout undo --dry-run=true deployment/abc
+
kubectl create rolebinding admin --role=admin --user=admin -o yaml --dry-run | kubectl set subject --local -f - --user=foo -o yaml
 
-

Rollback to a previous rollout.

+

Update User, Group or ServiceAccount in a RoleBinding/ClusterRoleBinding.

Usage

-

$ undo (TYPE NAME | TYPE/NAME) [flags]

+

$ subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

Flags

@@ -4948,6 +4559,12 @@

Flags

+ + + + + + @@ -4957,7 +4574,31 @@

Flags

- + + + + + + + + + + + + + + + + + + + + + + + + + @@ -4966,45 +4607,23 @@

Flags

- + + - - + + + + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
dry-run false filename f []Filename, directory, or URL to files identifying the resource to get from a server. Filename, directory, or URL to files the resource to update the subjects
group[]Groups to bind to the role
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
localfalseIf true, set subject will NOT contact api-server but run locally.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recursive Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
to-revisionselectorl 0The revision to rollback to. Default to 0 (last revision). Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
serviceaccount[]Service accounts to bind to the role

-

scale

-
-

Scale a replicaset named 'foo' to 3.

-
-
kubectl scale --replicas=3 rs/foo
-
-
-

Scale a resource identified by type and name specified in "foo.yaml" to 3.

-
-
kubectl scale --replicas=3 -f foo.yaml
-
-
-

If the deployment named mysql's current size is 2, scale mysql to 3.

-
-
kubectl scale --current-replicas=2 --replicas=3 deployment/mysql
-
-
-

Scale multiple replication controllers.

-
-
kubectl scale --replicas=5 rc/foo rc/bar rc/baz
-
-
-

Scale statefulset named 'web' to 3.

-
-
kubectl scale --replicas=3 statefulset/web
-
-

Set a new size for a Deployment, ReplicaSet, Replication Controller, or StatefulSet.

-

Scale also allows users to specify one or more preconditions for the scale action.

-

If --current-replicas or --resource-version is specified, it is validated before the scale is attempted, and it is guaranteed that the precondition holds true when the scale is sent to the server.

+

wait

Usage

-

$ scale [--resource-version=version] [--current-replicas=count] --replicas=COUNT (-f FILENAME | TYPE NAME)

+

$ wait resource.group/name [--for=delete|--for condition=available]

Flags

@@ -5017,60 +4636,36 @@

Flags

- + - - - - - - - + - + - + - - + + - - - - - - - + - + - - - - - - - - - - - - @@ -5079,76 +4674,122 @@

Flags

- - + +
allall-namespaces falseSelect all resources in the namespace of the specified resource types
current-replicas-1Precondition for current size. Requires that the current size of the resource match this value in order to scale. If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
filename f []Filename, directory, or URL to files identifying the resource to set a new size identifying the resource.
include-extended-apisfor trueIf true, include definitions of new APIs via calls to the API server. [default true] The condition to wait on: [delete|condition=condition-name].
output o Output mode. Use "-o name" for shorter output (resource/name).
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recursive Rfalsetrue Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
replicas-1The new desired number of replicas. Required.
resource-versionPrecondition for resource version. Requires that the current resource version match this value in order to scale.
selector l
timeout 0sThe length of time to wait before giving up on a scale operation, zero means don't wait. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h). 30sThe length of time to wait before giving up. Zero means check once and don't wait, negative means wait for a week.
+

WORKING WITH APPS

+

This section contains commands for inspecting and debugging your +applications.

+
    +
  • logs will print the logs from the specified pod + container.
  • +
  • exec can be used to get an interactive shell on a pod + container.
  • +
  • describe will print debug information about the given resource.
  • +

-

set

-

Configure application resources

-

These commands help you make changes to existing application resources.

-

Usage

-

$ set SUBCOMMAND

-
-

env

+

attach

-

Update deployment 'registry' with a new environment variable

+

Get output from running pod 123456-7890, using the first container by default

-
kubectl set env deployment/registry STORAGE_DIR=/local
+
kubectl attach 123456-7890
 
-

List the environment variables defined on a deployments 'sample-build'

+

Get output from ruby-container from pod 123456-7890

-
kubectl set env deployment/sample-build --list
+
kubectl attach 123456-7890 -c ruby-container
 
-

List the environment variables defined on all pods

+

Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client

-
kubectl set env pods --all --list
+
kubectl attach 123456-7890 -c ruby-container -i -t
 
-

Output modified deployment in YAML, and does not alter the object on the server

+

Get output from the first pod of a ReplicaSet named nginx

-
kubectl set env deployment/sample-build STORAGE_DIR=/data -o yaml
+
kubectl attach rs/nginx
 
-
-

Update all containers in all replication controllers in the project to have ENV=prod

+

Attach to a process that is already running inside an existing container.

+

Usage

+

$ attach (POD | TYPE/NAME) -c CONTAINER

+

Flags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameShorthandDefaultUsage
containercContainer name. If omitted, the first container in the pod will be chosen
pod-running-timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
stdinifalsePass stdin to the container
ttytfalseStdin is a TTY
+
+

auth

+

Inspect authorization

+

Usage

+

$ auth

+
+

can-i

+
+

Check to see if I can create pods in any namespace

-
kubectl set env rc --all ENV=prod
+
kubectl auth can-i create pods --all-namespaces
 
-

Import environment from a secret

+

Check to see if I can list deployments in my current namespace

-
kubectl set env --from=secret/mysecret deployment/myapp
+
kubectl auth can-i list deployments.extensions
 
-

Import environment from a config map with a prefix

+

Check to see if I can do everything in my current namespace ("*" means all)

-
kubectl set env --from=configmap/myconfigmap --prefix=MYSQL_ deployment/myapp
+
kubectl auth can-i '*' '*'
 
-

Remove the environment variable ENV from container 'c1' in all deployment configs

+

Check to see if I can get the job named "bar" in namespace "foo"

-
kubectl set env deployments --all --containers="c1" ENV-
+
kubectl auth can-i list jobs.batch/bar -n foo
 
-

Remove the environment variable ENV from a deployment definition on disk and # update the deployment config on the server

+

Check to see if I can read pod logs

-
kubectl set env -f deploy.json ENV-
+
kubectl auth can-i get pods --subresource=log
 
-

Set some of the local shell environment into a deployment config on the server

+

Check to see if I can access the URL /logs/

-
env | grep RAILS_ | kubectl set env -e - deployment/registry
+
kubectl auth can-i get /logs/
 
-

Update environment variables on a pod template.

-

List environment variable definitions in one or more pods, pod templates. Add, update, or remove container environment variable definitions in one or more pod templates (within replication controllers or deployment configurations). View or modify the environment variable definitions on all containers in the specified pods or pod templates, or just those that match a wildcard.

-

If "--env -" is passed, environment variables can be read from STDIN using the standard env syntax.

-

Possible resources include (case insensitive):

-

pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs)

+

Check whether an action is allowed.

+

VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL starts with "/". NAME is the name of a particular Kubernetes resource.

Usage

-

$ env RESOURCE/NAME KEY_1=VAL_1 ... KEY_N=VAL_N

+

$ can-i VERB [TYPE | TYPE/NAME | NONRESOURCEURL]

Flags

@@ -5161,64 +4802,58 @@

Flags

- + - - - - - - - - - - - - - + - - + + - - - - - - - - - - - - - + - + - + + +
allall-namespaces falseIf true, select all resources in the namespace of the specified resource types
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
containersc*The names of containers in the selected pod templates to change - may use wildcards If true, check the specified action in all namespaces.
dry-runquietq falseIf true, only print the object that would be sent, without sending it.
enve[]Specify a key-value pair for an environment variable to set into each container.
filenamef[]Filename, directory, or URL to files the resource to update the env If true, suppress output and just return the exit code.
fromsubresource The name of a resource from which to inject environment variables SubResource such as pod/log or deployment/scale
+
+

reconcile

+
+

Reconcile rbac resources from a file

+
+
kubectl auth reconcile -f my-rbac-rules.yaml
+
+

Reconciles rules for RBAC Role, RoleBinding, ClusterRole, and ClusterRole binding objects.

+

This is preferred to 'apply' for RBAC resources so that proper rule coverage checks are done.

+

Usage

+

$ reconcile -f FILENAME

+

Flags

+ + - - - - + + + + + + - + - + - - - - + + + + @@ -5227,94 +4862,38 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
listfalseIf true, display the environment and any changes in the standard format. this flag will removed when we have kubectl view env. NameShorthandDefaultUsage
localdry-run falseIf true, set env will NOT contact api-server but run locally. If true, display results but do not submit changes
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers). filenamef[]Filename, directory, or URL to files identifying the resource to reconcile.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
overwritetrueIf true, allow environment to be overwritten, otherwise reject updates that overwrite existing environment.
prefixPrefix to append to variable names
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
resolvefalseIf true, show secret or configmap references when listing variables
selectorlSelector (label query) to filter on
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

-

image

+

cp

-

Set a deployment's nginx container image to 'nginx:1.9.1', and its busybox container image to 'busybox'.

+

!!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace

-
kubectl set image deployment/nginx busybox=busybox nginx=nginx:1.9.1
+
kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
 
-

Update all deployments' and rc's nginx container's image to 'nginx:1.9.1'

+

Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container

-
kubectl set image deployments,rc nginx=nginx:1.9.1 --all
+
kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
 
-

Update image of all containers of daemonset abc to 'nginx:1.9.1'

+

Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace

-
kubectl set image daemonset abc *=nginx:1.9.1
+
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
 
-

Print result (in yaml format) of updating nginx container image from local file, without hitting the server

+

Copy /tmp/foo from a remote pod to /tmp/bar locally

-
kubectl set image -f path/to/file.yaml nginx=nginx:1.9.1 --local -o yaml
+
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar
 
-

Update existing container image(s) of resources.

-

Possible resources include (case insensitive):

-

pod (po), replicationcontroller (rc), deployment (deploy), daemonset (ds), replicaset (rs)

+

Copy files and directories to and from containers.

Usage

-

$ image (-f FILENAME | TYPE NAME) CONTAINER_NAME_1=CONTAINER_IMAGE_1 ... CONTAINER_NAME_N=CONTAINER_IMAGE_N

+

$ cp <file-spec-src> <file-spec-dest>

Flags

@@ -5327,64 +4906,80 @@

Flags

- - - - - - - - - - - - - + + - - - - - - - - - - - - - - + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runcontainerc falseIf true, only print the object that would be sent, without sending it.
filenamef[]Filename, directory, or URL to files identifying the resource to get from a server.
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. Container name. If omitted, the first container in the pod will be chosen
+
+

describe

+
+

Describe a node

+
+
kubectl describe nodes kubernetes-node-emt8.c.myproject.internal
+
+
+

Describe a pod

+
+
kubectl describe pods/nginx
+
+
+

Describe a pod identified by type and name in "pod.json"

+
+
kubectl describe -f pod.json
+
+
+

Describe all pods

+
+
kubectl describe pods
+
+
+

Describe pods by label name=myLabel

+
+
kubectl describe po -l name=myLabel
+
+
+

Describe all pods managed by the 'frontend' replication controller (rc-created pods # get the name of the rc as a prefix in the pod the name).

+
+
kubectl describe pods frontend
+
+

Show details of a specific resource or group of resources

+

Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provide a name prefix, or label selector. For example:

+

$ kubectl describe TYPE NAME_PREFIX

+

will first check for an exact match on TYPE and NAME PREFIX. If no such resource exists, it will output details for every resource that has a name prefixed with NAME PREFIX.

+

Use "kubectl api-resources" for a complete list of supported resources.

+

Usage

+

$ describe (-f FILENAME | TYPE [NAME_PREFIX | -l label] | TYPE/NAME)

+

Flags

+ + - - - - + + + + + + - + - - - - - - - + - - - - + + + + - + - + @@ -5396,61 +4991,128 @@

Flags

- + - - + + - + + +
localfalseIf true, set image will NOT contact api-server but run locally. NameShorthandDefaultUsage
no-headersall-namespaces falseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). filenamef[]Filename, directory, or URL to files containing the resource to describe
recordinclude-uninitialized falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. If true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
recursive selector l Selector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allashow-events trueWhen printing, show all resources (default show all pods including terminated one.) If true, display events related to the described object.
+
+

exec

+
+

Get output from running 'date' from pod 123456-7890, using the first container by default

+
+
kubectl exec 123456-7890 date
+
+
+

Get output from running 'date' in ruby-container from pod 123456-7890

+
+
kubectl exec 123456-7890 -c ruby-container date
+
+
+

Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client

+
+
kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
+
+
+

List contents of /usr from the first container of pod 123456-7890 and sort by modification time. # If the command you want to execute in the pod has any flags in common (e.g. -i), # you must use two dashes (--) to separate your command's flags/arguments. # Also note, do not surround your command and its flags/arguments with quotes # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").

+
+
kubectl exec 123456-7890 -i -t -- ls -t /usr
+
+

Execute a command in a container.

+

Usage

+

$ exec POD [-c CONTAINER] -- COMMAND [args...]

+

Flags

+ + - - - - + + + + + + - - + + - + - - + + - + + + + + + + + + + + + +
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column) NameShorthandDefaultUsage
sort-bycontainerc If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Container name. If omitted, the first container in the pod will be chosen
templatepodp Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Pod name
stdinifalsePass stdin to the container
ttytfalseStdin is a TTY

-

resources

+

logs

-

Set a deployments nginx container cpu limits to "200m" and memory to "512Mi"

+

Return snapshot logs from pod nginx with only one container

-
kubectl set resources deployment nginx -c=nginx --limits=cpu=200m,memory=512Mi
+
kubectl logs nginx
 
-

Set the resource request and limits for all containers in nginx

+

Return snapshot logs from pod nginx with multi containers

-
kubectl set resources deployment nginx --limits=cpu=200m,memory=512Mi --requests=cpu=100m,memory=256Mi
+
kubectl logs nginx --all-containers=true
 
-

Remove the resource requests for resources on containers in nginx

+

Return snapshot logs from all containers in pods defined by label app=nginx

-
kubectl set resources deployment nginx --limits=cpu=0,memory=0 --requests=cpu=0,memory=0
+
kubectl logs -lapp=nginx --all-containers=true
 
-

Print the result (in yaml format) of updating nginx container limits from a local, without hitting the server

+

Return snapshot of previous terminated ruby container logs from pod web-1

-
kubectl set resources -f path/to/file.yaml --limits=cpu=200m,memory=512Mi --local -o yaml
+
kubectl logs -p -c ruby web-1
 
-

Specify compute resource requirements (cpu, memory) for any resource that defines a pod template. If a pod is successfully scheduled, it is guaranteed the amount of resource requested, but may burst up to its specified limits.

-

for each compute resource, if a limit is specified and a request is omitted, the request will default to the limit.

-

Possible resources include (case insensitive): replicationcontroller, deployment, daemonset, job, replicaset.

+
+

Begin streaming the logs of the ruby container in pod web-1

+
+
kubectl logs -f -c ruby web-1
+
+
+

Display only the most recent 20 lines of output in pod nginx

+
+
kubectl logs --tail=20 nginx
+
+
+

Show all logs from pod nginx written in the last hour

+
+
kubectl logs --since=1h nginx
+
+
+

Return snapshot logs from first container of a job named hello

+
+
kubectl logs job/hello
+
+
+

Return snapshot logs from container nginx-1 of a deployment named nginx

+
+
kubectl logs deployment/nginx -c nginx-1
+
+

Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.

Usage

-

$ resources (-f FILENAME | TYPE NAME) ([--limits=LIMITS & --requests=REQUESTS]

+

$ logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]

Flags

@@ -5463,133 +5125,160 @@

Flags

- + - - - - - - - + - + - - - - - - - + - + - - + + - + - + - - + - + + - + + + + + + + - + - + + - - + - - + - + + - + - + - - - - - - - - - - - - - - - - - - - - + - - - - - - - + + - + - + + +
allall-containers falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. Get all containers's logs in the pod(s).
containerscontainer c*The names of containers in the selected pod templates to change, all containers are selected by default - may use wildcards
dry-run falseIf true, only print the object that would be sent, without sending it. Print the logs of this container
filenamefollow f[]Filename, directory, or URL to files identifying the resource to get from a server. falseSpecify if the logs should be streamed.
include-uninitializedinteractive falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. If true, prompt the user for input when required.
limitslimit-bytes The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges. 0Maximum bytes of logs to return. Defaults to no limit.
localpod-running-timeout 20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
previousp falseIf true, set resources will NOT contact api-server but run locally. If true, print the logs for the previous instance of the container in a pod if it exists.
no-headersselectorl falseWhen using the default or custom-column output format, don't print headers (default print headers). Selector (label query) to filter on.
outputosince Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. 0sOnly return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used.
output-versionsince-time DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used.
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
requestsThe resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.
selectorltail Selector (label query) to filter on, not including uninitialized ones,supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) -1Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided.
show-labelstimestamps falseWhen printing, show all labels as the last column (default hide labels column) Include timestamps on each line in the log output
+
+

port-forward

+
+

Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod

+
+
kubectl port-forward pod/mypod 5000 6000
+
+
+

Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment

+
+
kubectl port-forward deployment/mydeployment 5000 6000
+
+
+

Listen on port 8888 locally, forwarding to 5000 in the pod

+
+
kubectl port-forward pod/mypod 8888:5000
+
+
+

Listen on a random port locally, forwarding to 5000 in the pod

+
+
kubectl port-forward pod/mypod :5000
+
+

Forward one or more local ports to a pod.

+

Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.

+

If there are multiple pods matching the criteria, a pod will be selected automatically. The forwarding session ends when the selected pod terminates, and rerun of the command is needed to resume forwarding.

+

Usage

+

$ port-forward TYPE/NAME [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]

+

Flags

+ + - - - - + + + + + + - - + - + +
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. NameShorthandDefaultUsage
templatepod-running-timeout Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. 1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running

-

selector

+

proxy

-

set the labels and selector before creating a deployment/service pair.

+

To proxy all of the kubernetes api and nothing else, use:

-
kubectl create service clusterip my-svc --clusterip="None" -o yaml --dry-run | kubectl set selector --local -f - 'environment=qa' -o yaml | kubectl create -f -
-kubectl create deployment my-dep -o yaml --dry-run | kubectl label --local -f - environment=qa -o yaml | kubectl create -f -
+
$ kubectl proxy --api-prefix=/
 
-

Set the selector on a resource. Note that the new selector will overwrite the old selector if the resource had one prior to the invocation of 'set selector'.

-

A selector must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters. If --resource-version is specified, then updates will use this resource version, otherwise the existing resource-version will be used. Note: currently selectors can only be set on Service objects.

+
+

To proxy only part of the kubernetes api and also some static files:

+
+
$ kubectl proxy --www=/my/files --www-prefix=/static/ --api-prefix=/api/
+
+
+

The above lets you 'curl localhost:8001/api/v1/pods'. # To proxy the entire kubernetes api at a different root, use:

+
+
$ kubectl proxy --api-prefix=/custom/
+
+
+

The above lets you 'curl localhost:8001/custom/api/v1/pods' # Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/

+
+
kubectl proxy --port=8011 --www=./local/www/
+
+
+

Run a proxy to kubernetes apiserver on an arbitrary local port. # The chosen port for the server will be output to stdout.

+
+
kubectl proxy --port=0
+
+
+

Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api # This makes e.g. the pods api available at localhost:8001/k8s-api/v1/pods/

+
+
kubectl proxy --api-prefix=/k8s-api
+
+

Creates a proxy server or application-level gateway between localhost and the Kubernetes API Server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote kubernetes API Server port, except for the path matching the static content path.

Usage

-

$ selector (-f FILENAME | TYPE NAME) EXPRESSIONS [--resource-version=version]

+

$ proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]

Flags

@@ -5602,120 +5291,96 @@

Flags

- - - - - - - + - - + + - + - - - - - - - - + + - + - - + + - + - - + + - + - - - - - - - + - - - - + + + + - + - - - - - - - - + + - - + - - - - - - - + + - + + - - + - - + + - + - - - - + + + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
allow-missing-template-keysaccept-hosts trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. ^localhost$,^127.0.0.1$,^[::1]$Regular expression for hosts that the proxy should accept.
dry-runaccept-paths falseIf true, only print the object that would be sent, without sending it.
filenamef[]Filename, directory, or URL to files the resource to update the selectors ^.*Regular expression for paths that the proxy should accept.
include-uninitializedaddress falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. 127.0.0.1The IP address on which to serve on.
localapi-prefix falseIf true, set selector will NOT contact api-server but run locally. /Prefix to serve the proxied API under.
no-headersdisable-filter falseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. If true, disable request filtering in the proxy. This is dangerous, and can leave you vulnerable to XSRF attacks, when used with an accessible port.
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). portp8001The port on which to run the proxy. Set to 0 to pick a random port.
recordreject-methods falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. ^$Regular expression for HTTP methods that the proxy should reject (example --reject-methods='POST,PUT,PATCH').
resource-versionreject-paths If non-empty, the selectors update will only succeed if this is the current resource-version for the object. Only valid when specifying a single resource.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) ^/api/./pods/./exec,^/api/./pods/./attachRegular expression for paths that the proxy should reject. Paths specified here will be rejected even accepted by --accept-paths.
show-labelsunix-socketu falseWhen printing, show all labels as the last column (default hide labels column) Unix socket on which to run the proxy.
sort-bywwww If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Also serve static files from the given directory under the specified prefix.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. www-prefixP/static/Prefix to serve static files under, if static file directory is specified.

-

serviceaccount

+

top

+

Display Resource (CPU/Memory/Storage) usage.

+

The top command allows you to see the resource consumption for nodes or pods.

+

This command requires Heapster to be correctly configured and working on the server.

+

Usage

+

$ top

+
+

node

-

Set Deployment nginx-deployment's ServiceAccount to serviceaccount1

+

Show metrics for all nodes

-
kubectl set serviceaccount deployment nginx-deployment serviceaccount1
+
kubectl top node
 
-

Print the result (in yaml format) of updated nginx deployment with serviceaccount from local file, without hitting apiserver

+

Show metrics for a given node

-
kubectl set sa -f nginx-deployment.yaml serviceaccount1 --local --dry-run -o yaml
+
kubectl top node NODE_NAME
 
-

Update ServiceAccount of pod template resources.

-

Possible resources (case insensitive) can be:

-

replicationcontroller (rc), deployment (deploy), daemonset (ds), job, replicaset (rs), statefulset

+

Display Resource (CPU/Memory/Storage) usage of nodes.

+

The top-node command allows you to see the resource consumption of nodes.

Usage

-

$ serviceaccount (-f FILENAME | TYPE NAME) SERVICE_ACCOUNT

+

$ node [NAME | -l label]

Flags

@@ -5728,117 +5393,142 @@

Flags

- + - - + + - + - - + + - + - - + + - - - - + + + + - + + - - + + +
allheapster-namespace falseSelect all resources, including uninitialized ones, in the namespace of the specified resource types kube-systemNamespace Heapster service is located in
allow-missing-template-keysheapster-port trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. Port name in service to use
dry-runheapster-scheme falseIf true, only print the object that would be sent, without sending it. httpScheme (http or https) to connect to Heapster as
filenamef[]Filename, directory, or URL to files identifying the resource to get from a server. heapster-serviceheapsterName of Heapster service
include-uninitializedselectorl falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
+
+

pod

+
+

Show metrics for all pods in the default namespace

+
+
kubectl top pod
+
+
+

Show metrics for all pods in the given namespace

+
+
kubectl top pod --namespace=NAMESPACE
+
+
+

Show metrics for a given pod and its containers

+
+
kubectl top pod POD_NAME --containers
+
+
+

Show metrics for the pods defined by label name=myLabel

+
+
kubectl top pod -l name=myLabel
+
+

Display Resource (CPU/Memory/Storage) usage of pods.

+

The 'top pod' command allows you to see the resource consumption of pods.

+

Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.

+

Usage

+

$ pod [NAME | -l label]

+

Flags

+ + - - - - + + + + + + - + - + - - + - + + - - + - + + - + - - - - - - - - - - - - - - + + - + - - + + - - + - + + - - + + - +
localfalseIf true, set serviceaccount will NOT contact api-server but run locally. NameShorthandDefaultUsage
no-headersall-namespaces falseWhen using the default or custom-column output format, don't print headers (default print headers). If present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
outputocontainers Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. falseIf present, print usage of containers within a pod.
output-versionheapster-namespace DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). kube-systemNamespace Heapster service is located in
recordheapster-port falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Port name in service to use
show-labelsheapster-scheme falseWhen printing, show all labels as the last column (default hide labels column) httpScheme (http or https) to connect to Heapster as
sort-byheapster-service If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. heapsterName of Heapster service
templateselectorl Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
+

CLUSTER MANAGEMENT


-

subject

-
-

Update a ClusterRoleBinding for serviceaccount1

-
-
kubectl set subject clusterrolebinding admin --serviceaccount=namespace:serviceaccount1
-
-
-

Update a RoleBinding for user1, user2, and group1

-
-
kubectl set subject rolebinding admin --user=user1 --user=user2 --group=group1
-
+

api-versions

-

Print the result (in yaml format) of updating rolebinding subjects from a local, without hitting the server

+

Print the supported API versions

-
kubectl create rolebinding admin --role=admin --user=admin -o yaml --dry-run | kubectl set subject --local -f - --user=foo -o yaml
+
kubectl api-versions
 
-

Update User, Group or ServiceAccount in a RoleBinding/ClusterRoleBinding.

+

Print the supported API versions on the server, in the form of "group/version"

Usage

-

$ subject (-f FILENAME | TYPE NAME) [--user=username] [--group=groupname] [--serviceaccount=namespace:serviceaccountname] [--dry-run]

+

$ api-versions

+
+

certificate

+

Modify certificate resources.

+

Usage

+

$ certificate SUBCOMMAND

+
+

approve

+

Approve a certificate signing request.

+

kubectl certificate approve allows a cluster admin to approve a certificate signing request (CSR). This action tells a certificate signing controller to issue a certificate to the requestor with the attributes requested in the CSR.

+

SECURITY NOTICE: Depending on the requested attributes, the issued certificate can potentially grant a requester access to cluster resources or to authenticate as a requested identity. Before approving a CSR, ensure you understand what the signed certificate can do.

+

Usage

+

$ approve (-f FILENAME | NAME)

Flags

@@ -5851,52 +5541,16 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - + - + @@ -5905,83 +5559,92 @@

Flags

- - - - - - + +
allfalseSelect all resources, including uninitialized ones, in the namespace of the specified resource types
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
dry-runfalseIf true, only print the object that would be sent, without sending it.
filename f []Filename, directory, or URL to files the resource to update the subjects
group[]Groups to bind to the role
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized.
localfalseIf true, set subject will NOT contact api-server but run locally. Filename, directory, or URL to files identifying the resource to update
no-headersforce falseWhen using the default or custom-column output format, don't print headers (default print headers). Update the CSR even if it is already approved.
output Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
recursive R false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
+
+

deny

+

Deny a certificate signing request.

+

kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor.

+

Usage

+

$ deny (-f FILENAME | NAME)

+

Flags

+ + - - - - + + + + + + - - + + - - - - - - - + - + - + - - + + - + - - - - + + + +
selectorlSelector (label query) to filter on, not including uninitialized ones, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2) NameShorthandDefaultUsage
serviceaccountfilenamef []Service accounts to bind to the role
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) Filename, directory, or URL to files identifying the resource to update
show-labelsforce falseWhen printing, show all labels as the last column (default hide labels column) Update the CSR even if it is already denied.
sort-byoutputo If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
-

DECLARATIVE APP MANAGEMENT


-

apply

+

cluster-info

-

Apply the configuration in pod.json to a pod.

+

Print the address of the master and cluster services

-
kubectl apply -f ./pod.json
+
kubectl cluster-info
 
+

Display addresses of the master and services with label kubernetes.io/cluster-service=true To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

+

Usage

+

$ cluster-info

+
+

dump

-

Apply the JSON passed into stdin to a pod.

+

Dump current cluster state to stdout

-
cat pod.json | kubectl apply -f -
+
kubectl cluster-info dump
 
-

Note: --prune is still in Alpha # Apply the configuration in manifest.yaml that matches label app=nginx and delete all the other resources that are not in the file and match label app=nginx.

+

Dump current cluster state to /path/to/cluster-state

-
kubectl apply --prune -f manifest.yaml -l app=nginx
+
kubectl cluster-info dump --output-directory=/path/to/cluster-state
 
-

Apply the configuration in manifest.yaml and delete all the other configmaps that are not in the file.

+

Dump all namespaces to stdout

-
kubectl apply --prune -f manifest.yaml --all --prune-whitelist=core/v1/ConfigMap
+
kubectl cluster-info dump --all-namespaces
 
-

Apply a configuration to a resource by filename or stdin. The resource name must be specified. This resource will be created if it doesn't exist yet. To use 'apply', always create the resource initially with either 'apply' or 'create --save-config'.

-

JSON and YAML formats are accepted.

-

Alpha Disclaimer: the --prune functionality is not yet complete. Do not use unless you are aware of what the current state is. See https://issues.k8s.io/34274.

+
+

Dump a set of namespaces to /path/to/cluster-state

+
+
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state
+
+

Dumps cluster info out suitable for debugging and diagnosing cluster problems. By default, dumps everything to stdout. You can optionally specify a directory with --output-directory. If you specify a directory, kubernetes will build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.

+

The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories based on namespace and pod name.

Usage

-

$ apply -f FILENAME

+

$ dump

Flags

@@ -5994,176 +5657,179 @@

Flags

- + - - - - - - - - - - - - - + - + - - - - - - - + - + - - - - - - - + - + - - + + + +
allall-namespaces falseSelect all resources in the namespace of the specified resource types.
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
cascadetrueOnly relevant during a prune or a force apply. If true, cascade the deletion of the resources managed by pruned or deleted resources (e.g. Pods created by a ReplicationController). If true, dump all namespaces. If true, --namespaces is ignored.
dry-runnamespaces falseIf true, only print the object that would be sent, without sending it.
filenamef []Filename, directory, or URL to files that contains the configuration to apply A comma separated list of namespaces to dump.
forceoutput-directory falseDelete and re-create the specified resource, when PATCH encounters conflict and has retried for 5 times.
grace-period -1Only relevant during a prune or a force apply. Period of time in seconds given to pruned or deleted resources to terminate gracefully. Ignored if negative. Where to output the files. If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory
include-extended-apispod-running-timeout trueIf true, include definitions of new APIs via calls to the API server. [default true] 20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
+
+

cordon

+
+

Mark node "foo" as unschedulable.

+
+
kubectl cordon foo
+
+

Mark node as unschedulable.

+

Usage

+

$ cordon NODE

+

Flags

+ + - - - - + + + + + + - + - - - - - - - - - - - - - + - - + + - + + +
include-uninitializedfalseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. NameShorthandDefaultUsage
no-headersdry-run falseWhen using the default or custom-column output format, don't print headers (default print headers).
openapi-patchtrueIf true, use openapi to calculate diff when the openapi presents and the resource can be found in the openapi spec. Otherwise, fall back to use baked-in types.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. If true, only print the object that would be sent, without sending it.
output-versionselectorl DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). Selector (label query) to filter on
+
+

drain

+
+

Drain node "foo", even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet on it.

+
+
$ kubectl drain foo --force
+
+
+

As above, but abort if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 minutes.

+
+
$ kubectl drain foo --grace-period=900
+
+

Drain node in preparation for maintenance.

+

The given node will be marked unschedulable to prevent new pods from arriving. 'drain' evicts the pods if the APIServer supports eviction (http://kubernetes.io/docs/admin/disruptions/). Otherwise, it will use normal DELETE to delete the pods. The 'drain' evicts or deletes all pods except mirror pods (which cannot be deleted through the API server). If there are DaemonSet-managed pods, drain will not proceed without --ignore-daemonsets, and regardless it will not delete any DaemonSet-managed pods, because those pods would be immediately replaced by the DaemonSet controller, which ignores unschedulable markings. If there are any pods that are neither mirror pods nor managed by ReplicationController, ReplicaSet, DaemonSet, StatefulSet or Job, then drain will not delete any pods unless you use --force. --force will also allow deletion to proceed if the managing resource of one or more pods is missing.

+

'drain' waits for graceful termination. You should not operate on the machine until the command completes.

+

When you are ready to put the node back into service, use kubectl uncordon, which will make the node schedulable again.

+

! http://kubernetes.io/images/docs/kubectl_drain.svg

+

Usage

+

$ drain NODE

+

Flags

+ + - - - - + + + + + + - + - - - - - - - + - + - + - - + + - + - - + - - - - - - - + + - + - + - + - + - - + + - + - - - - - - - +
overwritetrueAutomatically resolve conflicts between the modified and live configuration by using values from the modified configuration NameShorthandDefaultUsage
prunedelete-local-data falseAutomatically delete resource objects, including the uninitialized ones, that do not appear in the configs and are created by either apply or create --save-config. Should be used with either -l or --all.
prune-whitelist[]Overwrite the default whitelist with for --prune Continue even if there are pods using emptyDir (local data that will be deleted when the node is drained).
recorddry-run falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. If true, only print the object that would be sent, without sending it.
recursiveRforce falseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. Continue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet.
selectorlgrace-period Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) -1Period of time in seconds given to each pod to terminate gracefully. If negative, the default value specified in the pod will be used.
show-labelsignore-daemonsets falseWhen printing, show all labels as the last column (default hide labels column) Ignore DaemonSet-managed pods.
sort-bypod-selector If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. Label selector to filter pods on the node
templateselectorl Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Selector (label query) to filter on
timeout 0sOnly relevant during a force apply. The length of time to wait before giving up on a delete of the old resource, zero means determine a timeout from the size of the object. Any other values should contain a corresponding time unit (e.g. 1s, 2m, 3h).
validatetrueIf true, use a schema to validate the input before sending it The length of time to wait before giving up, zero means infinite

-

edit-last-applied

+

taint

-

Edit the last-applied-configuration annotations by type/name in YAML.

+

Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'. # If a taint with that key and effect already exists, its value is replaced as specified.

-
kubectl apply edit-last-applied deployment/nginx
+
kubectl taint nodes foo dedicated=special-user:NoSchedule
 
-

Edit the last-applied-configuration annotations by file in JSON.

+

Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists.

-
kubectl apply edit-last-applied -f deploy.yaml -o json
+
kubectl taint nodes foo dedicated:NoSchedule-
 
-

Edit the latest last-applied-configuration annotations of resources from the default editor.

-

The edit-last-applied command allows you to directly edit any API resource you can retrieve via the command line tools. It will open the editor defined by your KUBE _EDITOR, or EDITOR environment variables, or fall back to 'vi' for Linux or 'notepad' for Windows. You can edit multiple objects, although changes are applied one at a time. The command accepts filenames as well as command line arguments, although the files you point to must be previously saved versions of resources.

-

The default format is YAML. To edit in JSON, specify "-o json".

-

The flag --windows-line-endings can be used to force Windows line endings, otherwise the default for your operating system will be used.

-

In the event an error occurs while updating, a temporary file will be created on disk that contains your unapplied changes. The most common error when updating a resource is another editor changing the resource on the server. When this occurs, you will have to apply your changes to the newer version of the resource, or update your temporary saved copy to include the latest resource version.

+
+

Remove from node 'foo' all the taints with key 'dedicated'

+
+
kubectl taint nodes foo dedicated-
+
+
+

Add a taint with key 'dedicated' on nodes having label mylabel=X

+
+
kubectl taint node -l myLabel=X  dedicated=foo:PreferNoSchedule
+
+

Update the taints on one or more nodes.

+
    +
  • A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect.
  • +
  • The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 253 characters.
  • +
  • Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app
  • +
  • The value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters.
  • +
  • The effect must be NoSchedule, PreferNoSchedule or NoExecute.
  • +
  • Currently taint can only apply to node.
  • +

Usage

-

$ edit-last-applied (RESOURCE/NAME | -f FILENAME)

+

$ taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N

Flags

@@ -6176,63 +5842,47 @@

Flags

- - - - - - - + - + - - + + - + - + - - - - + + + + - + - - + +
filenamef[]Filename, directory, or URL to files to use to edit the resource
include-uninitializedall falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. Select all nodes in the cluster
output oyamlOutput format. One of: yaml|json. Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
recordoverwrite falseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists. If true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints.
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory. selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
windows-line-endingsvalidate falseDefaults to the line ending native to your platform. trueIf true, use a schema to validate the input before sending it

-

set-last-applied

+

uncordon

-

Set the last-applied-configuration of a resource to match the contents of a file.

+

Mark node "foo" as schedulable.

-
kubectl apply set-last-applied -f deploy.yaml
-
-
-

Execute set-last-applied against each configuration file in a directory.

-
-
kubectl apply set-last-applied -f path/
-
-
-

Set the last-applied-configuration of a resource to match the contents of a file, will create the annotation if it does not already exist.

-
-
kubectl apply set-last-applied -f deploy.yaml --create-annotation=true
+
$ kubectl uncordon foo
 
-

Set the latest last-applied-configuration annotations by setting it to match the contents of a file. This results in the last-applied-configuration being updated as though 'kubectl apply -f ' was run, without updating any other parts of the object.

+

Mark node as schedulable.

Usage

-

$ set-last-applied -f FILENAME

+

$ uncordon NODE

Flags

@@ -6245,95 +5895,48 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + - +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
create-annotationfalseWill create 'last-applied-configuration' annotations if current objects doesn't have one
dry-run false If true, only print the object that would be sent, without sending it.
filenamef[]Filename, directory, or URL to files that contains the last-applied-configuration annotations
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
recordfalseRecord current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateselectorl Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. Selector (label query) to filter on
+

KUBECTL SETTINGS AND USAGE


-

view-last-applied

+

alpha

+

These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.

+

Usage

+

$ alpha

+
+

diff

-

View the last-applied-configuration annotations by type/name in YAML.

+

Diff resources included in pod.json. By default, it will diff LOCAL and LIVE versions

-
kubectl apply view-last-applied deployment/nginx
+
kubectl alpha diff -f pod.json
 
-

View the last-applied-configuration annotations by file in JSON

+

When one version is specified, diff that version against LIVE

-
kubectl apply view-last-applied -f deploy.yaml -o json
+
cat service.yaml | kubectl alpha diff -f - MERGED
 
-

View the latest last-applied-configuration annotations by type/name or file.

-

The default output will be printed to stdout in YAML format. One can use -o option to change output format.

+
+

Or specify both versions

+
+
kubectl alpha diff -f pod.json -f service.yaml LAST LOCAL
+
+

Diff configurations specified by filename or stdin between their local, last-applied, live and/or "merged" versions.

+

LOCAL and LIVE versions are diffed by default. Other available keywords are MERGED and LAST.

+

Output is always YAML.

+

KUBERNETES EXTERNAL DIFF environment variable can be used to select your own diff command. By default, the "diff" command available in your path will be run with "-u" (unicode) and "-N" (treat new files as empty) options.

Usage

-

$ view-last-applied (TYPE [NAME | -l label] | TYPE/NAME | -f FILENAME)

+

$ diff -f FILENAME

Flags

@@ -6346,22 +5949,10 @@

Flags

- - - - - - - - - - - - - + @@ -6369,47 +5960,38 @@

Flags

- - - - - -
allfalseSelect all resources in the namespace of the specified resource types
filename f []Filename, directory, or URL to files that contains the last-applied-configuration annotations
outputoOutput format. Must be one of yaml|json Filename, directory, or URL to files contains the configuration to diff
recursive false Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
-

WORKING WITH APPS

-

This section contains commands for inspecting and debugging your -applications.

-
    -
  • logs will print the logs from the specified pod + container.
  • -
  • exec can be used to get an interactive shell on a pod + container.
  • -
  • describe will print debug information about the given resource.
  • -

-

attach

+

api-resources

-

Get output from running pod 123456-7890, using the first container by default

+

Print the supported API Resources

-
kubectl attach 123456-7890
+
kubectl api-resources
 
-

Get output from ruby-container from pod 123456-7890

+

Print the supported API Resources with more information

-
kubectl attach 123456-7890 -c ruby-container
+
kubectl api-resources -o wide
 
-

Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client

+

Print the supported namespaced resources

-
kubectl attach 123456-7890 -c ruby-container -i -t
+
kubectl api-resources --namespaced=true
 
-

Get output from the first pod of a ReplicaSet named nginx

+

Print the supported non-namespaced resources

-
kubectl attach rs/nginx
+
kubectl api-resources --namespaced=false
 
-

Attach to a process that is already running inside an existing container.

+
+

Print the supported API Resources with specific APIGroup

+
+
kubectl api-resources --api-group=extensions
+
+

Print the supported API resources on the server

Usage

-

$ attach (POD | TYPE/NAME) -c CONTAINER

+

$ api-resources

Flags

@@ -6422,77 +6004,164 @@

Flags

- - + - + + - + - - + + - - - - + + + + - - + + - + + + + + + + + + + + + +
containercapi-group Container name. If omitted, the first container in the pod will be chosen Limit to resources in the specified API group.
pod-running-timeoutcached 1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running falseUse the cached list of resources if available.
stdinifalsePass stdin to the container namespacedtrueIf false, non-namespaced resources will be returned, otherwise returning namespaced resources by default.
ttytno-headers falseStdin is a TTY When using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: wide|name.
verbs[]Limit to resources that support the specified verbs.

-

auth

-

Inspect authorization

-

Usage

-

$ auth

-
-

can-i

+

completion

-

Check to see if I can create pods in any namespace

+

Installing bash completion on macOS using homebrew ## If running Bash 3.2 included with macOS

-
kubectl auth can-i create pods --all-namespaces
+
brew install bash-completion
+
+
+

or, if running Bash 4.1+

+
+
brew install bash-completion@2
+
+
+

If kubectl is installed via homebrew, this should start working immediately. ## If you've installed via other means, you may need add the completion to your completion directory

+
+
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
 
-

Check to see if I can list deployments in my current namespace

+

Installing bash completion on Linux ## Load the kubectl completion code for bash into the current shell

-
kubectl auth can-i list deployments.extensions
+
source <(kubectl completion bash)
+
+
+

Write bash completion code to a file and source if from .bash_profile

+
+
kubectl completion bash > ~/.kube/completion.bash.inc
+printf "
 
-

Check to see if I can do everything in my current namespace ("*" means all)

+

Kubectl shell completion

-
kubectl auth can-i '*' '*'
+
source '$HOME/.kube/completion.bash.inc'
+" >> $HOME/.bash_profile
+source $HOME/.bash_profile
 
-

Check to see if I can get the job named "bar" in namespace "foo"

+

Load the kubectl completion code for zsh[1] into the current shell

-
kubectl auth can-i list jobs.batch/bar -n foo
+
source <(kubectl completion zsh)
 
-

Check to see if I can read pod logs

+

Set the kubectl completion code for zsh[1] to autoload on startup

-
kubectl auth can-i get pods --subresource=log
+
kubectl completion zsh > "${fpath[1]}/_kubectl"
 
+

Output shell completion code for the specified shell (bash or zsh). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash _profile.

+

Detailed instructions on how to do this are available here: https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion

+

Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2

+

Usage

+

$ completion SHELL

+
+

config

+

Modify kubeconfig files using subcommands like "kubectl config set current-context my-context"

+

The loading order follows these rules:

+
    +
  1. If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes place.
  2. +
  3. If $KUBECONFIG environment variable is set, then it is used a list of paths (normal path delimitting rules for your system). These paths are merged. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list.
  4. +
  5. Otherwise, ${HOME}/.kube/config is used and no merging takes place.
  6. +
+

Usage

+

$ config SUBCOMMAND

+
+

current-context

-

Check to see if I can access the URL /logs/

+

Display the current-context

-
kubectl auth can-i get /logs/
+
kubectl config current-context
 
-

Check whether an action is allowed.

-

VERB is a logical Kubernetes API verb like 'get', 'list', 'watch', 'delete', etc. TYPE is a Kubernetes resource. Shortcuts and groups will be resolved. NONRESOURCEURL is a partial URL starts with "/". NAME is the name of a particular Kubernetes resource.

+

Displays the current-context

Usage

-

$ can-i VERB [TYPE | TYPE/NAME | NONRESOURCEURL]

-

Flags

- - - - +

$ current-context

+
+

delete-cluster

+
+

Delete the minikube cluster

+
+
kubectl config delete-cluster minikube
+
+

Delete the specified cluster from the kubeconfig

+

Usage

+

$ delete-cluster NAME

+
+

delete-context

+
+

Delete the context for the minikube cluster

+
+
kubectl config delete-context minikube
+
+

Delete the specified context from the kubeconfig

+

Usage

+

$ delete-context NAME

+
+

get-clusters

+
+

List the clusters kubectl knows about

+
+
kubectl config get-clusters
+
+

Display clusters defined in the kubeconfig.

+

Usage

+

$ get-clusters

+
+

get-contexts

+
+

List all the contexts in your kubeconfig file

+
+
kubectl config get-contexts
+
+
+

Describe one context in your kubeconfig file.

+
+
kubectl config get-contexts my-context
+
+

Displays one or many contexts from the kubeconfig file.

+

Usage

+

$ get-contexts [(-o|--output=)name)]

+

Flags

+
Name
+ + + @@ -6500,36 +6169,39 @@

Flags

- + - - - - - - - + - - + + - +
Name Shorthand Default Usage
all-namespacesno-headers falseIf true, check the specified action in all namespaces.
quietqfalseIf true, suppress output and just return the exit code. When using the default or custom-column output format, don't print headers (default print headers).
subresourceoutputo SubResource such as pod/log or deployment/scale Output format. One of: name

-

reconcile

+

rename-context

-

Reconcile rbac resources from a file

+

Rename the context 'old-name' to 'new-name' in your kubeconfig file

-
kubectl auth reconcile -f my-rbac-rules.yaml
+
kubectl config rename-context old-name new-name
 
-

Reconciles rules for RBAC Role, RoleBinding, ClusterRole, and ClusterRole binding objects.

-

This is preferred to 'apply' for RBAC resources so that proper rule coverage checks are done.

+

Renames a context from the kubeconfig file.

+

CONTEXT _NAME is the context name that you wish change.

+

NEW _NAME is the new name you wish to set.

+

Note: In case the context being renamed is the 'current-context', this field will also be updated.

Usage

-

$ reconcile -f FILENAME

+

$ rename-context CONTEXT_NAME NEW_NAME

+
+

set

+

Sets an individual value in a kubeconfig file

+

PROPERTY _NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.

+

PROPERTY _VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64 encoded string unless the --set-raw-bytes flag is used.

+

Usage

+

$ set PROPERTY_NAME PROPERTY_VALUE

Flags

@@ -6542,92 +6214,34 @@

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + - - - - - - - - - - - - - +
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
filenamef[]Filename, directory, or URL to files identifying the resource to reconcile.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsset-raw-bytes falseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. When writing a []byte PROPERTY_VALUE, write the given string directly without base64 decoding.

-

cp

-
-

!!!Important Note!!! # Requires that the 'tar' binary is present in your container # image. If 'tar' is not present, 'kubectl cp' will fail. # Copy /tmp/foo_dir local directory to /tmp/bar_dir in a remote pod in the default namespace

-
-
kubectl cp /tmp/foo_dir <some-pod>:/tmp/bar_dir
-
+

set-cluster

-

Copy /tmp/foo local file to /tmp/bar in a remote pod in a specific container

+

Set only the server field on the e2e cluster entry without touching other values.

-
kubectl cp /tmp/foo <some-pod>:/tmp/bar -c <specific-container>
+
kubectl config set-cluster e2e --server=https://1.2.3.4
 
-

Copy /tmp/foo local file to /tmp/bar in a remote pod in namespace

+

Embed certificate authority data for the e2e cluster entry

-
kubectl cp /tmp/foo <some-namespace>/<some-pod>:/tmp/bar
+
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
 
-

Copy /tmp/foo from a remote pod to /tmp/bar locally

+

Disable cert checking for the dev cluster entry

-
kubectl cp <some-namespace>/<some-pod>:/tmp/foo /tmp/bar
+
kubectl config set-cluster e2e --insecure-skip-tls-verify=true
 
-

Copy files and directories to and from containers.

+

Sets a cluster entry in kubeconfig.

+

Specifying a name that already exists will merge new fields on top of existing values for those fields.

Usage

-

$ cp <file-spec-src> <file-spec-dest>

+

$ set-cluster NAME [--server=server] [--certificate-authority=path/to/certificate/authority] [--insecure-skip-tls-verify=true]

Flags

@@ -6640,91 +6254,67 @@

Flags

- - + - + +
containercembed-certs Container name. If omitted, the first container in the pod will be chosen falseembed-certs for the cluster entry in kubeconfig

-

describe

+

set-context

-

Describe a node

+

Set the user field on the gce context entry without touching other values

-
kubectl describe nodes kubernetes-node-emt8.c.myproject.internal
+
kubectl config set-context gce --user=cluster-admin
 
+

Sets a context entry in kubeconfig

+

Specifying a name that already exists will merge new fields on top of existing values for those fields.

+

Usage

+

$ set-context NAME [--cluster=cluster_nickname] [--user=user_nickname] [--namespace=namespace]

+
+

set-credentials

-

Describe a pod

+

Set only the "client-key" field on the "cluster-admin" # entry, without touching other values:

-
kubectl describe pods/nginx
+
kubectl config set-credentials cluster-admin --client-key=~/.kube/admin.key
 
-

Describe a pod identified by type and name in "pod.json"

+

Set basic auth for the "cluster-admin" entry

-
kubectl describe -f pod.json
+
kubectl config set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
 
-

Describe all pods

+

Embed client certificate data in the "cluster-admin" entry

-
kubectl describe pods
+
kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true
 
-

Describe pods by label name=myLabel

+

Enable the Google Compute Platform auth provider for the "cluster-admin" entry

-
kubectl describe po -l name=myLabel
+
kubectl config set-credentials cluster-admin --auth-provider=gcp
 
-

Describe all pods managed by the 'frontend' replication controller (rc-created pods # get the name of the rc as a prefix in the pod the name).

+

Enable the OpenID Connect auth provider for the "cluster-admin" entry with additional args

-
kubectl describe pods frontend
+
kubectl config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-id=foo --auth-provider-arg=client-secret=bar
 
-

Show details of a specific resource or group of resources

-

Print a detailed description of the selected resources, including related resources such as events or controllers. You may select a single object by name, all objects of that type, provide a name prefix, or label selector. For example:

-

$ kubectl describe TYPE NAME_PREFIX

-

will first check for an exact match on TYPE and NAME PREFIX. If no such resource exists, it will output details for every resource that has a name prefixed with NAME PREFIX.

-

Valid resource types include:

-
    -
  • all
  • -
  • certificatesigningrequests (aka 'csr')
  • -
  • clusterrolebindings
  • -
  • clusterroles
  • -
  • componentstatuses (aka 'cs')
  • -
  • configmaps (aka 'cm')
  • -
  • controllerrevisions
  • -
  • cronjobs
  • -
  • customresourcedefinition (aka 'crd')
  • -
  • daemonsets (aka 'ds')
  • -
  • deployments (aka 'deploy')
  • -
  • endpoints (aka 'ep')
  • -
  • events (aka 'ev')
  • -
  • horizontalpodautoscalers (aka 'hpa')
  • -
  • ingresses (aka 'ing')
  • -
  • jobs
  • -
  • limitranges (aka 'limits')
  • -
  • namespaces (aka 'ns')
  • -
  • networkpolicies (aka 'netpol')
  • -
  • nodes (aka 'no')
  • -
  • persistentvolumeclaims (aka 'pvc')
  • -
  • persistentvolumes (aka 'pv')
  • -
  • poddisruptionbudgets (aka 'pdb')
  • -
  • podpreset
  • -
  • pods (aka 'po')
  • -
  • podsecuritypolicies (aka 'psp')
  • -
  • podtemplates
  • -
  • replicasets (aka 'rs')
  • -
  • replicationcontrollers (aka 'rc')
  • -
  • resourcequotas (aka 'quota')
  • -
  • rolebindings
  • -
  • roles
  • -
  • secrets
  • -
  • serviceaccounts (aka 'sa')
  • -
  • services (aka 'svc')
  • -
  • statefulsets (aka 'sts')
  • -
  • storageclasses (aka 'sc')
  • -
+
+

Remove the "client-secret" config value for the OpenID Connect auth provider for the "cluster-admin" entry

+
+
kubectl config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-secret-
+
+

Sets a user entry in kubeconfig

+

Specifying a name that already exists will merge new fields on top of existing values.

+

Client-certificate flags: + --client-certificate=certfile --client-key=keyfile

+

Bearer token flags: + --token=bearer_token

+

Basic auth flags: + --username=basic_user --password=basic_password

+

Bearer token and basic auth are mutually exclusive.

Usage

-

$ describe (-f FILENAME | TYPE [NAME_PREFIX | -l label] | TYPE/NAME)

+

$ set-credentials NAME [--client-certificate=path/to/certfile] [--client-key=path/to/keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password] [--auth-provider=provider_name] [--auth-provider-arg=key=value]

Flags

@@ -6737,74 +6327,84 @@

Flags

- + - - + + - - + + - + - + - - + + - + - - + + - - - - - - - - - - - - - - - - + + + +
all-namespacesauth-provider falseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace. Auth provider for the user entry in kubeconfig
filenamefauth-provider-arg []Filename, directory, or URL to files containing the resource to describe 'key=value' arguments for the auth provider
include-extended-apisembed-certs trueIf true, include definitions of new APIs via calls to the API server. [default true] falseEmbed client cert/key for the user entry in kubeconfig
include-uninitializedpassword falseIf true, the kubectl command applies to uninitialized objects. If explicitly set to false, this flag overrides other flags that make the kubectl commands apply to uninitialized objects, e.g., "--all". Objects with empty metadata.initializers are regarded as initialized. password for the user entry in kubeconfig
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-eventstrueIf true, display events related to the described object. usernameusername for the user entry in kubeconfig

-

exec

+

unset

-

Get output from running 'date' from pod 123456-7890, using the first container by default

+

Unset the current-context.

-
kubectl exec 123456-7890 date
+
kubectl config unset current-context
 
-

Get output from running 'date' in ruby-container from pod 123456-7890

+

Unset namespace in foo context.

-
kubectl exec 123456-7890 -c ruby-container date
+
kubectl config unset contexts.foo.namespace
 
+

Unsets an individual value in a kubeconfig file

+

PROPERTY _NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.

+

Usage

+

$ unset PROPERTY_NAME

+
+

use-context

-

Switch to raw terminal mode, sends stdin to 'bash' in ruby-container from pod 123456-7890 # and sends stdout/stderr from 'bash' back to the client

+

Use the context for the minikube cluster

-
kubectl exec 123456-7890 -c ruby-container -i -t -- bash -il
+
kubectl config use-context minikube
+
+

Sets the current-context in a kubeconfig file

+

Usage

+

$ use-context CONTEXT_NAME

+
+

view

+
+

Show merged kubeconfig settings.

+
+
kubectl config view
 
-

List contents of /usr from the first container of pod 123456-7890 and sort by modification time. # If the command you want to execute in the pod has any flags in common (e.g. -i), # you must use two dashes (--) to separate your command's flags/arguments. # Also note, do not surround your command and its flags/arguments with quotes # unless that is how you would execute it normally (i.e., do ls -t /usr, not "ls -t /usr").

+

Show merged kubeconfig settings and raw certificate data.

-
kubectl exec 123456-7890 -i -t -- ls -t /usr
+
kubectl config view --raw
 
-

Execute a command in a container.

+
+

Get the password for the e2e user

+
+
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
+
+

Display merged kubeconfig settings or a specified kubeconfig file.

+

You can use --output jsonpath={...} to extract specific values using a jsonpath expression.

Usage

-

$ exec POD [-c CONTAINER] -- COMMAND [args...]

+

$ view

Flags

@@ -6817,76 +6417,183 @@

Flags

- - + - + + - - + - + + - - + + + + + + + + - + - - + + + + + + + + - + + + + + + +
containercallow-missing-template-keys Container name. If omitted, the first container in the pod will be chosen trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
podpflatten Pod name falseFlatten the resulting kubeconfig file into self-contained output (useful for creating portable kubeconfig files)
stdinimergetrueMerge the full hierarchy of kubeconfig files
minify falsePass stdin to the container Remove all information not used by current-context from the output
ttytoutputoyamlOutput format. One of: json|yaml|name|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
raw falseStdin is a TTY Display raw byte data
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].

-

logs

+

explain

-

Return snapshot logs from pod nginx with only one container

+

Get the documentation of the resource and its fields

-
kubectl logs nginx
+
kubectl explain pods
+
+
+

Get the documentation of a specific field of a resource

+
+
kubectl explain pods.spec.containers
 
+

List the fields for supported resources

+

This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:

+

.[.]

+

Add the --recursive flag to display all of the fields at once without descriptions. Information about each field is retrieved from the server in OpenAPI format.

+

Use "kubectl api-resources" for a complete list of supported resources.

+

Usage

+

$ explain RESOURCE

+

Flags

+ + + + + + + + + + + + + + + + + + + + + + + +
NameShorthandDefaultUsage
api-versionGet different explanations for particular API version
recursivefalsePrint the fields of fields (Currently only 1 level deep)
+
+

options

-

Return snapshot logs for the pods defined by label app=nginx

+

Print flags inherited by all commands

-
kubectl logs -lapp=nginx
+
kubectl options
 
+

Print the list of flags inherited by all commands

+

Usage

+

$ options

+
+

plugin

+

Runs a command-line plugin.

+

Plugins are subcommands that are not part of the major command-line distribution and can even be provided by third-parties. Please refer to the documentation and examples for more information about how to install and write your own plugins.

+

Usage

+

$ plugin NAME

+
+

version

-

Return snapshot of previous terminated ruby container logs from pod web-1

+

Print the client and server versions for the current context

-
kubectl logs -p -c ruby web-1
+
kubectl version
 
+

Print the client and server version information for the current context

+

Usage

+

$ version

+

Flags

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameShorthandDefaultUsage
clientcfalseClient version only (no server required).
outputoOne of 'yaml' or 'json'.
shortfalsePrint just the version number.
+

DEPRECATED COMMANDS

+
+

rolling-update

-

Begin streaming the logs of the ruby container in pod web-1

+

Update pods of frontend-v1 using new replication controller data in frontend-v2.json.

-
kubectl logs -f -c ruby web-1
+
kubectl rolling-update frontend-v1 -f frontend-v2.json
 
-

Display only the most recent 20 lines of output in pod nginx

+

Update pods of frontend-v1 using JSON data passed into stdin.

-
kubectl logs --tail=20 nginx
+
cat frontend-v2.json | kubectl rolling-update frontend-v1 -f -
 
-

Show all logs from pod nginx written in the last hour

+

Update the pods of frontend-v1 to frontend-v2 by just changing the image, and switching the # name of the replication controller.

-
kubectl logs --since=1h nginx
+
kubectl rolling-update frontend-v1 frontend-v2 --image=image:v2
 
-

Return snapshot logs from first container of a job named hello

+

Update the pods of frontend by just changing the image, and keeping the old name.

-
kubectl logs job/hello
+
kubectl rolling-update frontend --image=image:v2
 
-

Return snapshot logs from container nginx-1 of a deployment named nginx

+

Abort and reverse an existing rollout in progress (from frontend-v1 to frontend-v2).

-
kubectl logs deployment/nginx -c nginx-1
+
kubectl rolling-update frontend-v1 frontend-v2 --rollback
 
-

Print the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional.

+

Perform a rolling update of the given ReplicationController.

+

Replaces the specified replication controller with a new replication controller by updating one pod at a time to use the new PodTemplate. The new-controller.json must specify the same namespace as the existing replication controller and overwrite at least one (common) label in its replicaSelector.

+

! http://kubernetes.io/images/docs/kubectl_rollingupdate.svg

Usage

-

$ logs [-f] [-p] (POD | TYPE/NAME) [-c CONTAINER]

+

$ rolling-update OLD_CONTROLLER_NAME ([NEW_CONTROLLER_NAME] --image=NEW_CONTAINER_IMAGE | -f NEW_CONTROLLER_SPEC)

Flags

@@ -6900,159 +6607,144 @@

Flags

- - - - - - - - + + - + - - + + - + - + - + + + + + + + - - + + - + - - + + - - - - + + + + - - + - + + - + - - + + - - + - + + - + - - + + - + - - + +
containerc Print the logs of this container
followffalseSpecify if the logs should be streamed. Container name which will have its image upgraded. Only relevant when --image is specified, ignored otherwise. Required when using --image on a multi-container pod
include-extended-apisdeployment-label-key trueIf true, include definitions of new APIs via calls to the API server. [default true] deploymentThe key to use to differentiate between two different controllers, default 'deployment'. Only relevant when --image is specified, ignored otherwise
interactivedry-run falseIf true, prompt the user for input when required. If true, only print the object that would be sent, without sending it.
limit-bytesfilenamef[]Filename or URL to file to use to create the new replication controller.
image 0Maximum bytes of logs to return. Defaults to no limit. Image to use for upgrading the replication controller. Must be distinct from the existing image (either new image or new image tag). Can not be used with --filename/-f
pod-running-timeoutimage-pull-policy 20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running Explicit policy for when to pull container images. Required when --image is same as existing image, ignored otherwise.
previouspfalseIf true, print the logs for the previous instance of the container in a pod if it exists. outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
selectorlpoll-interval Selector (label query) to filter on. 3sTime delay between polling for replication controller status after the update. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
sincerollback 0sOnly return logs newer than a relative duration like 5s, 2m, or 3h. Defaults to all logs. Only one of since-time / since may be used. falseIf true, this is a request to abort an existing rollout that is partially rolled out. It effectively reverses current and next and runs a rollout
since-timetimeout Only return logs after a specific date (RFC3339). Defaults to all logs. Only one of since-time / since may be used. 5m0sMax time to wait for a replication controller to update before giving up. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
tailupdate-period -1Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided. 1m0sTime to wait between updating pods. Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
timestampsvalidate falseInclude timestamps on each line in the log output trueIf true, use a schema to validate the input before sending it

-

port-forward

+

run-container

-

Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod

+

Start a single instance of nginx.

-
kubectl port-forward pod/mypod 5000 6000
+
kubectl run nginx --image=nginx
 
-

Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the deployment

+

Start a single instance of hazelcast and let the container expose port 5701 .

-
kubectl port-forward deployment/mydeployment 5000 6000
+
kubectl run hazelcast --image=hazelcast --port=5701
 
-

Listen on port 8888 locally, forwarding to 5000 in the pod

+

Start a single instance of hazelcast and set environment variables "DNS_DOMAIN=cluster" and "POD_NAMESPACE=default" in the container.

-
kubectl port-forward pod/mypod 8888:5000
+
kubectl run hazelcast --image=hazelcast --env="DNS_DOMAIN=cluster" --env="POD_NAMESPACE=default"
 
-

Listen on a random port locally, forwarding to 5000 in the pod

+

Start a single instance of hazelcast and set labels "app=hazelcast" and "env=prod" in the container.

-
kubectl port-forward pod/mypod :5000
+
kubectl run hazelcast --image=nginx --labels="app=hazelcast,env=prod"
 
-

Forward one or more local ports to a pod.

-

Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.

-

If there are multiple pods matching the criteria, a pod will be selected automatically. The forwarding session ends when the selected pod terminates, and rerun of the command is needed to resume forwarding.

-

Usage

-

$ port-forward TYPE/NAME [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]

-

Flags

- - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
pod-running-timeout1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
-
-

proxy

-

To proxy all of the kubernetes api and nothing else, use:

+

Start a replicated instance of nginx.

-
$ kubectl proxy --api-prefix=/
+
kubectl run nginx --image=nginx --replicas=5
 
-

To proxy only part of the kubernetes api and also some static files:

+

Dry run. Print the corresponding API objects without creating them.

-
$ kubectl proxy --www=/my/files --www-prefix=/static/ --api-prefix=/api/
+
kubectl run nginx --image=nginx --dry-run
 
-

The above lets you 'curl localhost:8001/api/v1/pods'. # To proxy the entire kubernetes api at a different root, use:

+

Start a single instance of nginx, but overload the spec of the deployment with a partial set of values parsed from JSON.

-
$ kubectl proxy --api-prefix=/custom/
+
kubectl run nginx --image=nginx --overrides='{ "apiVersion": "v1", "spec": { ... } }'
 
-

The above lets you 'curl localhost:8001/custom/api/v1/pods' # Run a proxy to kubernetes apiserver on port 8011, serving static content from ./local/www/

+

Start a pod of busybox and keep it in the foreground, don't restart it if it exits.

-
kubectl proxy --port=8011 --www=./local/www/
+
kubectl run -i -t busybox --image=busybox --restart=Never
 
-

Run a proxy to kubernetes apiserver on an arbitrary local port. # The chosen port for the server will be output to stdout.

+

Start the nginx container using the default command, but use custom arguments (arg1 .. argN) for that command.

-
kubectl proxy --port=0
+
kubectl run nginx --image=nginx -- <arg1> <arg2> ... <argN>
 
-

Run a proxy to kubernetes apiserver, changing the api prefix to k8s-api # This makes e.g. the pods api available at localhost:8001/k8s-api/v1/pods/

+

Start the nginx container using a different command and custom arguments.

-
kubectl proxy --api-prefix=/k8s-api
+
kubectl run nginx --image=nginx --command -- <cmd> <arg1> ... <argN>
 
-

Creates a proxy server or application-level gateway between localhost and the Kubernetes API Server. It also allows serving static content over specified HTTP path. All incoming data enters through one port and gets forwarded to the remote kubernetes API Server port, except for the path matching the static content path.

+
+

Start the perl container to compute π to 2000 places and print it out.

+
+
kubectl run pi --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
+
+

Start the cron job to compute π to 2000 places and print it out every 5 minutes.

+
+
kubectl run pi --schedule="0/5 * * * ?" --image=perl --restart=OnFailure -- perl -Mbignum=bpi -wle 'print bpi(2000)'
+
+

Create and run a particular image, possibly replicated.

+

Creates a deployment or job to manage the created container(s).

Usage

-

$ proxy [--port=PORT] [--www=static-dir] [--www-prefix=prefix] [--api-prefix=prefix]

+

$ run-container

Flags

@@ -7065,1317 +6757,223 @@

Flags

- + - - + + - + - - + + - + - - + + - + - - + + - + + + + + + + - + - - - - + + + + - + - - + + - + - - + + - - + - + + - - + - + + - - - - + + + + - -
accept-hostsattach ^localhost$,^127.0.0.1$,^[::1]$Regular expression for hosts that the proxy should accept. falseIf true, wait for the Pod to start running, and then attach to the Pod as if 'kubectl attach ...' were called. Default false, unless '-i/--stdin' is set, in which case the default is true. With '--restart=Never' the exit code of the container process is returned.
accept-pathscascade ^.*Regular expression for paths that the proxy should accept. trueIf true, cascade the deletion of the resources managed by this resource (e.g. Pods created by a ReplicationController). Default true.
addresscommand 127.0.0.1The IP address on which to serve on. falseIf true and extra arguments are present, use them as the 'command' field in the container, rather than the 'args' field which is the default.
api-prefixdry-run /Prefix to serve the proxied API under. falseIf true, only print the object that would be sent, without sending it.
disable-filterenv[]Environment variables to set in the container
expose falseIf true, disable request filtering in the proxy. This is dangerous, and can leave you vulnerable to XSRF attacks, when used with an accessible port. If true, a public, external service is created for the container(s) which are run
portp8001The port on which to run the proxy. Set to 0 to pick a random port. filenamef[]to use to replace the resource.
reject-methodsforce ^$Regular expression for HTTP methods that the proxy should reject (example --reject-methods='POST,PUT,PATCH'). falseOnly used when grace-period=0. If true, immediately remove resources from API and bypass graceful deletion. Note that immediate deletion of some resources may result in inconsistency or data loss and requires confirmation.
reject-pathsgenerator ^/api/./pods/./exec,^/api/./pods/./attachRegular expression for paths that the proxy should reject. Paths specified here will be rejected even accepted by --accept-paths. The name of the API generator to use, see http://kubernetes.io/docs/user-guide/kubectl-conventions/#generators for a list.
unix-socketugrace-period Unix socket on which to run the proxy. -1Period of time in seconds given to the resource to terminate gracefully. Ignored if negative. Set to 1 for immediate shutdown. Can only be set to 0 when --force is true (force deletion).
wwwwhostport Also serve static files from the given directory under the specified prefix. -1The host port mapping for the container port. To demonstrate a single-machine container.
www-prefixP/static/Prefix to serve static files under, if static file directory is specified. imageThe image for the container to run.
-
-

top

-

Display Resource (CPU/Memory/Storage) usage.

-

The top command allows you to see the resource consumption for nodes or pods.

-

This command requires Heapster to be correctly configured and working on the server.

-

Usage

-

$ top

-
-

node

-
-

Show metrics for all nodes

-
-
kubectl top node
-
-
-

Show metrics for a given node

-
-
kubectl top node NODE_NAME
-
-

Display Resource (CPU/Memory/Storage) usage of nodes.

-

The top-node command allows you to see the resource consumption of nodes.

-

Usage

-

$ node [NAME | -l label]

-

Flags

- - - - - - + + + + - - - + + - - + - - + - + + - + - - + + - + + - - + - - + - - - -
NameShorthandDefaultUsageimage-pull-policyThe image pull policy for the container. If left empty, this value will not be specified by the client and defaulted by the server
heapster-namespacelabelsl kube-systemNamespace Heapster service is located in Comma separated labels to apply to the pod(s). Will override previous values.
heapster-portleave-stdin-open Port name in service to use falseIf the pod is started in interactive mode or with stdin, leave stdin open after the first attach completes. By default, stdin will be closed after the first attach completes.
heapster-schemelimits httpScheme (http or https) to connect to Heapster as The resource requirement limits for this container. For example, 'cpu=200m,memory=512Mi'. Note that server side components may assign limits depending on the server configuration, such as limit ranges.
heapster-serviceoutputo heapsterName of Heapster service Output format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
selectorloverrides Selector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
-
-

pod

-
-

Show metrics for all pods in the default namespace

-
-
kubectl top pod
-
-
-

Show metrics for all pods in the given namespace

-
-
kubectl top pod --namespace=NAMESPACE
-
-
-

Show metrics for a given pod and its containers

-
-
kubectl top pod POD_NAME --containers
-
-
-

Show metrics for the pods defined by label name=myLabel

-
-
kubectl top pod -l name=myLabel
-
-

Display Resource (CPU/Memory/Storage) usage of pods.

-

The 'top pod' command allows you to see the resource consumption of pods.

-

Due to the metrics pipeline delay, they may be unavailable for a few minutes since pod creation.

-

Usage

-

$ pod [NAME | -l label]

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
all-namespacesfalseIf present, list the requested object(s) across all namespaces. Namespace in current context is ignored even if specified with --namespace.
containersfalseIf present, print usage of containers within a pod.
heapster-namespacekube-systemNamespace Heapster service is located in
heapster-portPort name in service to use
heapster-schemehttpScheme (http or https) to connect to Heapster as
heapster-serviceheapsterName of Heapster service
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
-

CLUSTER MANAGEMENT

-
-

api-versions

-
-

Print the supported API versions

-
-
kubectl api-versions
-
-

Print the supported API versions on the server, in the form of "group/version"

-

Usage

-

$ api-versions

-
-

certificate

-

Modify certificate resources.

-

Usage

-

$ certificate SUBCOMMAND

-
-

approve

-

Approve a certificate signing request.

-

kubectl certificate approve allows a cluster admin to approve a certificate signing request (CSR). This action tells a certificate signing controller to issue a certificate to the requestor with the attributes requested in the CSR.

-

SECURITY NOTICE: Depending on the requested attributes, the issued certificate can potentially grant a requester access to cluster resources or to authenticate as a requested identity. Before approving a CSR, ensure you understand what the signed certificate can do.

-

Usage

-

$ approve (-f FILENAME | NAME)

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
filenamef[]Filename, directory, or URL to files identifying the resource to update
outputoOutput mode. Use "-o name" for shorter output (resource/name).
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
-
-

deny

-

Deny a certificate signing request.

-

kubectl certificate deny allows a cluster admin to deny a certificate signing request (CSR). This action tells a certificate signing controller to not to issue a certificate to the requestor.

-

Usage

-

$ deny (-f FILENAME | NAME)

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
filenamef[]Filename, directory, or URL to files identifying the resource to update
outputoOutput mode. Use "-o name" for shorter output (resource/name).
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
-
-

cluster-info

-
-

Print the address of the master and cluster services

-
-
kubectl cluster-info
-
-

Display addresses of the master and services with label kubernetes.io/cluster-service=true To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.

-

Usage

-

$ cluster-info

-

Flags

- - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true]
-
-

dump

-
-

Dump current cluster state to stdout

-
-
kubectl cluster-info dump
-
-
-

Dump current cluster state to /path/to/cluster-state

-
-
kubectl cluster-info dump --output-directory=/path/to/cluster-state
-
-
-

Dump all namespaces to stdout

-
-
kubectl cluster-info dump --all-namespaces
-
-
-

Dump a set of namespaces to /path/to/cluster-state

-
-
kubectl cluster-info dump --namespaces default,kube-system --output-directory=/path/to/cluster-state
-
-

Dumps cluster info out suitable for debugging and diagnosing cluster problems. By default, dumps everything to stdout. You can optionally specify a directory with --output-directory. If you specify a directory, kubernetes will build a set of files in that directory. By default only dumps things in the 'kube-system' namespace, but you can switch to a different namespace with the --namespaces flag, or specify --all-namespaces to dump all namespaces.

-

The command also dumps the logs of all of the pods in the cluster, these logs are dumped into different directories based on namespace and pod name.

-

Usage

-

$ dump

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
all-namespacesfalseIf true, dump all namespaces. If true, --namespaces is ignored.
namespaces[]A comma separated list of namespaces to dump.
output-directoryWhere to output the files. If empty or '-' uses stdout, otherwise creates a directory hierarchy in that directory
pod-running-timeout20sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
-
-

cordon

-
-

Mark node "foo" as unschedulable.

-
-
kubectl cordon foo
-
-

Mark node as unschedulable.

-

Usage

-

$ cordon NODE

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
dry-runfalseIf true, only print the object that would be sent, without sending it.
selectorlSelector (label query) to filter on
-
-

drain

-
-

Drain node "foo", even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet on it.

-
-
$ kubectl drain foo --force
-
-
-

As above, but abort if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet, and use a grace period of 15 minutes.

-
-
$ kubectl drain foo --grace-period=900
-
-

Drain node in preparation for maintenance.

-

The given node will be marked unschedulable to prevent new pods from arriving. 'drain' evicts the pods if the APIServer supports eviction (http://kubernetes.io/docs/admin/disruptions/). Otherwise, it will use normal DELETE to delete the pods. The 'drain' evicts or deletes all pods except mirror pods (which cannot be deleted through the API server). If there are DaemonSet-managed pods, drain will not proceed without --ignore-daemonsets, and regardless it will not delete any DaemonSet-managed pods, because those pods would be immediately replaced by the DaemonSet controller, which ignores unschedulable markings. If there are any pods that are neither mirror pods nor managed by ReplicationController, ReplicaSet, DaemonSet, StatefulSet or Job, then drain will not delete any pods unless you use --force. --force will also allow deletion to proceed if the managing resource of one or more pods is missing.

-

'drain' waits for graceful termination. You should not operate on the machine until the command completes.

-

When you are ready to put the node back into service, use kubectl uncordon, which will make the node schedulable again.

-

! http://kubernetes.io/images/docs/kubectl_drain.svg

-

Usage

-

$ drain NODE

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
delete-local-datafalseContinue even if there are pods using emptyDir (local data that will be deleted when the node is drained).
dry-runfalseIf true, only print the object that would be sent, without sending it.
forcefalseContinue even if there are pods not managed by a ReplicationController, ReplicaSet, Job, DaemonSet or StatefulSet.
grace-period-1Period of time in seconds given to each pod to terminate gracefully. If negative, the default value specified in the pod will be used.
ignore-daemonsetsfalseIgnore DaemonSet-managed pods.
pod-selectorLabel selector to filter pods on the node
selectorlSelector (label query) to filter on
timeout0sThe length of time to wait before giving up, zero means infinite
-
-

taint

-
-

Update node 'foo' with a taint with key 'dedicated' and value 'special-user' and effect 'NoSchedule'. # If a taint with that key and effect already exists, its value is replaced as specified.

-
-
kubectl taint nodes foo dedicated=special-user:NoSchedule
-
-
-

Remove from node 'foo' the taint with key 'dedicated' and effect 'NoSchedule' if one exists.

-
-
kubectl taint nodes foo dedicated:NoSchedule-
-
-
-

Remove from node 'foo' all the taints with key 'dedicated'

-
-
kubectl taint nodes foo dedicated-
-
-
-

Add a taint with key 'dedicated' on nodes having label mylabel=X

-
-
kubectl taint node -l myLabel=X  dedicated=foo:PreferNoSchedule
-
-

Update the taints on one or more nodes.

-
    -
  • A taint consists of a key, value, and effect. As an argument here, it is expressed as key=value:effect.
  • -
  • The key must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 253 characters.
  • -
  • Optionally, the key can begin with a DNS subdomain prefix and a single '/', like example.com/my-app
  • -
  • The value must begin with a letter or number, and may contain letters, numbers, hyphens, dots, and underscores, up to 63 characters.
  • -
  • The effect must be NoSchedule, PreferNoSchedule or NoExecute.
  • -
  • Currently taint can only apply to node.
  • -
-

Usage

-

$ taint NODE NAME KEY_1=VAL_1:TAINT_EFFECT_1 ... KEY_N=VAL_N:TAINT_EFFECT_N

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
allfalseSelect all nodes in the cluster
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
include-extended-apistrueIf true, include definitions of new APIs via calls to the API server. [default true]
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
output-versionDEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob').
overwritefalseIf true, allow taints to be overwritten, otherwise reject taint updates that overwrite existing taints.
selectorlSelector (label query) to filter on, supports '=', '==', and '!='.(e.g. -l key1=value1,key2=value2)
show-allatrueWhen printing, show all resources (default show all pods including terminated one.)
show-labelsfalseWhen printing, show all labels as the last column (default hide labels column)
sort-byIf non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string.
templateTemplate string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview].
validatetrueIf true, use a schema to validate the input before sending it
-
-

uncordon

-
-

Mark node "foo" as schedulable.

-
-
$ kubectl uncordon foo
-
-

Mark node as schedulable.

-

Usage

-

$ uncordon NODE

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
dry-runfalseIf true, only print the object that would be sent, without sending it.
selectorlSelector (label query) to filter on
-

KUBECTL SETTINGS AND USAGE

-
-

alpha

-

These commands correspond to alpha features that are not enabled in Kubernetes clusters by default.

-

Usage

-

$ alpha

-
-

diff

-
-

Diff resources included in pod.json. By default, it will diff LOCAL and LIVE versions

-
-
kubectl alpha diff -f pod.json
-
-
-

When one version is specified, diff that version against LIVE

-
-
cat service.yaml | kubectl alpha diff -f - MERGED
-
-
-

Or specify both versions

-
-
kubectl alpha diff -f pod.json -f service.yaml LAST LOCAL
-
-

Diff configurations specified by filename or stdin between their local, last-applied, live and/or "merged" versions.

-

LOCAL and LIVE versions are diffed by default. Other available keywords are MERGED and LAST.

-

Output is always YAML.

-

KUBERNETES EXTERNAL DIFF environment variable can be used to select your own diff command. By default, the "diff" command available in your path will be run with "-u" (unicode) and "-N" (treat new files as empty) options.

-

Usage

-

$ diff -f FILENAME

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
filenamef[]Filename, directory, or URL to files contains the configuration to diff
recursiveRfalseProcess the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
-
-

completion

-
-

Installing bash completion on macOS using homebrew ## If running Bash 3.2 included with macOS

-
-
brew install bash-completion
-
-
-

or, if running Bash 4.1+

-
-
brew install bash-completion@2
-
-
-

If kubectl is installed via homebrew, this should start working immediately. ## If you've installed via other means, you may need add the completion to your completion directory

-
-
kubectl completion bash > $(brew --prefix)/etc/bash_completion.d/kubectl
-
-
-

Installing bash completion on Linux ## Load the kubectl completion code for bash into the current shell

-
-
source <(kubectl completion bash)
-
-
-

Write bash completion code to a file and source if from .bash_profile

-
-
kubectl completion bash > ~/.kube/completion.bash.inc
-printf "
-
-
-

Kubectl shell completion

-
-
source '$HOME/.kube/completion.bash.inc'
-" >> $HOME/.bash_profile
-source $HOME/.bash_profile
-
-
-

Load the kubectl completion code for zsh[1] into the current shell

-
-
source <(kubectl completion zsh)
-
-
-

Set the kubectl completion code for zsh[1] to autoload on startup

-
-
kubectl completion zsh > "${fpath[1]}/_kubectl"
-
-

Output shell completion code for the specified shell (bash or zsh). The shell code must be evaluated to provide interactive completion of kubectl commands. This can be done by sourcing it from the .bash _profile.

-

Detailed instructions on how to do this are available here: https://kubernetes.io/docs/tasks/tools/install-kubectl/#enabling-shell-autocompletion

-

Note for zsh users: [1] zsh completions are only supported in versions of zsh >= 5.2

-

Usage

-

$ completion SHELL

-
-

config

-

Modify kubeconfig files using subcommands like "kubectl config set current-context my-context"

-

The loading order follows these rules:

-
    -
  1. If the --kubeconfig flag is set, then only that file is loaded. The flag may only be set once and no merging takes place.
  2. -
  3. If $KUBECONFIG environment variable is set, then it is used a list of paths (normal path delimitting rules for your system). These paths are merged. When a value is modified, it is modified in the file that defines the stanza. When a value is created, it is created in the first file that exists. If no files in the chain exist, then it creates the last file in the list.
  4. -
  5. Otherwise, ${HOME}/.kube/config is used and no merging takes place.
  6. -
-

Usage

-

$ config SUBCOMMAND

-
-

current-context

-
-

Display the current-context

-
-
kubectl config current-context
-
-

Displays the current-context

-

Usage

-

$ current-context

-
-

delete-cluster

-
-

Delete the minikube cluster

-
-
kubectl config delete-cluster minikube
-
-

Delete the specified cluster from the kubeconfig

-

Usage

-

$ delete-cluster NAME

-
-

delete-context

-
-

Delete the context for the minikube cluster

-
-
kubectl config delete-context minikube
-
-

Delete the specified context from the kubeconfig

-

Usage

-

$ delete-context NAME

-
-

get-clusters

-
-

List the clusters kubectl knows about

-
-
kubectl config get-clusters
-
-

Display clusters defined in the kubeconfig.

-

Usage

-

$ get-clusters

-
-

get-contexts

-
-

List all the contexts in your kubeconfig file

-
-
kubectl config get-contexts
-
-
-

Describe one context in your kubeconfig file.

-
-
kubectl config get-contexts my-context
-
-

Displays one or many contexts from the kubeconfig file.

-

Usage

-

$ get-contexts [(-o|--output=)name)]

-

Flags

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
allow-missing-template-keystrueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats.
no-headersfalseWhen using the default or custom-column output format, don't print headers (default print headers).
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath].
-
-

rename-context

-
-

Rename the context 'old-name' to 'new-name' in your kubeconfig file

-
-
kubectl config rename-context old-name new-name
-
-

Renames a context from the kubeconfig file.

-

CONTEXT _NAME is the context name that you wish change.

-

NEW _NAME is the new name you wish to set.

-

Note: In case the context being renamed is the 'current-context', this field will also be updated.

-

Usage

-

$ rename-context CONTEXT_NAME NEW_NAME

-
-

set

-

Sets an individual value in a kubeconfig file

-

PROPERTY _NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.

-

PROPERTY _VALUE is the new value you wish to set. Binary fields such as 'certificate-authority-data' expect a base64 encoded string unless the --set-raw-bytes flag is used.

-

Usage

-

$ set PROPERTY_NAME PROPERTY_VALUE

-

Flags

- - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
set-raw-bytesfalseWhen writing a []byte PROPERTY_VALUE, write the given string directly without base64 decoding.
-
-

set-cluster

-
-

Set only the server field on the e2e cluster entry without touching other values.

-
-
kubectl config set-cluster e2e --server=https://1.2.3.4
-
-
-

Embed certificate authority data for the e2e cluster entry

-
-
kubectl config set-cluster e2e --certificate-authority=~/.kube/e2e/kubernetes.ca.crt
-
-
-

Disable cert checking for the dev cluster entry

-
-
kubectl config set-cluster e2e --insecure-skip-tls-verify=true
-
-

Sets a cluster entry in kubeconfig.

-

Specifying a name that already exists will merge new fields on top of existing values for those fields.

-

Usage

-

$ set-cluster NAME [--server=server] [--certificate-authority=path/to/certificate/authority] [--insecure-skip-tls-verify=true]

-

Flags

- - - - - - - - - - - - - - - - - -
NameShorthandDefaultUsage
embed-certsfalseembed-certs for the cluster entry in kubeconfig
-
-

set-context

-
-

Set the user field on the gce context entry without touching other values

-
-
kubectl config set-context gce --user=cluster-admin
-
-

Sets a context entry in kubeconfig

-

Specifying a name that already exists will merge new fields on top of existing values for those fields.

-

Usage

-

$ set-context NAME [--cluster=cluster_nickname] [--user=user_nickname] [--namespace=namespace]

-
-

set-credentials

-
-

Set only the "client-key" field on the "cluster-admin" # entry, without touching other values:

-
-
kubectl config set-credentials cluster-admin --client-key=~/.kube/admin.key
-
-
-

Set basic auth for the "cluster-admin" entry

-
-
kubectl config set-credentials cluster-admin --username=admin --password=uXFGweU9l35qcif
-
-
-

Embed client certificate data in the "cluster-admin" entry

-
-
kubectl config set-credentials cluster-admin --client-certificate=~/.kube/admin.crt --embed-certs=true
-
-
-

Enable the Google Compute Platform auth provider for the "cluster-admin" entry

-
-
kubectl config set-credentials cluster-admin --auth-provider=gcp
-
-
-

Enable the OpenID Connect auth provider for the "cluster-admin" entry with additional args

-
-
kubectl config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-id=foo --auth-provider-arg=client-secret=bar
-
-
-

Remove the "client-secret" config value for the OpenID Connect auth provider for the "cluster-admin" entry

-
-
kubectl config set-credentials cluster-admin --auth-provider=oidc --auth-provider-arg=client-secret-
-
-

Sets a user entry in kubeconfig

-

Specifying a name that already exists will merge new fields on top of existing values.

-

Client-certificate flags: - --client-certificate=certfile --client-key=keyfile

-

Bearer token flags: - --token=bearer_token

-

Basic auth flags: - --username=basic_user --password=basic_password

-

Bearer token and basic auth are mutually exclusive.

-

Usage

-

$ set-credentials NAME [--client-certificate=path/to/certfile] [--client-key=path/to/keyfile] [--token=bearer_token] [--username=basic_user] [--password=basic_password] [--auth-provider=provider_name] [--auth-provider-arg=key=value]

-

Flags

- - - - - - - - - - - - - - + - + - - + + - + - - - - -
NameShorthandDefaultUsage
auth-provider Auth provider for the user entry in kubeconfig An inline JSON override for the generated object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field.
auth-provider-argpod-running-timeout []'key=value' arguments for the auth provider 1m0sThe length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one pod is running
embed-certsport falseEmbed client cert/key for the user entry in kubeconfig
-
-

unset

-
-

Unset the current-context.

-
-
kubectl config unset current-context
-
-
-

Unset namespace in foo context.

-
-
kubectl config unset contexts.foo.namespace
-
-

Unsets an individual value in a kubeconfig file

-

PROPERTY _NAME is a dot delimited name where each token represents either an attribute name or a map key. Map keys may not contain dots.

-

Usage

-

$ unset PROPERTY_NAME

-
-

use-context

-
-

Use the context for the minikube cluster

-
-
kubectl config use-context minikube
-
-

Sets the current-context in a kubeconfig file

-

Usage

-

$ use-context CONTEXT_NAME

-
-

view

-
-

Show Merged kubeconfig settings.

-
-
kubectl config view
-
-
-

Get the password for the e2e user

-
-
kubectl config view -o jsonpath='{.users[?(@.name == "e2e")].user.password}'
-
-

Display merged kubeconfig settings or a specified kubeconfig file.

-

You can use --output jsonpath={...} to extract specific values using a jsonpath expression.

-

Usage

-

$ view

-

Flags

- - - - - - - - - - - - - - + - + - - - - - - - + - + - + - - + + - + - - - - + + + + - + - + - + - - - - - - - - + + - + - + - - + - + + - + - + - -
NameShorthandDefaultUsage
allow-missing-template-keys trueIf true, ignore any errors in templates when a field or map key is missing in the template. Only applies to golang and jsonpath output formats. The port that this container exposes. If --expose is true, this is also the port used by the service that is created.
flattenquiet falseFlatten the resulting kubeconfig file into self-contained output (useful for creating portable kubeconfig files)
mergetrueMerge the full hierarchy of kubeconfig files If true, suppress prompt messages.
minifyrecord falseRemove all information not used by current-context from the output Record current kubectl command in the resource annotation. If set to false, do not record the command. If set to true, record the command. If not set, default to updating the existing annotation value only if one already exists.
no-headersrecursiveR falseWhen using the default or custom-column output format, don't print headers (default print headers). Process the directory used in -f, --filename recursively. Useful when you want to manage related manifests organized within the same directory.
outputoOutput format. One of: json|yaml|wide|name|custom-columns=...|custom-columns-file=...|go-template=...|go-template-file=...|jsonpath=...|jsonpath-file=... See custom columns [http://kubernetes.io/docs/user-guide/kubectl-overview/#custom-columns], golang template [http://golang.org/pkg/text/template/#pkg-overview] and jsonpath template [http://kubernetes.io/docs/user-guide/jsonpath]. replicasr1Number of replicas to create for this container. Default is 1.
output-versionrequests DEPRECATED: To use a specific API version, fully-qualify the resource, version, and group (for example: 'jobs.v1.batch/myjob'). The resource requirement requests for this container. For example, 'cpu=100m,memory=256Mi'. Note that server side components may assign requests depending on the server configuration, such as limit ranges.
rawrestart falseDisplay raw byte data
show-allatrueWhen printing, show all resources (default show all pods including terminated one.) AlwaysThe restart policy for this Pod. Legal values [Always, OnFailure, Never]. If set to 'Always' a deployment is created, if set to 'OnFailure' a job is created, if set to 'Never', a regular pod is created. For the latter two --replicas must be 1. Default 'Always', for CronJobs Never.
show-labelsrm falseWhen printing, show all labels as the last column (default hide labels column) If true, delete resources created in this command for attached containers.
sort-bysave-config If non-empty, sort list types using this field specification. The field specification is expressed as a JSONPath expression (e.g. '{.metadata.name}'). The field in the API resource specified by this JSONPath expression must be an integer or a string. falseIf true, the configuration of current object will be saved in its annotation. Otherwise, the annotation will be unchanged. This flag is useful when you want to perform kubectl apply on this object in the future.
templateschedule Template string or path to template file to use when -o=go-template, -o=go-template-file. The template format is golang templates [http://golang.org/pkg/text/template/#pkg-overview]. A schedule in the Cron format the job should be run with.
-
-

explain

-
-

Get the documentation of the resource and its fields

-
-
kubectl explain pods
-
-
-

Get the documentation of a specific field of a resource

-
-
kubectl explain pods.spec.containers
-
-

List the fields for supported resources

-

This command describes the fields associated with each supported API resource. Fields are identified via a simple JSONPath identifier:

-

.[.]

-

Add the --recursive flag to display all of the fields at once without descriptions. Information about each field is retrieved from the server in OpenAPI format.

-

Valid resource types include:

-
    -
  • all
  • -
  • certificatesigningrequests (aka 'csr')
  • -
  • clusterrolebindings
  • -
  • clusterroles
  • -
  • componentstatuses (aka 'cs')
  • -
  • configmaps (aka 'cm')
  • -
  • controllerrevisions
  • -
  • cronjobs
  • -
  • customresourcedefinition (aka 'crd')
  • -
  • daemonsets (aka 'ds')
  • -
  • deployments (aka 'deploy')
  • -
  • endpoints (aka 'ep')
  • -
  • events (aka 'ev')
  • -
  • horizontalpodautoscalers (aka 'hpa')
  • -
  • ingresses (aka 'ing')
  • -
  • jobs
  • -
  • limitranges (aka 'limits')
  • -
  • namespaces (aka 'ns')
  • -
  • networkpolicies (aka 'netpol')
  • -
  • nodes (aka 'no')
  • -
  • persistentvolumeclaims (aka 'pvc')
  • -
  • persistentvolumes (aka 'pv')
  • -
  • poddisruptionbudgets (aka 'pdb')
  • -
  • podpreset
  • -
  • pods (aka 'po')
  • -
  • podsecuritypolicies (aka 'psp')
  • -
  • podtemplates
  • -
  • replicasets (aka 'rs')
  • -
  • replicationcontrollers (aka 'rc')
  • -
  • resourcequotas (aka 'quota')
  • -
  • rolebindings
  • -
  • roles
  • -
  • secrets
  • -
  • serviceaccounts (aka 'sa')
  • -
  • services (aka 'svc')
  • -
  • statefulsets (aka 'sts')
  • -
  • storageclasses (aka 'sc')
  • -
-

Usage

-

$ explain RESOURCE

-

Flags

- - - - - - + + + + - - - + - + - + - - + + - - + + - + - -
NameShorthandDefaultUsageservice-generatorservice/v2The name of the generator to use for creating a service. Only used if --expose is true
api-versionservice-overrides Get different explanations for particular API version An inline JSON override for the generated service object. If this is non-empty, it is used to override the generated object. Requires that the object supply a valid apiVersion field. Only used if --expose is true.
include-extended-apisserviceaccount trueIf true, include definitions of new APIs via calls to the API server. [default true] Service account to set in the pod spec
recursivestdini falsePrint the fields of fields (Currently only 1 level deep) Keep stdin open on the container(s) in the pod, even if nothing is attached.
-
-

options

-
-

Print flags inherited by all commands

-
-
kubectl options
-
-

Print the list of flags inherited by all commands

-

Usage

-

$ options

-
-

version

-
-

Print the client and server versions for the current context

-
-
kubectl version
-
-

Print the client and server version information for the current context

-

Usage

-

$ version

-

Flags

- - - - - - + + + + - - - - + + - - - - - - - + - + - +
NameShorthandDefaultUsagetimeout0sThe length of time to wait before giving up on a delete, zero means determine a timeout from the size of the object
clientcttyt falseClient version only (no server required).
outputoOne of 'yaml' or 'json'. Allocated a TTY for each container in the pod.
shortwait falsePrint just the version number. If true, wait for resources to be gone before returning. This waits for finalizers.
-
-

plugin

-

Runs a command-line plugin.

-

Plugins are subcommands that are not part of the major command-line distribution and can even be provided by third-parties. Please refer to the documentation and examples for more information about how to install and write your own plugins.

-

Usage

-

$ plugin NAME

-

DEPRECATED COMMANDS

diff --git a/static/docs/reference/generated/kubectl/navData.js b/static/docs/reference/generated/kubectl/navData.js index 213410f5107cc..4df43b4b82ea0 100644 --- a/static/docs/reference/generated/kubectl/navData.js +++ b/static/docs/reference/generated/kubectl/navData.js @@ -1 +1 @@ -(function(){navData = {"toc":[{"section":"-strong-deprecated-commands-strong-","subsections":[]},{"section":"plugin","subsections":[]},{"section":"version","subsections":[]},{"section":"options","subsections":[]},{"section":"explain","subsections":[]},{"section":"config","subsections":[{"section":"-em-view-em-"},{"section":"-em-use-context-em-"},{"section":"-em-unset-em-"},{"section":"-em-set-credentials-em-"},{"section":"-em-set-context-em-"},{"section":"-em-set-cluster-em-"},{"section":"-em-set-em-"},{"section":"-em-rename-context-em-"},{"section":"-em-get-contexts-em-"},{"section":"-em-get-clusters-em-"},{"section":"-em-delete-context-em-"},{"section":"-em-delete-cluster-em-"},{"section":"-em-current-context-em-"}]},{"section":"completion","subsections":[]},{"section":"alpha","subsections":[{"section":"-em-diff-em-"}]},{"section":"-strong-kubectl-settings-and-usage-strong-","subsections":[]},{"section":"uncordon","subsections":[]},{"section":"taint","subsections":[]},{"section":"drain","subsections":[]},{"section":"cordon","subsections":[]},{"section":"cluster-info","subsections":[{"section":"-em-dump-em-"}]},{"section":"certificate","subsections":[{"section":"-em-deny-em-"},{"section":"-em-approve-em-"}]},{"section":"api-versions","subsections":[]},{"section":"-strong-cluster-management-strong-","subsections":[]},{"section":"top","subsections":[{"section":"-em-pod-em-"},{"section":"-em-node-em-"}]},{"section":"proxy","subsections":[]},{"section":"port-forward","subsections":[]},{"section":"logs","subsections":[]},{"section":"exec","subsections":[]},{"section":"describe","subsections":[]},{"section":"cp","subsections":[]},{"section":"auth","subsections":[{"section":"-em-reconcile-em-"},{"section":"-em-can-i-em-"}]},{"section":"attach","subsections":[]},{"section":"-strong-working-with-apps-strong-","subsections":[]},{"section":"apply","subsections":[{"section":"-em-view-last-applied-em-"},{"section":"-em-set-last-applied-em-"},{"section":"-em-edit-last-applied-em-"}]},{"section":"-strong-declarative-app-management-strong-","subsections":[]},{"section":"set","subsections":[{"section":"-em-subject-em-"},{"section":"-em-serviceaccount-em--1"},{"section":"-em-selector-em-"},{"section":"-em-resources-em-"},{"section":"-em-image-em-"},{"section":"-em-env-em-"}]},{"section":"scale","subsections":[]},{"section":"rollout","subsections":[{"section":"-em-undo-em-"},{"section":"-em-status-em-"},{"section":"-em-resume-em-"},{"section":"-em-pause-em-"},{"section":"-em-history-em-"}]},{"section":"rolling-update","subsections":[]},{"section":"replace","subsections":[]},{"section":"patch","subsections":[]},{"section":"label","subsections":[]},{"section":"get","subsections":[]},{"section":"edit","subsections":[]},{"section":"delete","subsections":[]},{"section":"create","subsections":[{"section":"-em-serviceaccount-em-"},{"section":"-em-service-nodeport-em-"},{"section":"-em-service-loadbalancer-em-"},{"section":"-em-service-externalname-em-"},{"section":"-em-service-clusterip-em-"},{"section":"-em-service-em-"},{"section":"-em-secret-tls-em-"},{"section":"-em-secret-generic-em-"},{"section":"-em-secret-docker-registry-em-"},{"section":"-em-secret-em-"},{"section":"-em-rolebinding-em-"},{"section":"-em-role-em-"},{"section":"-em-quota-em-"},{"section":"-em-priorityclass-em-"},{"section":"-em-poddisruptionbudget-em-"},{"section":"-em-namespace-em-"},{"section":"-em-job-em-"},{"section":"-em-deployment-em-"},{"section":"-em-configmap-em-"},{"section":"-em-clusterrolebinding-em-"},{"section":"-em-clusterrole-em-"}]},{"section":"convert","subsections":[]},{"section":"autoscale","subsections":[]},{"section":"annotate","subsections":[]},{"section":"-strong-app-management-strong-","subsections":[]},{"section":"expose","subsections":[]},{"section":"run-container","subsections":[]},{"section":"run","subsections":[]},{"section":"-strong-getting-started-strong-","subsections":[]}],"flatToc":["-strong-deprecated-commands-strong-","plugin","version","options","explain","-em-view-em-","-em-use-context-em-","-em-unset-em-","-em-set-credentials-em-","-em-set-context-em-","-em-set-cluster-em-","-em-set-em-","-em-rename-context-em-","-em-get-contexts-em-","-em-get-clusters-em-","-em-delete-context-em-","-em-delete-cluster-em-","-em-current-context-em-","config","completion","-em-diff-em-","alpha","-strong-kubectl-settings-and-usage-strong-","uncordon","taint","drain","cordon","-em-dump-em-","cluster-info","-em-deny-em-","-em-approve-em-","certificate","api-versions","-strong-cluster-management-strong-","-em-pod-em-","-em-node-em-","top","proxy","port-forward","logs","exec","describe","cp","-em-reconcile-em-","-em-can-i-em-","auth","attach","-strong-working-with-apps-strong-","-em-view-last-applied-em-","-em-set-last-applied-em-","-em-edit-last-applied-em-","apply","-strong-declarative-app-management-strong-","-em-subject-em-","-em-serviceaccount-em--1","-em-selector-em-","-em-resources-em-","-em-image-em-","-em-env-em-","set","scale","-em-undo-em-","-em-status-em-","-em-resume-em-","-em-pause-em-","-em-history-em-","rollout","rolling-update","replace","patch","label","get","edit","delete","-em-serviceaccount-em-","-em-service-nodeport-em-","-em-service-loadbalancer-em-","-em-service-externalname-em-","-em-service-clusterip-em-","-em-service-em-","-em-secret-tls-em-","-em-secret-generic-em-","-em-secret-docker-registry-em-","-em-secret-em-","-em-rolebinding-em-","-em-role-em-","-em-quota-em-","-em-priorityclass-em-","-em-poddisruptionbudget-em-","-em-namespace-em-","-em-job-em-","-em-deployment-em-","-em-configmap-em-","-em-clusterrolebinding-em-","-em-clusterrole-em-","create","convert","autoscale","annotate","-strong-app-management-strong-","expose","run-container","run","-strong-getting-started-strong-"]};})(); \ No newline at end of file +(function(){navData = {"toc":[{"section":"run-container","subsections":[]},{"section":"rolling-update","subsections":[]},{"section":"-strong-deprecated-commands-strong-","subsections":[]},{"section":"version","subsections":[]},{"section":"plugin","subsections":[]},{"section":"options","subsections":[]},{"section":"explain","subsections":[]},{"section":"config","subsections":[{"section":"-em-view-em-"},{"section":"-em-use-context-em-"},{"section":"-em-unset-em-"},{"section":"-em-set-credentials-em-"},{"section":"-em-set-context-em-"},{"section":"-em-set-cluster-em-"},{"section":"-em-set-em-"},{"section":"-em-rename-context-em-"},{"section":"-em-get-contexts-em-"},{"section":"-em-get-clusters-em-"},{"section":"-em-delete-context-em-"},{"section":"-em-delete-cluster-em-"},{"section":"-em-current-context-em-"}]},{"section":"completion","subsections":[]},{"section":"api-resources","subsections":[]},{"section":"alpha","subsections":[{"section":"-em-diff-em-"}]},{"section":"-strong-kubectl-settings-and-usage-strong-","subsections":[]},{"section":"uncordon","subsections":[]},{"section":"taint","subsections":[]},{"section":"drain","subsections":[]},{"section":"cordon","subsections":[]},{"section":"cluster-info","subsections":[{"section":"-em-dump-em-"}]},{"section":"certificate","subsections":[{"section":"-em-deny-em-"},{"section":"-em-approve-em-"}]},{"section":"api-versions","subsections":[]},{"section":"-strong-cluster-management-strong-","subsections":[]},{"section":"top","subsections":[{"section":"-em-pod-em-"},{"section":"-em-node-em-"}]},{"section":"proxy","subsections":[]},{"section":"port-forward","subsections":[]},{"section":"logs","subsections":[]},{"section":"exec","subsections":[]},{"section":"describe","subsections":[]},{"section":"cp","subsections":[]},{"section":"auth","subsections":[{"section":"-em-reconcile-em-"},{"section":"-em-can-i-em-"}]},{"section":"attach","subsections":[]},{"section":"-strong-working-with-apps-strong-","subsections":[]},{"section":"wait","subsections":[]},{"section":"set","subsections":[{"section":"-em-subject-em-"},{"section":"-em-serviceaccount-em--1"},{"section":"-em-selector-em-"},{"section":"-em-resources-em-"},{"section":"-em-image-em-"},{"section":"-em-env-em-"}]},{"section":"scale","subsections":[]},{"section":"rollout","subsections":[{"section":"-em-undo-em-"},{"section":"-em-status-em-"},{"section":"-em-resume-em-"},{"section":"-em-pause-em-"},{"section":"-em-history-em-"}]},{"section":"replace","subsections":[]},{"section":"patch","subsections":[]},{"section":"label","subsections":[]},{"section":"edit","subsections":[]},{"section":"convert","subsections":[]},{"section":"autoscale","subsections":[]},{"section":"annotate","subsections":[]},{"section":"apply","subsections":[{"section":"-em-view-last-applied-em-"},{"section":"-em-set-last-applied-em-"},{"section":"-em-edit-last-applied-em-"}]},{"section":"-strong-app-management-strong-","subsections":[]},{"section":"delete","subsections":[]},{"section":"expose","subsections":[]},{"section":"run","subsections":[]},{"section":"get","subsections":[]},{"section":"create","subsections":[{"section":"-em-serviceaccount-em-"},{"section":"-em-service-nodeport-em-"},{"section":"-em-service-loadbalancer-em-"},{"section":"-em-service-externalname-em-"},{"section":"-em-service-clusterip-em-"},{"section":"-em-service-em-"},{"section":"-em-secret-tls-em-"},{"section":"-em-secret-generic-em-"},{"section":"-em-secret-docker-registry-em-"},{"section":"-em-secret-em-"},{"section":"-em-rolebinding-em-"},{"section":"-em-role-em-"},{"section":"-em-quota-em-"},{"section":"-em-priorityclass-em-"},{"section":"-em-poddisruptionbudget-em-"},{"section":"-em-namespace-em-"},{"section":"-em-job-em-"},{"section":"-em-deployment-em-"},{"section":"-em-configmap-em-"},{"section":"-em-clusterrolebinding-em-"},{"section":"-em-clusterrole-em-"}]},{"section":"-strong-getting-started-strong-","subsections":[]}],"flatToc":["run-container","rolling-update","-strong-deprecated-commands-strong-","version","plugin","options","explain","-em-view-em-","-em-use-context-em-","-em-unset-em-","-em-set-credentials-em-","-em-set-context-em-","-em-set-cluster-em-","-em-set-em-","-em-rename-context-em-","-em-get-contexts-em-","-em-get-clusters-em-","-em-delete-context-em-","-em-delete-cluster-em-","-em-current-context-em-","config","completion","api-resources","-em-diff-em-","alpha","-strong-kubectl-settings-and-usage-strong-","uncordon","taint","drain","cordon","-em-dump-em-","cluster-info","-em-deny-em-","-em-approve-em-","certificate","api-versions","-strong-cluster-management-strong-","-em-pod-em-","-em-node-em-","top","proxy","port-forward","logs","exec","describe","cp","-em-reconcile-em-","-em-can-i-em-","auth","attach","-strong-working-with-apps-strong-","wait","-em-subject-em-","-em-serviceaccount-em--1","-em-selector-em-","-em-resources-em-","-em-image-em-","-em-env-em-","set","scale","-em-undo-em-","-em-status-em-","-em-resume-em-","-em-pause-em-","-em-history-em-","rollout","replace","patch","label","edit","convert","autoscale","annotate","-em-view-last-applied-em-","-em-set-last-applied-em-","-em-edit-last-applied-em-","apply","-strong-app-management-strong-","delete","expose","run","get","-em-serviceaccount-em-","-em-service-nodeport-em-","-em-service-loadbalancer-em-","-em-service-externalname-em-","-em-service-clusterip-em-","-em-service-em-","-em-secret-tls-em-","-em-secret-generic-em-","-em-secret-docker-registry-em-","-em-secret-em-","-em-rolebinding-em-","-em-role-em-","-em-quota-em-","-em-priorityclass-em-","-em-poddisruptionbudget-em-","-em-namespace-em-","-em-job-em-","-em-deployment-em-","-em-configmap-em-","-em-clusterrolebinding-em-","-em-clusterrole-em-","create","-strong-getting-started-strong-"]};})(); \ No newline at end of file diff --git a/static/docs/reference/generated/kubectl/scroll.js b/static/docs/reference/generated/kubectl/scroll.js index 6639f62895616..67fee8729e449 100644 --- a/static/docs/reference/generated/kubectl/scroll.js +++ b/static/docs/reference/generated/kubectl/scroll.js @@ -187,10 +187,10 @@ $(document).ready(function() { var scrollPosition = $(window).scrollTop(); scrollActions(scrollPosition); checkActiveElement(flatToc, scrollPosition); - // TODO: prevent scroll on sidebar from propagating to window + // TODO: prevent scroll on sidebar from propogating to window $(window).on('scroll', function(event) { var scrollPosition = $(window).scrollTop(); var activeSectionTokens = scrollActions(scrollPosition); var activeElemToken = checkActiveElement(flatToc, scrollPosition); }); -}); +}); \ No newline at end of file