Installing kubectl
Learn how to install the Kubernetes command-line tool: kubectl.
We'll cover the following
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.
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.
If you already have Homebrew package manager installed, you can “brew” it with the command that follows.
Linux#
If, on the other hand, you’re a Linux user, the commands that will install kubectl
are as follows.
Windows#
Finally, Windows users should download the binary through the command that follows.
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.
The output is as follows.
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
The output is as follows.
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.