kubectl

Learn about the main Kubernetes command-line tool: kubectl.

What is kubectl?

kubectl is the main Kubernetes command-line tool and is what you will use for your day-to-day Kubernetes management activities. It might be useful to think of kubectl as SSH for Kubernetes. It’s available for Linux, Mac, and Windows.

As it’s the main command-line tool, it’s important that you use a version that is no more than one minor version higher or lower than your cluster. For example, if your cluster is running Kubernetes 1.18.x, your kubectl should be between 1.17.x and 1.19.x.

At a high level, kubectl converts user-friendly commands into the JSON payload required by the API server. It uses a configuration file to know which cluster and API server endpoint to POST commands to.

The kubectl configuration file is called config and lives in $HOME/.kube. It contains definitions for:

  • Clusters
  • Users (credentials)
  • Contexts

Get hands-on with 1200+ tech skills courses.