With any Linux distribution attached, Windows clients are suddenly becoming workhorses that are OS agnostic.
Linux opens up a whole new set of functions to standard shell/Powershell, and in combination with VSCode, there are (almost) endless possibilities.
From creating a SSL certificate in under a minute, complex git operations to handling Kubernetes clusters with ease, all the bells and whizzes at your fingertips.
MS evolved the very early WSL (=WindowsSubsystemforLinux) to Version WSL 2, which got a lot of security and performance improvements.
Here you will find an installation path from vanilla ubuntu to a customized zsh shell, with tons of options; ready for your preferred functions and style.
Ubuntu Installation
- If ubuntu is installed already, it can be easily reset by uninstalling in Apps & features and installed again
- For anyone who needs to upgrade from WSL1, please use link, or reinstall from scratch from Microsoft Store
- If you never had WSL activated on your laptop, you have to activate your feature first:
A.) Easy Installation type:
- GoTo: Microsoft Store, search for “Ubuntu”, choose the latest “LTS” (LongTermSupport) and install it from there.
- Restart PC
3. Check with Powershell (in your UserProfile):
1. wsl -l -v
B.) Do it the hard way:
- Execute Step1 — Step6 from https://docs.microsoft.com/en-us/windows/wsl/install-manual
- for an elevated shell, ask your IT Administrator for help
- Use an LTS version such as 20.04
- Check with Powershell (in your UserProfile):
wsl -l -v
- If Version is still on WSL Version 1, execute:
wsl --set-version <NAME> 2
example: wsl –set-version Ubuntu-20.04 2
- Processing will need 5–10 minutes, check for the “operation complete” message.
- Restart PC
First Startup of Ubuntu
- After restart, open Application “Ubuntu”
- Once it has finished the initial bootup, enter your preferred username and (sudo) password for the shell when asked in the prompt
ATTENTION: losing the password is a bad idea!
Installation of executables, Zsh and “oh-my-zsh”
execute commands in following order line by line:
sudo apt-get install -y build-essential curl file git jq apt-transport-https ca-certificates ssh-agent
sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg https://packages.cloud.google.com/apt/doc/apt-key.gpg
echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee /etc/apt/sources.list.d/kubernetes.list
sudo apt-get update
sudo apt-get install -y kubectl
sudo apt-get install -y zsh && sh -c "$(curl -fsSL https://raw.githubusercontent.com/robbyrussell/oh-my-zsh/master/tools/install.sh)" -y
git clone https://github.com/romkatv/powerlevel10k.git $ZSH_CUSTOM/themes/powerlevel10k
git clone https://github.com/zsh-users/zsh-autosuggestions.git $ZSH_CUSTOM/plugins/zsh-autosuggestions
git clone https://github.com/zsh-users/zsh-syntax-highlighting.git $ZSH_CUSTOM/plugins/zsh-syntax-highlighting
git clone https://github.com/zsh-users/zsh-history-substring-search.git ${ZSH_CUSTOM:-~/.oh-my-zsh/custom}/plugins/zsh-history-substring-search
sudo apt-get update
sudo apt-get install zsh-syntax-highlighting
mkdir ~/.kube && chmod 0700 ~/.kube
cd .oh-my-zsh/custom/plugins && chmod 0700 zsh-autosuggestions && chmod 0700 zsh-syntax-highlighting && chsh -s $(which zsh)
sudo apt autoremove -y
Fonts, VSCode Installation/Configuration
- Install Fonts (by just downloading and executing links below):
- MesloLGS NF Regular.ttf
- MesloLGS NF Bold.ttf
- MesloLGS NF Italic.ttf
- MesloLGS NF Bold Italic.ttf
- Make sure your WSL distro is running with “WSL Version 2” (see “Ubuntu installation”
- Install Visual Studio Code
- Enter VSCode, install “Remote — WSL” under “Extensions” (CTRL-SHIFT-X)
- Press “CTRL” + “,” to get into VSCODE Settings
- search for “Terminal Font”
- Enter “MesloLGS NF”
ZSH Setup
- Go to Ubuntu shell and execute: “code .zshrc”
- Software Packages will be installed quickly.
- Afterwards, VSCode will pop up with the .zshrc file that needs some adaption
- Edit:
ZSH_THEME=powerlevel10k/powerlevel10k
plugins=(ssh-agent docker docker-compose git git-flow kubectl zsh-autosuggestions zsh-syntax-highlighting history-substring-search z)
Plugins in oh-my-zsh are a very powerful thing. Find some reference for used plugins at the end of the article.
If you want to to explore yourself, here is one of the many plugin resources you can work with: Plugin Collection
3.Add at the bottom:
#kubectl autocompletion
source <(kubectl completion zsh)
#bash history completion
bindkey '\e[A' history-search-backward
bindkey '\e[B' history-search-forward
bindkey "^[[H" beginning-of-line
bindkey "^[[F" end-of-line
#use VSCode as editor in "kubectl edit"
export KUBE_EDITOR="code - wait"
#automated file detection for any new cluster-config, after adding any ".yaml" file into ~/.kube/ folder, reload with #zsh
export DIR=/$HOME/.kube/
if ls ${DIR}/*.yaml &>/dev/null
then
mergedKubeConfigs=$HOME/.kube/config
for i in $HOME/.kube/*.yaml; do mergedKubeConfigs=$mergedKubeConfigs:$i; done
export KUBECONFIG=$mergedKubeConfigs
fi
Powerlevel10k Configuration
Powerlevel10k is a brilliant tool to enrich your shell prompt with data on top, like:
- In VSCode, go to “Terminal/New Terminal”
- Follow along the dialog
- if this dialog does not show up, you can execute “p10k configure” to start OR re-execute if its not to your liking
- make sure the symbols appear properly on screen, if they don’t; make sure you have executed this steps correctly
Wrong Font in use:
Please check again your settings in “Fonts, VSCode Installation/Configuration”
Window too small:
If this error appears, please widen your VSCode window
Correct font in use:
Recommended values to begin with (right font necessary):
- Symbol check1: y
- Symbol check2: y
- Symbol check3: y
- Symbol check4: y
- Prompt Style: 1–2
- Character Set: 1
- Prompt Colors: 1–4
- Show Current Time: 1–3
- Prompt Height: 2
- Prompt Connection: 1
- Prompt Frame: 1
- Prompt Spacing: 1
- Icons: 2
- Prompt Flow: 1
- Enable Transient Prompt: y
- Instant Prompt Mode: 1 (Verbose)
- Overwrite (Save): y
Configure your git client to work with a git provider
Git clients need to authenticate themselves against any non-public repository for any server-remote action.
With ssh, you have a very convenient way to not authenticate at every pull, push, etc.
1. make sure you have in your .zshrc file under plugins “ssh-agent” and “git” configured
- go to your shell prompt an execute: “ssh-keygen”
- “Enter” once to keep the default path for your ssh-key
- Insert a secure password (twice)
- Execute “cat ~/.ssh/id_rsa.pub”
- Copy output into your clipboard
- Go to your git provider/profile
- Add the ssh key into your profile
- Execute “git config — global user.email “forename.lastname@acme.com”
- Execute “git config — global user.name “Forename Lastname”
- done
The “ssh-agent” will ask you only once to present the password, untill you restart your PC.
Make use of the shortcuts already in the system, such as “gaa” (git add all), you can screen-print all shortcuts via “alias”, or use the VSCode extension
Attention: you need to remember this password, so keep it safe!
Configure kubectl
as you previously installed kubectl already and have configured nice plugins for, we now need to configure it to communicate with your clusters.
- navigate to your rancher cluster of choice and download/copy the “KUEBCONFIG” file to download.
2. paste the content into a new tab in VSCode and edit it to your needs
based on the example underneath, you see the minimal version needed for a valid KUBECONFIG file
3. save it under: ~/.kube/<clustername>.yaml (must be .yaml, not .yml)
4. reload your shell by executing “zsh” in the prompt
done! the clusters are now available in your shell. Start with “kcuc” & “SPACE” & “TAB” to choose which cluster to connect to.
Tip: you can screen-print all shortcuts via “alias”: