To manage your Kubernetes cluster, you use a program called 'kubectl'. Simply put, Kubectl is a command-line tool that allows you to execute commands on a Kubernetes cluster.
You install kubectl on your local computer or laptop. In this guide, we show you how to install Kubectl on Windows/Linux/MacOS.
The version of Kubectl can only differ one version from the version of Kubernetes your Kubernetes cluster uses. For example, if your Kubernetes cluster uses version 1.23, Kubectl version can be 1.22, 1.23, or 1.24.
Installing Kubectl on Windows
Step 1
Create a directory in Windows Explorer, for example, the directory C:\kubectl.
Step 2
Use the link below to download Kubectl. Replace the version of Kubectl in the address with your version of Kubernetes. You can check the version in the TransIP control panel.
https://storage.googleapis.com/kubernetes-release/release/v1.24.2/bin/windows/amd64/kubectl.exe
Step 3
Simultaneously press the Windows Start icon + R on your keyboard. The Run screen will appear. Type the command 'sysdm.cpl' and press 'OK' or the enter key.
Click on the 'Advanced' tab > 'Environment Variables'.
You will see a heading 'User variables for ...' and 'System variables'. Scroll down to 'Path' under 'User variables' and click 'Edit'.
Click 'New' and enter the directory you created in step 1 (case sensitive). Finally, click 'OK' three times to close all open windows.
Congratulations! You have successfully installed Kubectl on your computer. You can now use Kubectl by starting the command prompt (CMD) (Windows Start button > cmd) and executing the command 'kubectl', for example, as a test:
kubectl version
The output will look something like this:
username@COMPUTERNAME>kubectl version
Client Version: v1.27.2
Server Version: v1.26.3
Installing Kubectl on Linux
Step 1
Open a terminal and download the latest or a specific version of Kubectl using one of the following commands:
Latest version:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
Specific version:
curl -LO https://dl.k8s.io/release/v1.24.2/bin/linux/amd64/kubectl
Remember to replace 1.24.2 with the version of Kubernetes that your Kubernetes cluster is using (visible in the TransIP control panel).
Step 2
Next, install Kubectl with the command:
sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl
Congratulations! You have successfully installed Kubectl on your computer. You can test Kubectl directly with the command:
kubectl version
The output will look something like this:
username@COMPUTERNAME>kubectl version
Client Version: v1.27.2
Server Version: v1.26.3
Installing Kubectl on MacOS
The installation of Kubectl on MacOS varies slightly depending on whether you are using an Intel processor or an Apple silicon processor.
Step 1
Open a terminal and download the latest or a specific version of Kubectl using the following commands:
Intel processor - Latest Kubectl version:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
Intel processor - Specific Kubectl version:
curl -LO "https://dl.k8s.io/release/v1.24.2/bin/darwin/amd64/kubectl"
Remember to replace 1.24.2 with the version of Kubernetes that your Kubernetes cluster is using (visible in the TransIP control panel).
Apple silicon processor - Latest Kubectl version:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/arm64/kubectl"
Apple silicon processor - Specific Kubectl version:
curl -LO "https://dl.k8s.io/release/v1.27.2/bin/darwin/arm64/kubectl"
Remember to replace 1.27.2 with the version of Kubernetes that your Kubernetes cluster is using (visible in the TransIP control panel).
Step 2
Make the file executable, create the /usr/local/bin directory (it may already exist), move kubectl to a directory included in the $PATH system variable (so that it can be executed from any directory), and make the root user the owner of the file:
chmod +x ./kubectl sudo mkdir /usr/local/bin/ sudo mv ./kubectl /usr/local/bin/kubectl sudo chown root: /usr/local/bin/kubectl
Congratulations! You have successfully installed Kubectl on your computer. You can test Kubectl directly with the command:
kubectl version
The output will look something like this:
username@COMPUTERNAME>kubectl version
Client Version: v1.27.2
Server Version: v1.26.3