By now you’ve heard the stories that Microsoft loves Linux and fully embraces the open-source world. Microsoft, under Satya Nadella, has taken a new stance on open-source, which to some is a complete flip-flop from the Microsoft of the past. The “New Microsoft” is one of the top open-source contributors on GitHub and has opened the following projects to open-source:

  • PowerShell
  • Visual Studio Code
  • Edge
  • Windows Terminal
  • Calculator
  • TypeScript
  • .NET Core
  • Windows Subsystem for Linux (WSL)

and many more.

Not to mention, in October of 2018, Microsoft joined the Open Invention Network (OIN) and has opened 60,000 patents to open-source. You can read more about that here.

Canonical

Among the relationships Microsoft has formed with Red Hat, Oracle, and SUSE since its mobile-first, cloud-first initiative in 2014, one of its closest is Canonical. Canonical fully supports the Ubuntu distribution running in Azure. So much so, that they even have their department at the Redmond campus. Contact them via email: linux@microsoft.com.

You started to get a feel for this cultural shift at the most recent WSL conf; which we talked about in episode 344 of the Linux Unplugged Podcast. Canonical, having such an integrated and unified presence in the Azure ecosystem, provides a perfect opportunity to demonstrate how easy it is to get up and running with MicroK8s in Azure.

MicroK8s

MicroK8s is a CNCF certified upstream Kubernetes deployment that runs entirely on your workstation or edge device. The only requirement is a Linux VM. Since the snap package manager is pre-installed on the official Ubuntu 18.04 LTS image in Azure, getting up and running is a cinch!

Your Toolbox

By the end of this tutorial, you will have a Kubernetes cluster running locally on Azure VMs. Why? Because it’s arguably the fastest way to get Kubernetes up and running, the footprint is small, it’s reliable, and it’s FREE!

To follow along, you must have access to an Azure account. If you don’t have an Azure account, NO PROBLEM! Use one of our cloud sandboxes! Cloud sandboxes are included with your Linux Academy subscription.

All of the following commands should be run in Azure Cloud Shell. Access this shell by going to http://shell.azure.com from any browser and logging into your Azure account.

Let’s Get Up and Running!

Starting with a deployment to our Azure account, we’ll create two virtual machines, which we’ll use for our two MicroK8s nodes. To do this, we’ll create a parameter file and an Azure Resource Manager (ARM) template file.

First, create some variables to set the username and password for the two virtual machines (I chose to generate a secure 16 character password, but you can create a custom password if you wish):

~$ adminUsername=”azureuser”

~$ adminPassword=$(openssl rand -base64 16)

Now, insert those variables into a file named ‘parameters.json’ which will be used in our deployment:

~$ cat < parameters.json

{

“adminUsername”: { “value”: “$adminUsername” },

“adminPassword”: { “value”: “$adminPassword” }

}

EOF

Now, Download the ARM Template File, and Rename It “template.json”:

~$ wget https://gist.githubusercontent.com/chadmcrowell/441058e5fd9379b64b7c875b521564f5/raw/0db25244f66f99af3bf24f812cb537635d15f295/ubuntu-microk8s.json-O template.json

Create the resource group and deploy the ARM template (if you’re using a cloud sandbox, set the “resourceGroupName” variable to the existing resource group name and skip the resource group creation):

~$ resourceGroupName=”vmdeploy-rg”

~$ location=”westus”

~$ deploymentName=”vm-deploy”

~$ az group create -n $resourceGroupName -l $location # skip this step if you are using cloud sandbox

Now that we’re all set up, let’s start the deployment of the VMs, with the “az deployment group create” command, passing in the variables we just set as well as the template file and the parameters file:

~$ az deployment group create \

-g $resourceGroupName \

-n $deploymentName \

–template-file template.json \

–parameters parameters.json

Once the deployment is complete (mine took about 5 minutes), you can retrieve both of the public IP addresses of the VMs with the following command:

~$ az vm list-ip-addresses -g vmdeploy-rg | grep ipAddress

SSH into the first node using the following command:

~$ ssh azureuser@

Once you’re logged in, add your user to the microK8s group and allow access to the “.kube” directory so that you can issue commands to the cluster:

~$ sudo usermod -a -G microk8s $USER

~$ sudo chown -f -R $USER ~/.kube

~$ su – $USER

You can check if microK8s is ready by using this command:

~$ microk8s status –wait-ready

#azure #kubernetes #running #microk8s

MicroK8s: Up and Running in Azure
16.35 GEEK