kubectl
is the command line interface (CLI) for interacting with a Kubernetes cluster. It allows users to deploy applications, inspect and manage cluster resources, and view logs. kubectl
commands can be used to perform a wide range of operations on a Kubernetes cluster, from basic CRUD (Create, Read, Update, Delete) operations on Kubernetes objects, to inspecting the state of the cluster, to debugging running applications.
Installing kubectl
is a crucial step in managing Kubernetes clusters. Below are the installation steps for Ubuntu (Linux), macOS, and Windows.
Ubuntu (Linux)
-
Download the Latest Version of kubectl:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
-
Make the kubectl Binary Executable:
chmod +x ./kubectl
-
Move the Binary into Your PATH:
sudo mv ./kubectl /usr/local/bin/kubectl
-
Test to Ensure the Version You Installed is Up-to-Date:
kubectl version --client
macOS
-
Download the Latest Version of kubectl with Curl:
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/darwin/amd64/kubectl"
-
Make the kubectl Binary Executable:
chmod +x ./kubectl
-
Move the Binary in to Your PATH:
sudo mv ./kubectl /usr/local/bin/kubectl
-
Test to Ensure the Version You Installed is Up-to-Date:
kubectl version --client
Alternatively, macOS users can also use Homebrew to install kubectl
:
brew install kubectl
Windows
-
Download the Latest Version of kubectl with Curl (You can use PowerShell for this step):
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/windows/amd64/kubectl.exe"
-
Add the Binary in to Your PATH:
- Move the downloaded
kubectl.exe
to a directory included in your system's PATH.
- Move the downloaded
-
Test to Ensure the Version You Installed is Up-to-Date (from Command Line or PowerShell):
kubectl version --client
Alternatively, Windows users can also use Chocolatey, a package manager for Windows, to install kubectl
:
choco install kubernetes-cli
Verifying Installation
Regardless of your operating system, you can verify that kubectl
is installed correctly by running:
kubectl version --client
This command should print the client version. If you get an error or do not have a connection to a Kubernetes cluster yet, it may show an error for the server version, which is expected.
Enabling Shell Autocompletion
Shell autocompletion can greatly enhance your productivity with kubectl
. To enable it, follow the instructions for your shell and operating system in the Kubernetes documentation.
These steps should help you get kubectl
installed and running on your system, allowing you to interact with your Kubernetes clusters efficiently.
To know more about kubectl check here