Managing K8s cluster on Windows using PowerShell
Although Linux/MAC is mostly preferred to manage your Kubernetes clusters, you could also manage them on Windows as well using PowerShell.
Install kubectl
The first thing we need to do is install kubectl.
The K8s command-line tool, kubectl, allows you to run commands against K8s clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs.
Once kubectl is installed, ensure it is added to Windows PATH.
Setting context, users and clusters
Once we have setup kubectl, we can manage multiple clusters.
To configure your context, users and clusters, refer the K8s docs.
Setting up PowerShell Profiles
First open PowerShell and get the path of your PowerShell Profile by typing
echo $PROFILE
By default, the profile file does not exist, even though PowerShell displays the filename on the console. It can be created using New-Item or any text editor.
For more on PowerShell profiles, refer Understanding the Six PowerShell Profiles.
Adding kubectl aliases
Copy the contents of kubectl_aliases.ps1 and add it to the PowerShell Profile from above step.
Switching contexts faster
We can switch contexts faster using the Windows version of kubectx, kubectxwin.
Download the binary kubectxwin.exe and add it to Windows PATH.
Additionally, we can also add an alias to the PowerShell Profile
Set-Alias -Name kx -Value kubectxwin
Switching namespaces faster
We can switch contexts faster using the Windows version of kubens, kubenswin.
Download the binary kubenswin.exe and add it to Windows PATH.
Additionally, we can also add an alias to PowerShell Profile
Set-Alias -Name kns -Value kubenswin
Testing it all together
Download and install Minikube
choco install minikube
Ensure Docker Desktop is running and configured with the WSL2 backend.
Start minikube
minikube start
Once it starts, we can issue the various command aliases we configured above













