Working with WSL and AKS

Introduction

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.  

Commands

There are some key commands you will need when working with AKS and kubectl you can find some of these on the first link below.  While working with AKS you will  be using other tools like Docker for creating and managing your container images.,  I have provided some key starter commands for this on the second link.

Helm helps you manage your Kubernetes applications.  Helm enables you to describe, install and upgrade applications on Kubernetes. You will see Helm used on official Microsoft documents for deploying services to AKS.  I have added some starter Helm commands for you in the third link below.

As I will be updating these guides regularly I have provided the links to the markdown files in github rather than paste any commands in this blog.

AKS Commands

Docker Commands

Helm Commands

K9s


K9s is a terminal UI to interact and manage your Kubernetes clusters. It simplifies the management of your cluster removing the need to remember the host of commands needed to dig into cluster and pod configurations and logs.  

K9s runs on any platform Windows/Mac/Linux and allows you to manage Kubernetes across platforms so you can use the same UI to manage your own clusters or EKS/AKS.  It is a really handy tool and I recommend you have play, this video give you a handy demo .  The developer of K9s Fernand Galiana also posts updates on his youtube channel so you can keep up-to-date with the latest features.

WSL

The 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.

Mount point

It is worth noting that when working within WSL and interacting with local disks it creates a mount point back to your local drives. So you will need to access the drives using that format for example, cd C:\users\joebloggs\docs would become cd /mnt/c/Users/RobertLarkin/docs

Themes

You can play around with the Themes and background in WSL.  I found some nice themes from Thomas Maurer which you can find on his blog .

WSL and VSCode

Remote - 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 issues

As 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

To install;
sudo apt-get update
sudo apt-get install dos2unix

To run it just do the following
dos2unix -k -o filename.sh

I hope seeing how I have used these tools to manage AKS has been useful to you.  Keep an eye on the github documents as I will add to these as I learn more.

Comments

Popular posts