kubectl

Subcommands

NameDescription
alphaThese commands correspond to alpha features that are not enabled in Kubernetes clusters by default
annotateUpdate the annotations on one or more resources
api-resourcesPrint the supported API resources on the server
api-versionsPrint the supported API versions on the server, in the form of "group/version"
applyApply 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'
attachAttach to a process that is already running inside an existing container
authInspect authorization
autoscaleCreates an autoscaler that automatically chooses and sets the number of pods that run in a kubernetes cluster
certificateModify certificate resources
cluster-infoDisplay 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'
completionOutput 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
configModify kubeconfig files using subcommands like "kubectl config set current-context my-context"
convertConvert config files between different API versions. Both YAML and JSON formats are accepted
cordonMark node as unschedulable
cpCopy files and directories to and from containers
createCreate a resource from a file or from stdin
deleteDelete resources by filenames, stdin, resources and names, or by resources and label selector
describeShow details of a specific resource or group of resources
diffDiff configurations specified by filename or stdin between the current online configuration, and the configuration as it would be if applied
drainDrain node in preparation for maintenance
editEdit a resource from the default editor
execExecute a command in a container
explainList the fields for supported resources
exposeExpose a resource as a new Kubernetes service
getDisplay one or many resources
kustomizePrint a set of API resources generated from instructions in a kustomization.yaml file
labelUpdate the labels on a resource
logsPrint the logs for a container in a pod or specified resource. If the pod has only one container, the container name is optional
patchUpdate field(s) of a resource using strategic merge patch, a JSON merge patch, or a JSON patch
pluginProvides utilities for interacting with plugins
port-forwardForward one or more local ports to a pod. This command requires the node to have 'socat' installed
proxyCreates 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
replaceReplace a resource by filename or stdin
rolloutManage the rollout of a resource
runCreate and run a particular image in a pod
scaleSet a new size for a Deployment, ReplicaSet, Replication Controller, or StatefulSet
setConfigure application resources
taintUpdate the taints on one or more nodes
topDisplay Resource (CPU/Memory/Storage) usage
uncordonMark node as schedulable
versionPrint the client and server version information for the current context
waitExperimental: Wait for a specific condition on one or many resources

Options

NameDescription
-n, --namespace <namespace>If present, the namespace scope for this CLI request