How to Install and Use kubectl on Windows

Introduction

kubectl is the command-line tool used to manage Kubernetes clusters. If you’re running Windows and need to interact with your Kubernetes cluster, follow this simple guide to install and configure kubectl without using PowerShell.

Step 1: Download kubectl

To get started, download the latest version of kubectl from the official Kubernetes site.

  1. Open your browser and go to: https://cdn.dl.k8s.io/release/v1.32.3/bin/windows/amd64/kubectl.exe
  2. Save the file to your computer.

Step 2: Move kubectl to System32

To make kubectl accessible from any command prompt, move it to the System32 directory:

  1. Copy the downloaded kubectl.exe file.
  2. Navigate to C:\Windows\System32\.
  3. Paste kubectl.exe into this directory.

Step 3: Verify Installation

Once copied, check if kubectl is installed by running the following command in Command Prompt (cmd):

kubectl version --client

You should see output confirming that kubectl is installed.

Step 4: Configure kubectl

To connect to your Kubernetes cluster, you need to set up a configuration file.

  1. Open File Explorer and navigate to your user directory: C:\Users\YourUsername\
  2. Create a new folder named .kube (if it doesn’t exist).
  3. Inside the .kube folder, create a new file named config (without any file extension).
  4. Open the config file in Notepad or any text editor.
  5. Paste your kubeconfig details into the file and save it.

Step 5: Test the Connection

To ensure kubectl is connected to your cluster, run:

kubectl get nodes

If configured correctly, you should see a list of nodes in your cluster.

Conclusion

You’ve successfully installed and configured kubectl on Windows! You can now use it to manage your Kubernetes cluster efficiently. If you run into issues, ensure your config file is correct and properly placed in the .kube directory.

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *