kubernetes reference contenttype tool reference heading synopsis weight 30 kubectl controls the Kubernetes cluster manager title kubectl

Answer:
---
title: kubectl
content_type: tool-reference
weight: 30
---

##

kubectl controls the Kubernetes cluster manager.

Find more information in [Command line tool](/docs/reference/kubectl/) (`kubectl`).

```shell
kubectl [flags]
```

##

<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />
</colgroup>

--add-dir-header

	If true, adds the file directory to the header of the log messages

--alsologtostderr

	log to standard error as well as files

--as string

	Username to impersonate for the operation

--as-group stringArray

	Group to impersonate for the operation, this flag can be repeated to specify multiple groups.

--azure-container-registry-config string

	Path to the file containing Azure container registry configuration information.

--cache-dir string     Default: "$HOME/.kube/cache"

	Default cache directory

--certificate-authority string

	Path to a cert file for the certificate authority

--client-certificate string

	Path to a client certificate file for TLS

--client-key string

	Path to a client key file for TLS

--cloud-provider-gce-l7lb-src-cidrs cidrs     Default: 130.211.0.0/22,35.191.0.0/16

	CIDRs opened in GCE firewall for L7 LB traffic proxy & health checks

--cloud-provider-gce-lb-src-cidrs cidrs     Default: 130.211.0.0/22,209.85.152.0/22,209.85.204.0/22,35.191.0.0/16

	CIDRs opened in GCE firewall for L4 LB traffic proxy & health checks

--cluster string

	The name of the kubeconfig cluster to use

--context string

	The name of the kubeconfig context to use

--default-not-ready-toleration-seconds int     Default: 300

	Indicates the tolerationSeconds of the toleration for notReady:NoExecute that is added by default to every pod that does not already have such a toleration.

--default-unreachable-toleration-seconds int     Default: 300

	Indicates the tolerationSeconds of the toleration for unreachable:NoExecute that is added by default to every pod that does not already have such a toleration.

-h, --help

	help for kubectl

--insecure-skip-tls-verify

	If true, the server's certificate will not be checked for validity. This will make your HTTPS connections insecure

--kubeconfig string

	Path to the kubeconfig file to use for CLI requests.

--log-backtrace-at traceLocation     Default: :0

	when logging hits line file:N, emit a stack trace

--log-dir string

	If non-empty, write log files in this directory

--log-file string

	If non-empty, use this log file

--log-file-max-size uint     Default: 1800

	Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited.

--log-flush-frequency duration     Default: 5s

	Maximum number of seconds between log flushes

--logtostderr     Default: true

	log to standard error instead of files

--match-server-version

	Require server version to match client version

-n, --namespace string

	If present, the namespace scope for this CLI request

--one-output

	If true, only write logs to their native severity level (vs also writing to each lower severity level)

--password string

	Password for basic authentication to the API server

--profile string     Default: "none"

	Name of profile to capture. One of (none|cpu|heap|goroutine|threadcreate|block|mutex)

--profile-output string     Default: "profile.pprof"

	Name of the file to write the profile to

--request-timeout string     Default: "0"

	The length of time to wait before giving up on a single server request. Non-zero values should contain a corresponding time unit (e.g. 1s, 2m, 3h). A value of zero means don't timeout requests.

-s, --server string

	The address and port of the Kubernetes API server

--skip-headers

	If true, avoid header prefixes in the log messages

--skip-log-headers

	If true, avoid headers when opening log files

--stderrthreshold severity     Default: 2

	logs at or above this threshold go to stderr

--tls-server-name string

	Server name to use for server certificate validation. If it is not provided, the hostname used to contact the server is used

--token string

	Bearer token for authentication to the API server

--user string

	The name of the kubeconfig user to use

--username string

	Username for basic authentication to the API server

-v, --v Level

	number for the log level verbosity

--version version[=true]

	Print version information and quit

--vmodule moduleSpec

	comma-separated list of pattern=N settings for file-filtered logging

--warnings-as-errors

	Treat warnings received from the server as errors and exit with a non-zero exit code

##

<colgroup>
<col span="1" style="width: 10px;" />
<col span="1" />
</colgroup>

KUBECONFIG

	Path to the kubectl configuration ("kubeconfig") file. Default: "$HOME/.kube/config"

KUBECTL_COMMAND_HEADERS

	When set to false, turns off extra HTTP headers detailing invoked kubectl command (Kubernetes version v1.22 or later)

KUBECTL_DEBUG_CUSTOM_PROFILE

	When set to true, custom flag will be enabled in kubectl debug. This flag is used to customize the pre-defined profiles.

KUBECTL_EXPLAIN_OPENAPIV3

	Toggles whether calls to `kubectl explain` use the new OpenAPIv3 data source available. OpenAPIV3 is enabled by default since Kubernetes 1.24.

KUBECTL_ENABLE_CMD_SHADOW

	When set to true, external plugins can be used as subcommands for builtin commands if subcommand does not exist. In alpha stage, this feature can only be used for create command(e.g. kubectl create networkpolicy).

KUBECTL_PORT_FORWARD_WEBSOCKETS

	When set to true, the kubectl port-forward command will attempt to stream using the websockets protocol. If the upgrade to websockets fails, the commands will fallback to use the current SPDY protocol.

KUBECTL_REMOTE_COMMAND_WEBSOCKETS

	When set to true, the kubectl exec, cp, and attach commands will attempt to stream using the websockets protocol. If the upgrade to websockets fails, the commands will fallback to use the current SPDY protocol.

##

* [kubectl annotate](/docs/reference/kubectl/generated/kubectl_annotate/) - Update the annotations on a resource
* [kubectl api-resources](/docs/reference/kubectl/generated/kubectl_api-resources/) - Print the supported API resources on the server
* [kubectl api-versions](/docs/reference/kubectl/generated/kubectl_api-versions/) - Print the supported API versions on the server,
  in the form of "group/version"
* [kubectl apply](/docs/reference/kubectl/generated/kubectl_apply/) - Apply a configuration to a resource by filename or stdin
* [kubectl attach](/docs/reference/kubectl/generated/kubectl_attach/) - Attach to a running container
* [kubectl auth](/docs/reference/kubectl/generated/kubectl_auth/) - Inspect authorization
* [kubectl autoscale](/docs/reference/kubectl/generated/kubectl_autoscale/) - Auto-scale a Deployment, ReplicaSet, or ReplicationController
* [kubectl certificate](/docs/reference/kubectl/generated/kubectl_certificate/) - Modify certificate resources.
* [kubectl cluster-info](/docs/reference/kubectl/generated/kubectl_cluster-info/) - Display cluster info
* [kubectl completion](/docs/reference/kubectl/generated/kubectl_completion/) - Output shell completion code for the specified shell (bash or zsh)
* [kubectl config](/docs/reference/kubectl/generated/kubectl_config/) - Modify kubeconfig files
* [kubectl cordon](/docs/reference/kubectl/generated/kubectl_cordon/) - Mark node as unschedulable
* [kubectl cp](/docs/reference/kubectl/generated/kubectl_cp/) - Copy files and directories to and from containers.
* [kubectl create](/docs/reference/kubectl/generated/kubectl_create/) - Create a resource from a file or from stdin.
* [kubectl debug](/docs/reference/kubectl/generated/kubectl_debug/) - Create debugging sessions for troubleshooting workloads and nodes
* [kubectl delete](/docs/reference/kubectl/generated/kubectl_delete/) - Delete resources by filenames,
  stdin, resources and names, or by resources and label selector
* [kubectl describe](/docs/reference/kubectl/generated/kubectl_describe/) - Show details of a specific resource or group of resources
* [kubectl diff](/docs/reference/kubectl/generated/kubectl_diff/) - Diff live version against would-be applied version
* [kubectl drain](/docs/reference/kubectl/generated/kubectl_drain/) - Drain node in preparation for maintenance
* [kubectl edit](/docs/reference/kubectl/generated/kubectl_edit/) - Edit a resource on the server
* [kubectl events](/docs/reference/kubectl/generated/kubectl_events/)  - List events
* [kubectl exec](/docs/reference/kubectl/generated/kubectl_exec/) - Execute a command in a container
* [kubectl explain](/docs/reference/kubectl/generated/kubectl_explain/) - Documentation of resources
* [kubectl expose](/docs/reference/kubectl/generated/kubectl_expose/) - Take a replication controller,
  service, deployment or pod and expose it as a new Kubernetes Service
* [kubectl get](/docs/reference/kubectl/generated/kubectl_get/) - Display one or many resources
* [kubectl kustomize](/docs/reference/kubectl/generated/kubectl_kustomize/) - Build a kustomization
  target from a directory or a remote url.
* [kubectl label](/docs/reference/kubectl/generated/kubectl_label/) - Update the labels on a resource
* [kubectl logs](/docs/reference/kubectl/generated/kubectl_logs/) - Print the logs for a container in a pod
* [kubectl options](/docs/reference/kubectl/generated/kubectl_options/) - Print the list of flags inherited by all commands
* [kubectl patch](/docs/reference/kubectl/generated/kubectl_patch/) - Update field(s) of a resource
* [kubectl plugin](/docs/reference/kubectl/generated/kubectl_plugin/) - Provides utilities for interacting with plugins.
* [kubectl port-forward](/docs/reference/kubectl/generated/kubectl_port-forward/) - Forward one or more local ports to a pod
* [kubectl proxy](/docs/reference/kubectl/generated/kubectl_proxy/) - Run a proxy to the Kubernetes API server
* [kubectl replace](/docs/reference/kubectl/generated/kubectl_replace/) - Replace a resource by filename or stdin
* [kubectl rollout](/docs/reference/kubectl/generated/kubectl_rollout/) - Manage the rollout of a resource
* [kubectl run](/docs/reference/kubectl/generated/kubectl_run/) - Run a particular image on the cluster
* [kubectl scale](/docs/reference/kubectl/generated/kubectl_scale/) - Set a new size for a Deployment, ReplicaSet or Replication Controller
* [kubectl set](/docs/reference/kubectl/generated/kubectl_set/) - Set specific features on objects
* [kubectl taint](/docs/reference/kubectl/generated/kubectl_taint/) - Update the taints on one or more nodes
* [kubectl top](/docs/reference/kubectl/generated/kubectl_top/) - Display Resource (CPU/Memory/Storage) usage.
* [kubectl uncordon](/docs/reference/kubectl/generated/kubectl_uncordon/) - Mark node as schedulable
* [kubectl version](/docs/reference/kubectl/generated/kubectl_version/) - Print the client and server version information
* [kubectl wait](/docs/reference/kubectl/generated/kubectl_wait/) - Experimental: Wait for a specific condition on one or many resources.

title  kubectl content type  tool reference weight  30           kubectl controls the Kubernetes cluster manager   Find more information in  Command line tool   docs reference kubectl     kubectl        shell kubectl  flags                table style  width  100   table layout  fixed     colgroup   col span  1  style  width  10px       col span  1       colgroup   tbody    tr   td colspan  2    add dir header  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If true  adds the file directory to the header of the log messages  td    tr    tr   td colspan  2    alsologtostderr  td    tr   tr   td   td  td style  line height  130   word wrap  break word   log to standard error as well as files  td    tr    tr   td colspan  2    as string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Username to impersonate for the operation  td    tr    tr   td colspan  2    as group stringArray  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Group to impersonate for the operation  this flag can be repeated to specify multiple groups   td    tr    tr   td colspan  2    azure container registry config string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to the file containing Azure container registry configuration information   td    tr    tr   td colspan  2    cache dir string nbsp  nbsp  nbsp  nbsp  nbsp Default    HOME  kube cache   td    tr   tr   td   td  td style  line height  130   word wrap  break word   Default cache directory  td    tr    tr   td colspan  2    certificate authority string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to a cert file for the certificate authority  td    tr    tr   td colspan  2    client certificate string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to a client certificate file for TLS  td    tr    tr   td colspan  2    client key string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to a client key file for TLS  td    tr    tr   td colspan  2    cloud provider gce l7lb src cidrs cidrs nbsp  nbsp  nbsp  nbsp  nbsp Default  130 211 0 0 22 35 191 0 0 16  td    tr   tr   td   td  td style  line height  130   word wrap  break word   CIDRs opened in GCE firewall for L7 LB traffic proxy   health checks  td    tr    tr   td colspan  2    cloud provider gce lb src cidrs cidrs nbsp  nbsp  nbsp  nbsp  nbsp Default  130 211 0 0 22 209 85 152 0 22 209 85 204 0 22 35 191 0 0 16  td    tr   tr   td   td  td style  line height  130   word wrap  break word   CIDRs opened in GCE firewall for L4 LB traffic proxy   health checks  td    tr    tr   td colspan  2    cluster string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   The name of the kubeconfig cluster to use  td    tr    tr   td colspan  2    context string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   The name of the kubeconfig context to use  td    tr    tr   td colspan  2    default not ready toleration seconds int nbsp  nbsp  nbsp  nbsp  nbsp Default  300  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Indicates the tolerationSeconds of the toleration for notReady NoExecute that is added by default to every pod that does not already have such a toleration   td    tr    tr   td colspan  2    default unreachable toleration seconds int nbsp  nbsp  nbsp  nbsp  nbsp Default  300  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Indicates the tolerationSeconds of the toleration for unreachable NoExecute that is added by default to every pod that does not already have such a toleration   td    tr    tr   td colspan  2   h    help  td    tr   tr   td   td  td style  line height  130   word wrap  break word   help for kubectl  td    tr    tr   td colspan  2    insecure skip tls verify  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If true  the server s certificate will not be checked for validity  This will make your HTTPS connections insecure  td    tr    tr   td colspan  2    kubeconfig string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to the kubeconfig file to use for CLI requests   td    tr    tr   td colspan  2    log backtrace at traceLocation nbsp  nbsp  nbsp  nbsp  nbsp Default   0  td    tr   tr   td   td  td style  line height  130   word wrap  break word   when logging hits line file N  emit a stack trace  td    tr    tr   td colspan  2    log dir string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If non empty  write log files in this directory  td    tr    tr   td colspan  2    log file string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If non empty  use this log file  td    tr    tr   td colspan  2    log file max size uint nbsp  nbsp  nbsp  nbsp  nbsp Default  1800  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Defines the maximum size a log file can grow to  Unit is megabytes  If the value is 0  the maximum file size is unlimited   td    tr    tr   td colspan  2    log flush frequency duration nbsp  nbsp  nbsp  nbsp  nbsp Default  5s  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Maximum number of seconds between log flushes  td    tr    tr   td colspan  2    logtostderr nbsp  nbsp  nbsp  nbsp  nbsp Default  true  td    tr   tr   td   td  td style  line height  130   word wrap  break word   log to standard error instead of files  td    tr    tr   td colspan  2    match server version  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Require server version to match client version  td    tr    tr   td colspan  2   n    namespace string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If present  the namespace scope for this CLI request  td    tr    tr   td colspan  2    one output  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If true  only write logs to their native severity level  vs also writing to each lower severity level   td    tr    tr   td colspan  2    password string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Password for basic authentication to the API server  td    tr    tr   td colspan  2    profile string nbsp  nbsp  nbsp  nbsp  nbsp Default   none   td    tr   tr   td   td  td style  line height  130   word wrap  break word   Name of profile to capture  One of  none cpu heap goroutine threadcreate block mutex   td    tr    tr   td colspan  2    profile output string nbsp  nbsp  nbsp  nbsp  nbsp Default   profile pprof   td    tr   tr   td   td  td style  line height  130   word wrap  break word   Name of the file to write the profile to  td    tr    tr   td colspan  2    request timeout string nbsp  nbsp  nbsp  nbsp  nbsp Default   0   td    tr   tr   td   td  td style  line height  130   word wrap  break word   The length of time to wait before giving up on a single server request  Non zero values should contain a corresponding time unit  e g  1s  2m  3h   A value of zero means don t timeout requests   td    tr    tr   td colspan  2   s    server string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   The address and port of the Kubernetes API server  td    tr    tr   td colspan  2    skip headers  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If true  avoid header prefixes in the log messages  td    tr    tr   td colspan  2    skip log headers  td    tr   tr   td   td  td style  line height  130   word wrap  break word   If true  avoid headers when opening log files  td    tr    tr   td colspan  2    stderrthreshold severity nbsp  nbsp  nbsp  nbsp  nbsp Default  2  td    tr   tr   td   td  td style  line height  130   word wrap  break word   logs at or above this threshold go to stderr  td    tr    tr   td colspan  2    tls server name string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Server name to use for server certificate validation  If it is not provided  the hostname used to contact the server is used  td    tr    tr   td colspan  2    token string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Bearer token for authentication to the API server  td    tr    tr   td colspan  2    user string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   The name of the kubeconfig user to use  td    tr    tr   td colspan  2    username string  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Username for basic authentication to the API server  td    tr    tr   td colspan  2   v    v Level  td    tr   tr   td   td  td style  line height  130   word wrap  break word   number for the log level verbosity  td    tr    tr   td colspan  2    version version  true   td    tr   tr   td   td  td style  line height  130   word wrap  break word   Print version information and quit  td    tr    tr   td colspan  2    vmodule moduleSpec  td    tr   tr   td   td  td style  line height  130   word wrap  break word   comma separated list of pattern N settings for file filtered logging  td    tr    tr   td colspan  2    warnings as errors  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Treat warnings received from the server as errors and exit with a non zero exit code  td    tr     tbody    table         table style  width  100   table layout  fixed     colgroup   col span  1  style  width  10px       col span  1       colgroup   tbody    tr   td colspan  2  KUBECONFIG  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Path to the kubectl configuration   kubeconfig   file  Default    HOME  kube config   td    tr    tr   td colspan  2  KUBECTL COMMAND HEADERS  td    tr   tr   td   td  td style  line height  130   word wrap  break word   When set to false  turns off extra HTTP headers detailing invoked kubectl command  Kubernetes version v1 22 or later   td    tr    tr   td colspan  2  KUBECTL DEBUG CUSTOM PROFILE  td    tr   tr   td   td  td style  line height  130   word wrap  break word   When set to true  custom flag will be enabled in kubectl debug  This flag is used to customize the pre defined profiles    td    tr    tr   td colspan  2  KUBECTL EXPLAIN OPENAPIV3  td    tr   tr   td   td  td style  line height  130   word wrap  break word   Toggles whether calls to  kubectl explain  use the new OpenAPIv3 data source available  OpenAPIV3 is enabled by default since Kubernetes 1 24    td    tr    tr   td colspan  2  KUBECTL ENABLE CMD SHADOW  td    tr   tr   td   td  td style  line height  130   word wrap  break word   When set to true  external plugins can be used as subcommands for builtin commands if subcommand does not exist  In alpha stage  this feature can only be used for create command e g  kubectl create networkpolicy      td    tr    tr   td colspan  2  KUBECTL PORT FORWARD WEBSOCKETS  td    tr   tr   td   td  td style  line height  130   word wrap  break word   When set to true  the kubectl port forward command will attempt to stream using the websockets protocol  If the upgrade to websockets fails  the commands will fallback to use the current SPDY protocol    td    tr    tr   td colspan  2  KUBECTL REMOTE COMMAND WEBSOCKETS  td    tr   tr   td   td  td style  line height  130   word wrap  break word   When set to true  the kubectl exec  cp  and attach commands will attempt to stream using the websockets protocol  If the upgrade to websockets fails  the commands will fallback to use the current SPDY protocol    td    tr     tbody    table           kubectl annotate   docs reference kubectl generated kubectl annotate     Update the annotations on a resource    kubectl api resources   docs reference kubectl generated kubectl api resources     Print the supported API resources on the server    kubectl api versions   docs reference kubectl generated kubectl api versions     Print the supported API versions on the server    in the form of  group version     kubectl apply   docs reference kubectl generated kubectl apply     Apply a configuration to a resource by filename or stdin    kubectl attach   docs reference kubectl generated kubectl attach     Attach to a running container    kubectl auth   docs reference kubectl generated kubectl auth     Inspect authorization    kubectl autoscale   docs reference kubectl generated kubectl autoscale     Auto scale a Deployment  ReplicaSet  or ReplicationController    kubectl certificate   docs reference kubectl generated kubectl certificate     Modify certificate resources     kubectl cluster info   docs reference kubectl generated kubectl cluster info     Display cluster info    kubectl completion   docs reference kubectl generated kubectl completion     Output shell completion code for the specified shell  bash or zsh     kubectl config   docs reference kubectl generated kubectl config     Modify kubeconfig files    kubectl cordon   docs reference kubectl generated kubectl cordon     Mark node as unschedulable    kubectl cp   docs reference kubectl generated kubectl cp     Copy files and directories to and from containers     kubectl create   docs reference kubectl generated kubectl create     Create a resource from a file or from stdin     kubectl debug   docs reference kubectl generated kubectl debug     Create debugging sessions for troubleshooting workloads and nodes    kubectl delete   docs reference kubectl generated kubectl delete     Delete resources by filenames    stdin  resources and names  or by resources and label selector    kubectl describe   docs reference kubectl generated kubectl describe     Show details of a specific resource or group of resources    kubectl diff   docs reference kubectl generated kubectl diff     Diff live version against would be applied version    kubectl drain   docs reference kubectl generated kubectl drain     Drain node in preparation for maintenance    kubectl edit   docs reference kubectl generated kubectl edit     Edit a resource on the server    kubectl events   docs reference kubectl generated kubectl events      List events    kubectl exec   docs reference kubectl generated kubectl exec     Execute a command in a container    kubectl explain   docs reference kubectl generated kubectl explain     Documentation of resources    kubectl expose   docs reference kubectl generated kubectl expose     Take a replication controller    service  deployment or pod and expose it as a new Kubernetes Service    kubectl get   docs reference kubectl generated kubectl get     Display one or many resources    kubectl kustomize   docs reference kubectl generated kubectl kustomize     Build a kustomization   target from a directory or a remote url     kubectl label   docs reference kubectl generated kubectl label     Update the labels on a resource    kubectl logs   docs reference kubectl generated kubectl logs     Print the logs for a container in a pod    kubectl options   docs reference kubectl generated kubectl options     Print the list of flags inherited by all commands    kubectl patch   docs reference kubectl generated kubectl patch     Update field s  of a resource    kubectl plugin   docs reference kubectl generated kubectl plugin     Provides utilities for interacting with plugins     kubectl port forward   docs reference kubectl generated kubectl port forward     Forward one or more local ports to a pod    kubectl proxy   docs reference kubectl generated kubectl proxy     Run a proxy to the Kubernetes API server    kubectl replace   docs reference kubectl generated kubectl replace     Replace a resource by filename or stdin    kubectl rollout   docs reference kubectl generated kubectl rollout     Manage the rollout of a resource    kubectl run   docs reference kubectl generated kubectl run     Run a particular image on the cluster    kubectl scale   docs reference kubectl generated kubectl scale     Set a new size for a Deployment  ReplicaSet or Replication Controller    kubectl set   docs reference kubectl generated kubectl set     Set specific features on objects    kubectl taint   docs reference kubectl generated kubectl taint     Update the taints on one or more nodes    kubectl top   docs reference kubectl generated kubectl top     Display Resource  CPU Memory Storage  usage     kubectl uncordon   docs reference kubectl generated kubectl uncordon     Mark node as schedulable    kubectl version   docs reference kubectl generated kubectl version     Print the client and server version information    kubectl wait   docs reference kubectl generated kubectl wait     Experimental  Wait for a specific condition on one or many resources


kubernetes reference brendandburns contenttype concept reviewers title kubectl for Docker Users thockin overview weight 50

Answer:
---
title: kubectl for Docker Users
content_type: concept
reviewers:
- brendandburns
- thockin
weight: 50
---

<!-- overview -->
You can use the Kubernetes command line tool `kubectl` to interact with the API Server. Using kubectl is straightforward if you are familiar with the Docker command line tool. However, there are a few differences between the Docker commands and the kubectl commands. The following sections show a Docker sub-command and describe the equivalent `kubectl` command.

<!-- body -->
## docker run

To run an nginx Deployment and expose the Deployment, see [kubectl create deployment](/docs/reference/generated/kubectl/kubectl-commands#-em-deployment-em-).

docker:

```shell
docker run -d --restart=always -e DOMAIN=cluster --name nginx-app -p 80:80 nginx
```
```
55c103fa129692154a7652490236fee9be47d70a8dd562281ae7d2f9a339a6db
```

```shell
docker ps
```
```
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
55c103fa1296        nginx               "nginx -g 'daemon of…"   9 seconds ago       Up 9 seconds        0.0.0.0:80->80/tcp   nginx-app
```

kubectl:

```shell
# start the pod running nginx
kubectl create deployment --image=nginx nginx-app
```
```
deployment.apps/nginx-app created
```

```shell
# add env to nginx-app
kubectl set env deployment/nginx-app  DOMAIN=cluster
```
```
deployment.apps/nginx-app env updated
```

`kubectl` commands print the type and name of the resource created or mutated, which can then be used in subsequent commands. You can expose a new Service after a Deployment is created.

```shell
# expose a port through with a service
kubectl expose deployment nginx-app --port=80 --name=nginx-http
```
```
service "nginx-http" exposed
```

By using kubectl, you can create a [Deployment](/docs/concepts/workloads/controllers/deployment/) to ensure that N pods are running nginx, where N is the number of replicas stated in the spec and defaults to 1. You can also create a [service](/docs/concepts/services-networking/service/) with a selector that matches the pod labels. For more information, see [Use a Service to Access an Application in a Cluster](/docs/tasks/access-application-cluster/service-access-application-cluster).

By default images run in the background, similar to `docker run -d ...`. To run things in the foreground, use [`kubectl run`](/docs/reference/generated/kubectl/kubectl-commands/#run) to create pod:
```shell
kubectl run [-i] [--tty] --attach <name> --image=<image>
```

Unlike `docker run ...`, if you specify `--attach`, then you attach `stdin`, `stdout` and `stderr`. You cannot control which streams are attached (`docker -a ...`).
To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.

## docker ps

To list what is currently running, see [kubectl get](/docs/reference/generated/kubectl/kubectl-commands/#get).

docker:

```shell
docker ps -a
```
```
CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                     PORTS                NAMES
14636241935f        ubuntu:16.04        "echo test"              5 seconds ago        Exited (0) 5 seconds ago                        cocky_fermi
55c103fa1296        nginx               "nginx -g 'daemon of…"   About a minute ago   Up About a minute          0.0.0.0:80->80/tcp   nginx-app
```

kubectl:

```shell
kubectl get po
```
```
NAME                        READY     STATUS      RESTARTS   AGE
nginx-app-8df569cb7-4gd89   1/1       Running     0          3m
ubuntu                      0/1       Completed   0          20s
```

## docker attach

To attach a process that is already running in a container, see [kubectl attach](/docs/reference/generated/kubectl/kubectl-commands/#attach).

docker:

```shell
docker ps
```
```
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
55c103fa1296        nginx               "nginx -g 'daemon of…"   5 minutes ago       Up 5 minutes        0.0.0.0:80->80/tcp   nginx-app
```

```shell
docker attach 55c103fa1296
...
```

kubectl:

```shell
kubectl get pods
```
```
NAME              READY     STATUS    RESTARTS   AGE
nginx-app-5jyvm   1/1       Running   0          10m
```

```shell
kubectl attach -it nginx-app-5jyvm
...
```

To detach from the container, you can type the escape sequence Ctrl+P followed by Ctrl+Q.

## docker exec

To execute a command in a container, see [kubectl exec](/docs/reference/generated/kubectl/kubectl-commands/#exec).

docker:

```shell
docker ps
```
```
CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES
55c103fa1296        nginx               "nginx -g 'daemon of…"   6 minutes ago       Up 6 minutes        0.0.0.0:80->80/tcp   nginx-app
```
```shell
docker exec 55c103fa1296 cat /etc/hostname
```
```
55c103fa1296
```

kubectl:

```shell
kubectl get po
```
```
NAME              READY     STATUS    RESTARTS   AGE
nginx-app-5jyvm   1/1       Running   0          10m
```

```shell
kubectl exec nginx-app-5jyvm -- cat /etc/hostname
```
```
nginx-app-5jyvm
```

To use interactive commands.

docker:

```shell
docker exec -ti 55c103fa1296 /bin/sh
# exit
```

kubectl:

```shell
kubectl exec -ti nginx-app-5jyvm -- /bin/sh
# exit
```

For more information, see [Get a Shell to a Running Container](/docs/tasks/debug/debug-application/get-shell-running-container/).

## docker logs

To follow stdout/stderr of a process that is running, see [kubectl logs](/docs/reference/generated/kubectl/kubectl-commands/#logs).

docker:

```shell
docker logs -f a9e
```
```
192.168.9.1 - - [14/Jul/2015:01:04:02 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.35.0" "-"
192.168.9.1 - - [14/Jul/2015:01:04:03 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.35.0" "-"
```

kubectl:

```shell
kubectl logs -f nginx-app-zibvs
```
```
10.240.63.110 - - [14/Jul/2015:01:09:01 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.26.0" "-"
10.240.63.110 - - [14/Jul/2015:01:09:02 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.26.0" "-"
```

There is a slight difference between pods and containers; by default pods do not terminate if their processes exit. Instead the pods restart the process. This is similar to the docker run option `--restart=always` with one major difference. In docker, the output for each invocation of the process is concatenated, but for Kubernetes, each invocation is separate. To see the output from a previous run in Kubernetes, do this:

```shell
kubectl logs --previous nginx-app-zibvs
```
```
10.240.63.110 - - [14/Jul/2015:01:09:01 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.26.0" "-"
10.240.63.110 - - [14/Jul/2015:01:09:02 +0000] "GET / HTTP/1.1" 200 612 "-" "curl/7.26.0" "-"
```

For more information, see [Logging Architecture](/docs/concepts/cluster-administration/logging/).

## docker stop and docker rm

To stop and delete a running process, see [kubectl delete](/docs/reference/generated/kubectl/kubectl-commands/#delete).

docker:

```shell
docker ps
```
```
CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                         NAMES
a9ec34d98787        nginx               "nginx -g 'daemon of"  22 hours ago        Up 22 hours         0.0.0.0:80->80/tcp, 443/tcp   nginx-app
```

```shell
docker stop a9ec34d98787
```
```
a9ec34d98787
```

```shell
docker rm a9ec34d98787
```
```
a9ec34d98787
```

kubectl:

```shell
kubectl get deployment nginx-app
```
```
NAME         READY   UP-TO-DATE   AVAILABLE   AGE
nginx-app    1/1     1            1           2m
```

```shell
kubectl get po -l app=nginx-app
```
```
NAME                         READY     STATUS    RESTARTS   AGE
nginx-app-2883164633-aklf7   1/1       Running   0          2m
```
```shell
kubectl delete deployment nginx-app
```
```
deployment "nginx-app" deleted
```

```shell
kubectl get po -l app=nginx-app
# Return nothing
```

When you use kubectl, you don't delete the pod directly. You have to first delete the Deployment that owns the pod. If you delete the pod directly, the Deployment recreates the pod.

## docker login

There is no direct analog of `docker login` in kubectl. If you are interested in using Kubernetes with a private registry, see [Using a Private Registry](/docs/concepts/containers/images/#using-a-private-registry).

## docker version

To get the version of client and server, see [kubectl version](/docs/reference/generated/kubectl/kubectl-commands/#version).

docker:

```shell
docker version
```
```
Client version: 1.7.0
Client API version: 1.19
Go version (client): go1.4.2
Git commit (client): 0baf609
OS/Arch (client): linux/amd64
Server version: 1.7.0
Server API version: 1.19
Go version (server): go1.4.2
Git commit (server): 0baf609
OS/Arch (server): linux/amd64
```

kubectl:

```shell
kubectl version
```
```
Client Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.9+a3d1dfa6f4335", GitCommit:"9b77fed11a9843ce3780f70dd251e92901c43072", GitTreeState:"dirty", BuildDate:"2017-08-29T20:32:58Z", OpenPaasKubernetesVersion:"v1.03.02", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"6", GitVersion:"v1.6.9+a3d1dfa6f4335", GitCommit:"9b77fed11a9843ce3780f70dd251e92901c43072", GitTreeState:"dirty", BuildDate:"2017-08-29T20:32:58Z", OpenPaasKubernetesVersion:"v1.03.02", GoVersion:"go1.7.5", Compiler:"gc", Platform:"linux/amd64"}
```

## docker info

To get miscellaneous information about the environment and configuration, see [kubectl cluster-info](/docs/reference/generated/kubectl/kubectl-commands/#cluster-info).

docker:

```shell
docker info
```
```
Containers: 40
Images: 168
Storage Driver: aufs
 Root Dir: /usr/local/google/docker/aufs
 Backing Filesystem: extfs
 Dirs: 248
 Dirperm1 Supported: false
Execution Driver: native-0.2
Logging Driver: json-file
Kernel Version: 3.13.0-53-generic
Operating System: Ubuntu 14.04.2 LTS
CPUs: 12
Total Memory: 31.32 GiB
Name: k8s-is-fun.mtv.corp.google.com
ID: ADUV:GCYR:B3VJ:HMPO:LNPQ:KD5S:YKFQ:76VN:IANZ:7TFV:ZBF4:BYJO
WARNING: No swap limit support
```

kubectl:

```shell
kubectl cluster-info
```
```
Kubernetes master is running at https://203.0.113.141
KubeDNS is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/kube-dns/proxy
kubernetes-dashboard is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
Grafana is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-grafana/proxy
Heapster is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-heapster/proxy
InfluxDB is running at https://203.0.113.141/api/v1/namespaces/kube-system/services/monitoring-influxdb/proxy
```

title  kubectl for Docker Users content type  concept reviewers    brendandburns   thockin weight  50           overview     You can use the Kubernetes command line tool  kubectl  to interact with the API Server  Using kubectl is straightforward if you are familiar with the Docker command line tool  However  there are a few differences between the Docker commands and the kubectl commands  The following sections show a Docker sub command and describe the equivalent  kubectl  command         body        docker run  To run an nginx Deployment and expose the Deployment  see  kubectl create deployment   docs reference generated kubectl kubectl commands  em deployment em     docker      shell docker run  d   restart always  e DOMAIN cluster   name nginx app  p 80 80 nginx         55c103fa129692154a7652490236fee9be47d70a8dd562281ae7d2f9a339a6db         shell docker ps         CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES 55c103fa1296        nginx                nginx  g  daemon of     9 seconds ago       Up 9 seconds        0 0 0 0 80  80 tcp   nginx app      kubectl      shell   start the pod running nginx kubectl create deployment   image nginx nginx app         deployment apps nginx app created         shell   add env to nginx app kubectl set env deployment nginx app  DOMAIN cluster         deployment apps nginx app env updated        kubectl  commands print the type and name of the resource created or mutated  which can then be used in subsequent commands  You can expose a new Service after a Deployment is created       shell   expose a port through with a service kubectl expose deployment nginx app   port 80   name nginx http         service  nginx http  exposed      By using kubectl  you can create a  Deployment   docs concepts workloads controllers deployment   to ensure that N pods are running nginx  where N is the number of replicas stated in the spec and defaults to 1  You can also create a  service   docs concepts services networking service   with a selector that matches the pod labels  For more information  see  Use a Service to Access an Application in a Cluster   docs tasks access application cluster service access application cluster    By default images run in the background  similar to  docker run  d       To run things in the foreground  use   kubectl run    docs reference generated kubectl kubectl commands  run  to create pod     shell kubectl run   i     tty    attach  name    image  image       Unlike  docker run       if you specify    attach   then you attach  stdin    stdout  and  stderr   You cannot control which streams are attached   docker  a        To detach from the container  you can type the escape sequence Ctrl P followed by Ctrl Q      docker ps  To list what is currently running  see  kubectl get   docs reference generated kubectl kubectl commands  get    docker      shell docker ps  a         CONTAINER ID        IMAGE               COMMAND                  CREATED              STATUS                     PORTS                NAMES 14636241935f        ubuntu 16 04         echo test               5 seconds ago        Exited  0  5 seconds ago                        cocky fermi 55c103fa1296        nginx                nginx  g  daemon of     About a minute ago   Up About a minute          0 0 0 0 80  80 tcp   nginx app      kubectl      shell kubectl get po         NAME                        READY     STATUS      RESTARTS   AGE nginx app 8df569cb7 4gd89   1 1       Running     0          3m ubuntu                      0 1       Completed   0          20s         docker attach  To attach a process that is already running in a container  see  kubectl attach   docs reference generated kubectl kubectl commands  attach    docker      shell docker ps         CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES 55c103fa1296        nginx                nginx  g  daemon of     5 minutes ago       Up 5 minutes        0 0 0 0 80  80 tcp   nginx app         shell docker attach 55c103fa1296          kubectl      shell kubectl get pods         NAME              READY     STATUS    RESTARTS   AGE nginx app 5jyvm   1 1       Running   0          10m         shell kubectl attach  it nginx app 5jyvm          To detach from the container  you can type the escape sequence Ctrl P followed by Ctrl Q      docker exec  To execute a command in a container  see  kubectl exec   docs reference generated kubectl kubectl commands  exec    docker      shell docker ps         CONTAINER ID        IMAGE               COMMAND                  CREATED             STATUS              PORTS                NAMES 55c103fa1296        nginx                nginx  g  daemon of     6 minutes ago       Up 6 minutes        0 0 0 0 80  80 tcp   nginx app        shell docker exec 55c103fa1296 cat  etc hostname         55c103fa1296      kubectl      shell kubectl get po         NAME              READY     STATUS    RESTARTS   AGE nginx app 5jyvm   1 1       Running   0          10m         shell kubectl exec nginx app 5jyvm    cat  etc hostname         nginx app 5jyvm      To use interactive commands    docker      shell docker exec  ti 55c103fa1296  bin sh   exit      kubectl      shell kubectl exec  ti nginx app 5jyvm     bin sh   exit      For more information  see  Get a Shell to a Running Container   docs tasks debug debug application get shell running container        docker logs  To follow stdout stderr of a process that is running  see  kubectl logs   docs reference generated kubectl kubectl commands  logs     docker      shell docker logs  f a9e         192 168 9 1      14 Jul 2015 01 04 02  0000   GET   HTTP 1 1  200 612      curl 7 35 0      192 168 9 1      14 Jul 2015 01 04 03  0000   GET   HTTP 1 1  200 612      curl 7 35 0           kubectl      shell kubectl logs  f nginx app zibvs         10 240 63 110      14 Jul 2015 01 09 01  0000   GET   HTTP 1 1  200 612      curl 7 26 0      10 240 63 110      14 Jul 2015 01 09 02  0000   GET   HTTP 1 1  200 612      curl 7 26 0           There is a slight difference between pods and containers  by default pods do not terminate if their processes exit  Instead the pods restart the process  This is similar to the docker run option    restart always  with one major difference  In docker  the output for each invocation of the process is concatenated  but for Kubernetes  each invocation is separate  To see the output from a previous run in Kubernetes  do this      shell kubectl logs   previous nginx app zibvs         10 240 63 110      14 Jul 2015 01 09 01  0000   GET   HTTP 1 1  200 612      curl 7 26 0      10 240 63 110      14 Jul 2015 01 09 02  0000   GET   HTTP 1 1  200 612      curl 7 26 0           For more information  see  Logging Architecture   docs concepts cluster administration logging        docker stop and docker rm  To stop and delete a running process  see  kubectl delete   docs reference generated kubectl kubectl commands  delete    docker      shell docker ps         CONTAINER ID        IMAGE               COMMAND                CREATED             STATUS              PORTS                         NAMES a9ec34d98787        nginx                nginx  g  daemon of   22 hours ago        Up 22 hours         0 0 0 0 80  80 tcp  443 tcp   nginx app         shell docker stop a9ec34d98787         a9ec34d98787         shell docker rm a9ec34d98787         a9ec34d98787      kubectl      shell kubectl get deployment nginx app         NAME         READY   UP TO DATE   AVAILABLE   AGE nginx app    1 1     1            1           2m         shell kubectl get po  l app nginx app         NAME                         READY     STATUS    RESTARTS   AGE nginx app 2883164633 aklf7   1 1       Running   0          2m        shell kubectl delete deployment nginx app         deployment  nginx app  deleted         shell kubectl get po  l app nginx app   Return nothing       When you use kubectl  you don t delete the pod directly  You have to first delete the Deployment that owns the pod  If you delete the pod directly  the Deployment recreates the pod       docker login  There is no direct analog of  docker login  in kubectl  If you are interested in using Kubernetes with a private registry  see  Using a Private Registry   docs concepts containers images  using a private registry       docker version  To get the version of client and server  see  kubectl version   docs reference generated kubectl kubectl commands  version    docker      shell docker version         Client version  1 7 0 Client API version  1 19 Go version  client   go1 4 2 Git commit  client   0baf609 OS Arch  client   linux amd64 Server version  1 7 0 Server API version  1 19 Go version  server   go1 4 2 Git commit  server   0baf609 OS Arch  server   linux amd64      kubectl      shell kubectl version         Client Version  version Info Major  1   Minor  6   GitVersion  v1 6 9 a3d1dfa6f4335   GitCommit  9b77fed11a9843ce3780f70dd251e92901c43072   GitTreeState  dirty   BuildDate  2017 08 29T20 32 58Z   OpenPaasKubernetesVersion  v1 03 02   GoVersion  go1 7 5   Compiler  gc   Platform  linux amd64   Server Version  version Info Major  1   Minor  6   GitVersion  v1 6 9 a3d1dfa6f4335   GitCommit  9b77fed11a9843ce3780f70dd251e92901c43072   GitTreeState  dirty   BuildDate  2017 08 29T20 32 58Z   OpenPaasKubernetesVersion  v1 03 02   GoVersion  go1 7 5   Compiler  gc   Platform  linux amd64           docker info  To get miscellaneous information about the environment and configuration  see  kubectl cluster info   docs reference generated kubectl kubectl commands  cluster info    docker      shell docker info         Containers  40 Images  168 Storage Driver  aufs  Root Dir   usr local google docker aufs  Backing Filesystem  extfs  Dirs  248  Dirperm1 Supported  false Execution Driver  native 0 2 Logging Driver  json file Kernel Version  3 13 0 53 generic Operating System  Ubuntu 14 04 2 LTS CPUs  12 Total Memory  31 32 GiB Name  k8s is fun mtv corp google com ID  ADUV GCYR B3VJ HMPO LNPQ KD5S YKFQ 76VN IANZ 7TFV ZBF4 BYJO WARNING  No swap limit support      kubectl      shell kubectl cluster info         Kubernetes master is running at https   203 0 113 141 KubeDNS is running at https   203 0 113 141 api v1 namespaces kube system services kube dns proxy kubernetes dashboard is running at https   203 0 113 141 api v1 namespaces kube system services kubernetes dashboard proxy Grafana is running at https   203 0 113 141 api v1 namespaces kube system services monitoring grafana proxy Heapster is running at https   203 0 113 141 api v1 namespaces kube system services monitoring heapster proxy InfluxDB is running at https   203 0 113 141 api v1 namespaces kube system services monitoring influxdb proxy