Installing kubectl
Let's take a look at how you can install kubectl
on macOS, on Windows, and in CI/CD pipelines.
Installing on macOS
The easiest way to install kubectl
on macOS is using the Homebrew package manager (https://brew.sh/):
- To install, run this:
$ brew install kubectl
- To see the version you have installed, use this:
$ kubectl version –client --short Client Version: v1.18.1
Installing on Windows
To install kubectl
on Windows, you could use the simple command-line installer Scoop (https://scoop.sh/):
- To install, run this:
$ scoop install kubectl
- To see the version you have installed, use this:
$ kubectl version –client --short Client Version: v1.18.1
- Create the
.kube
directory in your home directory:$ mkdir %USERPROFILE%\.kube
- Navigate to the
.kube
directory:$ cd %USERPROFILE%\.kube
- Configure
kubectl
to use a remote Kubernetes cluster:$ New-Item config -type file
Installing on Linux
When you want to use kubectl
on Linux, you have two options:
- Use
curl
:$ curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
- If your Linux system supports Docker images, use https://hub.docker.com/r/bitnami/kubectl/.
Note
Linux is a very common environment for CI/CD pipelines.