Installing kubectl

Learn how to install the Kubernetes command-line tool: kubectl.

Understanding kubectl#

Kubernetes’ command-line tool, kubectl, is used to manage a cluster and applications running inside it. We’ll use kubectl a lot throughout the course, so we won’t go into details just yet. Instead, we’ll discuss its commands through examples that will follow shortly. For now, think of it as your interlocutor with a Kubernetes cluster.

svg viewer

Installation#

You can install kubectl by using one of the below-listed methods depending on your operating system:

Feel free to skip the installation steps if you already have kubectl. Just make sure that it is version 1.8 or above.

MacOS#

If you are a MacOS user, please execute the commands that follow.

install kubectl on MacOS

If you already have Homebrew package manager installed, you can “brew” it with the command that follows.

Intsall kubectl using Homebrew package manager

Linux#

If, on the other hand, you’re a Linux user, the commands that will install kubectl are as follows.

Install kubectl on Linux

Windows#

Finally, Windows users should download the binary through the command that follows.

Intsall kubsctl on Windows

Feel free to copy the binary to any directory. The important thing is to add it to your PATH.

Verification#

Let’s check kubectl version and, at the same time, validate that it is working correctly. No matter which OS you’re using, the command is as follows.

Verification of version

The output is as follows.

kubectl version

That is a very ugly and unreadable output. Fortunately, kubectl can use a few different formats for its output. For example, we can tell it to output the command in yaml format

kubectl version in YAML format

The output is as follows.

Out of kubectl version in YAML format

That was a much better (more readable) output.

We can see that the client version is 1.14.0. At the bottom is the error message stating that kubectl could not connect to the server. That is expected since we did not yet create a cluster. That’s our next step.

Exploring the Options
Installing Minikube
Mark as Completed
Report an Issue