Working with WSL and AKS
I find I am working with Azure Kubernetes Service (AKS) more and more recently and I thought I would share a few tips and snippets of code I have found useful. For reasons I will explain shortly I have started using the Windows Subsystem for Linux (WSL) as my main way of managing AKS. If you are starting out with AKS I hope you will find some of these hints and tips useful.
AKS is a fully managed Kubernetes service from Azure, if you want to find out more about AKS check out the material and video from Microsoft here . For the purpose of this document I am assuming you are familiar with AKS and have at least started to play around with it.
WSLThe Windows Subsystem for Linux allows you to run a GNU/Linux environment directly on Windows without having to configure this as a Virtual Machine. Follow this guide if you would like to setup WSL and install Ubuntu. This also shows you how to use the WSL in the Windows Terminal.
As you can see below this allows me to run Ubuntu alongside PowerShell and Azure Cloud Shell in Windows Terminal .
Why am I doing this? apart from the fact it is very cool (well in a geeky way!). When working with AKS and Kubernetes you will be using kubectl, Helm, Docker and other command line tools and in my personal experience I have found a lot of the documentation and help articles to be written for bash. There is nothing stopping you using Windows command line and PowerShell but I have found it time consuming converting some of the commands and getting them to work. This can just be having to change path command from / to \ .
In addition I am working with a team who are on a mix of Windows and Linux platforms and being able to share commands without having to edit the commands has been really useful. As an additional bonus it helps me to learn more Linux commands.
WSL and VSCodeRemote - WSL is an extension on the marketplace for integrating WSL with VScode. To open VS code from your terminal you just type code . which opens a new VS Code window connected to your default WSL distro. You can open it in other ways which are described in the link . This is very handy because now you can work with your Docker and Helm configurations in VScode while interacting with the WSL to push container images or make changes to your AKS cluster.
File format issuesAs I have worked with WSL more I have had occasions where I edit files outside of WSL then when I try to use these files in the Linux environment I see errors about unrecognised format issues or similar. This could just be different programs adding unexpected white space. To resolve this you can use dos2unix package which is a text file format converter to help when switching between dos/mac to unix and vice versa
sudo apt-get update
To run it just do the following
dos2unix -k -o filename.sh