Kubernetes

Install kubectl Using “choco install”

Kubernetes is a free, open-source, and well-known container orchestration system that is utilized for automating deployment, scaling, and management of applications and software. The developer can execute multi-container applications inside the cluster. The Kubernetes cluster is further composed of different components and resources such as kubelet, nodes, pods, control plane, controller, and so on. To manage and operate these components, the kubectl tool is essential.

This blog will illustrate:

What is kubectl?

The “kubectl” is the command line tool of Kubernetes that is utilized to deploy, monitor, and manage the containerized application inside the cluster. It is used to deploy, operate, and inspect the Kubernetes resources by offering a wide variety of kubectl commands. Users can easily communicate with Kubernetes components, give instructions, scale, and monitor applications through the “kubectl” command.

Prerequisite: Install Chocolatey on Windows

Chocolatey is an open-source free Microsoft machine-level package manager. It is used to install and upgrade software, applications, and packages. To install the Chocolatey on Windows, go through the following instructions.

Step 1: Launch PowerShell

First, launch PowerShell with administrator rights:

Step 2: Get Execution Policy

To get the current execution policy of PowerShell, use the below command. By default, its value is “Restricted”:

Get-ExecutionPolicy

If its status is “Restricted” as shown below, then the user needs to change it to the “AllSigned” policy:

Step 3: Set Execution Policy

To change the execution policy, utilize the given command. This step is essential to run the script in Windows PowerShell:

Set-ExecutionPolicy Bypass -Scope Process

Step 4: Install Chocolatey Package Manager

Now, install the Chocolatey by executing the following command in the PowerShell:

Set-ExecutionPolicy Bypass -Scope Process -Force; [System.Net.ServicePointManager]::SecurityProtocol = [System.Net.ServicePointManager]::SecurityProtocol -bor 3072; iex ((New-Object System.Net.WebClient).DownloadString('https://community.chocolatey.org/install.ps1'))

After installation, run the “choco” command to verify that if the package is installed or not:

choco

The output shows that we have effectively installed the Chocolatey “v2.2.2” on Windows:

How to Install kubectl Using “choco install”?

Choco package manager offers numerous packages and is supported by hundreds of companies. It also permits us to play with Kubernetes and its components through the “kubernetes-cli” package. To install the kubectl Kubernetes command line tool, use the below instructions.

Step 1: Install kubectl

To install kubectl using Chocolatey, utilize the below command:

choco install kubernetes-cli

Step 2: Verification

After installing the kubectl CLI, check the kubectl version:

kubectl version --client

The output shows that we have successfully installed the kubectl “v1.29.0” on Windows:

Step 3: Do Additional Configuration

To configure and use the remote Kubernetes cluster, first, navigate to the Windows Home directory which is “C:\Users\<User-name>”:

cd C:\Users\Dell

Create a new directory named “.kube”:

mkdir .kube

Configure a remote Kubernetes cluster by creating a config file. This file can be edited and opened in any text editor:

New-Item config -type file

Step 4: Start Minikube Cluster

To use kubectl to manage and control the Kubernetes cluster, first start the cluster using the minikube tool. To start understanding Kubernetes and to install minikube, follow our linked article. To start the minikube Kubernetes cluster, use the “minikube start” command:

minikube start

Step 5: Use Kubectl Command

After starting the cluster, the user can get the cluster info through the “kubectl cluster-info” command:

kubectl cluster-info

That is all about installing kubectl using the “choco install” command.

Conclusion

To install kubectl using the “choco install” command, first, install the Chocolatey Windows package manager on the system. After that, run the “choco install kubernetes-cli” command to install the kubectl. For verification, start the Kubernetes cluster using the minikube tool and use the “kubectl cluster-info” command. We have covered the installation method of kubectl using Chocolatey.

About the author

Rafia Zafar

I am graduated in computer science. I am a junior technical author here and passionate about Programming and learning new technologies. I have worked in JAVA, HTML 5, CSS3, Bootstrap, and PHP.