How to install Kubernetes client on Windows, Mac, and Linux?

First published: Monday, February 5, 2024 | Last updated: Monday, February 5, 2024

Use these simple steps to install the Kubernetes client on your Windows, Mac, and Linux operating systems to operate and manage the Kubernetes control plane.


What is Kubernetes client?

The Kubernetes platform offers a dedicated command line tool (kubectl) that facilitates communication with a Kubernetes cluster’s control plane by interacting with the Kubernetes API server. This utility is known as the Kubernetes client.

Install Kubernetes client

This knowledge base article provides detailed instructions for installing the Kubernetes client, which is the command line tool used to connect to and manage the Kubernetes cluster’s control plane. It is recommended to install Kubernetes client using a package manager on Mac or Linux-based operating systems for ease and consistency. On the Windows operating system, we can directly download and install the Kubernetes client executable program. Once the installation is complete, it is crucial to verify the Kubernetes client version to ensure that the installation was successful. For more in-depth guidance, you can refer to the Kubernetes client documentation.

Windows

You can use the following commands to install Kubernetes client in the Windows operating system.

# Download and install Kubernetes client.
$ mkdir ~/kubernetes
$ cd ~/kubernetes
$ curl -LO https://dl.k8s.io/release/v1.28.2/bin/windows/amd64/kubectl.exe

After downloading and installing the Kubernetes client on your Windows operating system, you’ll want to add the Kubernetes client executable program path to the environment variables.

# Copy Kubernetes client path.
$ cmd
# Add Kubernetes client path to environment variables.
View advanced system settings
	Environment Variables
		User Variables
			Path: <KUBERNETES_CLIENT_PATH>
# Check Kubernetes client version.
$ kubectl version --client

Mac (MacPorts)

You can use the following commands to install Kubernetes client in the MacPorts-based Mac operating system.

# Install Kubernetes client.
$ sudo port install kubectl-1.28

# Check Kubernetes client version.
$ kubectl version --client

Mac (Homebrew)

You can use the following commands to install Kubernetes client in the Homebrew-based Mac operating system.

# Install Kubernetes client.
$ brew install kubernetes-cli@1.28

# Check Kubernetes client version.
$ kubectl version --client

Linux (RPM)

You can use the following commands to install Kubernetes client in RPM-based Linux operating systems such as CentOS LinuxRed Hat LinuxFedora LinuxAmazon LinuxAlma LinuxRocky Linux, etc., or any other similar equivalents.

# Add Kubernetes repository to package manager source list.
$ cat <<EOF | sudo tee /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/
enabled=1
gpgcheck=1
gpgkey=https://pkgs.k8s.io/core:/stable:/v1.28/rpm/repodata/repomd.xml.key
EOF
# Install Kubernetes client.
$ sudo yum install kubectl

# Check Kubernetes client version.
$ kubectl version --client

Linux (Debian)

You can use the following commands to install Kubernetes client in Debian-based Linux operating systems such as Ubuntu LinuxMint LinuxKali LinuxKubuntu Linux, etc., or any other similar equivalents.

# Add Kubernetes official GPG key to package manager.
$ sudo mkdir /etc/apt/keyrings
$ curl -fsSL https://pkgs.k8s.io/core:/stable:/v1.28/deb/Release.key | sudo gpg --dearmor -o /etc/apt/keyrings/kubernetes-apt-keyring.gpg

# Add Kubernetes repository to package manager source list.
$ echo 'deb [signed-by=/etc/apt/keyrings/kubernetes-apt-keyring.gpg] https://pkgs.k8s.io/core:/stable:/v1.28/deb/ /' | sudo tee /etc/apt/sources.list.d/kubernetes.list

# Check for package updates.
$ sudo apt update

# Install Kubernetes client.
$ sudo apt install kubectl

# Check Kubernetes client version.
$ kubectl version --client