Skip to main content

Anatomy of a `kubectl` Command

kubectl is the command-line interface for Kubernetes. It allows us to run commands against Kubernetes clusters. It is the most important command in Kubernetes, and we'll use it a lot.

I can't emphasize enough how important it is to write these commands manually until we internalize them. And, very importantly, make sure to set up kubectl completion, it will speed things up a lot.

$kubectlgetpodmy-pod-n my-namespace

Command

Specifies the operation that you want to perform on one or more resources, for example create, get, describe, delete.

Resource Type

Specifies the resource type. Resource types are case-insensitive and you can specify the singular, plural, or abbreviated forms.

Resource Name

Specifies the name of the resource. Names are case-sensitive. If the name is omitted, details for all resources are displayed, for example kubectl get pods.

Flags

Specifies optional flags. For example, you can use the -s or --server flags to specify the address and port of the Kubernetes API server.