I was getting a bit tired of typing the kubectl command everytime. To solve this and only type k instead of kubectl, it’s possible to add an alias to Windows.
1. Create a directory in c:\program files\ called k8s
2. Create a cmd file and save it as alias.cmd in c:\program files\k8s\:
@echo off doskey k=kubectl $*
3. Add an entry to the registry which calls this alias.cmd file everytime when a command window is opened. This can be done with the following file. Save it as addtoregistry.reg:
Windows Registry Editor Version 5.00 [HKEY_CURRENT_USER\Software\Microsoft\Command Processor] "AutoRun"="c:\\\"Program Files\"\\k8s\\alias.cmd"
Download both files here
— update
Ahmet Alp Balkan has created more than 800 aliases for kubectl which works on Linux.
I converted the aliases Ahmet created, so they work on Windows. Read his blog to read the syntax and see the original aliases on his GitHub account:
https://ahmet.im/blog/kubectl-aliases/
https://github.com/ahmetb/kubectl-aliases
If you don’t mind to wait for the loading of all the aliases when opening a command prompt, you can find the Windows aliases here
doskey k = kubectl $ * needs to be doskey k = kubectl $* (removed space between dollar and star)
LikeLike
you can do it easier.
go to your kubectl location an make copy of kubectl.exe as k.exe.
Done -)
LikeLike