Windows Version of the powerful tool kubectx
Usage
kubectxwin : current context
kubectxwin ls : list the contexts
kubectxwin set <name> : switch to context <name>
kubectxwin rn <oldname> <newname> : rename context <oldname> <newname>
kubectxwin rm <name> : delete context <name>
kubectxwin help : display usage
OS | Success |
---|---|
Windows 10 | Yes |
Windows 2012 R2 | Yes |
Windows 2016 | N/A |
Windows 7 | N/A |
Windows 2008 R2 | N/A |
Note
N/A
= Haven't tested yet
You can install the kubectl client via Chocolatey. This is the recommended way based on the kubernetes.io docs.
choco install kubernetes-cli
$ kubectxwin ls
* minikube
mydevcluster
sandbox
$ kubectxwin set sandbox
Switched to context "sandbox".
$ kubectxwin set 'n/a'
Context "no-context" modified.
Switched to context "no-context".
$ kubectxwin rn sandbox sandbox-old
Context "sandbox" renamed to "sandbox-old".
$ kubectxwin ls
minikube
mydevcluster
* sandbox
$ kubectxwin
sandbox
You will need to ensure you put kubectxwin.exe
in a directory in your $PATH. To see what directories you can put it in use the following command.
In a Windows Command Prompt
echo %PATH%
In a Powershell Command Prompt
PS> Get-ChildItem Env:
kubectxwin for Windows is actually a powershell script that was converted using PS2EXE-GUI
. I have saved the copy of PS2EXE-GUI that I used in this repo.
This allows users and developers to use different methods of kubectxwin for Windows. For example, if you want just to use the Powershell script or convert it to a PowerShell module, you can do that. By default, I provide the .exe
because that is useful to me. However, feel free to use it anyway you like and please CONTRIBUTE with new features and funtionaility.
I'd love for anyone to contribute. Please read the CONTRIBUTING.md document for more information.
- Windows 10 or higher
PS2EXE-GUI
- Powershell 4.0 or higher (I used 5.0)
Open a Powershell command with Run as administrator
Set-ExecutionPolicy RemoteSigned
git clone https://github.com/thomasliddledba/kubectxwin.git <working directory>
cd <working directory>/kubectxwin
./PS2EXE-GUI/ps2exe.ps1 -inputfile kubectxwin.ps1 -output bin/kubectxwin.exe
- Markus Scholtes - PS2EXE-GUI
- Ingo Karstein - PS2EXE
- Jon Mosco - Late night discussion about doing this weekend project. Check out kube-ps1 by Jon! Maybe a Windows version????
- Ahmet Alp Balkan - kubectx - Writing the inital code for kubectx and giving me the idea to extend to Windows for us Windows guys based on this Issue #29