Canonical Voices

Posts tagged with 'virtualization'

K. Tsakalozos

MicroK8s is a local deployment of Kubernetes. Let’s skip all the technical details and just accept that Kubernetes does not run natively on MacOS or Windows. You may be thinking “I have seen Kubernetes running on a MacOS laptop, what kind of sorcery was that?” It’s simple, Kubernetes is running inside a VM. You might not see the VM or it might not even be a full blown virtual system but some level of virtualisation is there. This is exactly what we will show here. We will setup a VM and inside there we will install MicroK8s. After the installation we will discuss how to use the in-VM-Kubernetes.

A multipass VM on MacOS

Arguably the easiest way to get an Ubuntu VM on MacOS is with multipass. Head to the releases page and grab the latest package. Installing it is as simple as double-clicking on the .pkg file.

To start a VM with MicroK8s we:

multipass launch --name microk8s-vm --mem 4G --disk 40G
multipass exec microk8s-vm -- sudo snap install microk8s --classic
multipass exec microk8s-vm -- sudo iptables -P FORWARD ACCEPT

Make sure you reserve enough resources to host your deployments; above, we got 4GB of RAM and 40GB of hard disk. We also make sure packets to/from the pod network interface can be forwarded to/from the default interface.

Our VM has an IP that you can check with:

> multipass list
Name State IPv4 Release
microk8s-vm RUNNING Ubuntu 18.04 LTS

Take a note of this IP since our services will become available there.

Other multipass commands you may find handy:

  • Get a shell inside the VM:
multipass shell microk8s-vm
  • Shutdown the VM:
multipass stop microk8s-vm
  • Delete and cleanup the VM:
multipass delete microk8s-vm 
multipass purge

Using MicroK8s

To run a command in the VM we can get a multipass shell with:

multipass shell microk8s-vm

To execute a command without getting a shell we can use multipass exec like so:

multipass exec microk8s-vm -- /snap/bin/microk8s.status

A third way to interact with MicroK8s is via the Kubernetes API server listening on port 8080 of the VM. We can use microk8s’ kubeconfig file with a local installation of kubectl to access the in-VM-kubernetes. Here is how:

multipass exec microk8s-vm -- /snap/bin/microk8s.config > kubeconfig

Install kubectl on the host machine and then use the kubeconfig:

kubectl --kubeconfig=kubeconfig get all --all-namespaces

Accessing in-VM services — Enabling addons

Let’s first enable dns and the dashboard. In the rest of this blog we will be showing different methods of accessing Grafana:

multipass exec microk8s-vm -- /snap/bin/microk8s.enable dns dashboard

We check the deployment progress with:

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl get all --all-namespaces

After all services are running we can proceed into looking how to access the dashboard.

The Grafana of our dashboard

Accessing in-VM services — Use the Kubernetes API proxy

The API server is on port 8080 of our VM. Let’s see how the proxy path looks like:

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl cluster-info
Grafana is running at

By replacing with the VM’s IP, in this case, we can reach our service at:

Accessing in-VM services — Setup a proxy

In a very similar fashion to what we just did above, we can ask Kubernetes to create a proxy for us. We need to request the proxy to be available to all interfaces and to accept connections from everywhere so that the host can reach it.

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl proxy --address='' --accept-hosts='.*'
Starting to serve on [::]:8001

Leave the terminal with the proxy open. Again, replacing with the VMs IP we reach the dashboard through:

Make sure you go through the official docs on constructing the proxy paths.

Accessing in-VM services — Use a NodePort service

We can expose our service in a port on the VM and access it from there. This approach is using the NodePort service type. We start by spotting the deployment we want to expose:

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl get deployment -n kube-system  | grep grafana
monitoring-influxdb-grafana-v4 1 1 1 1 22h

Then we create the NodePort service:

multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl expose deployment.apps/monitoring-influxdb-grafana-v4 -n kube-system --type=NodePort

We have now a port for the Grafana service:

> multipass exec microk8s-vm -- /snap/bin/microk8s.kubectl get services -n kube-system  | grep NodePort
monitoring-influxdb-grafana-v4 NodePort <none> 8083:32580/TCP,8086:32152/TCP,3000:32720/TCP 13m

Grafana is on port 3000 mapped here to 32720. This port is randomly selected so it my vary for you. In our case, the service is available on


MicroK8s on MacOS (or Windows) will need a VM to run. This is no different that any other local Kubernetes solution and it comes with some nice benefits. The VM gives you an extra layer of isolation. Instead of using your host and potentially exposing the Kubernetes services to the outside world you have full control of what others can see. Of course, this isolation comes with some extra administrative overhead that may not be applicable for a dev environment. Give it a try and tell us what you think!



MicroK8s on MacOS was originally published in ITNEXT on Medium, where people are continuing the conversation by highlighting and responding to this story.

Read more
Larry Poon

The cloud is getting a lot of attention. Understandably and rightly so – it is one of the hottest topics around. An on-line panel discussion on how businesses can incorporate cloud computing into their existing datacenter operations will take place in a webinar hosted by rPath on 24 September 2009. You’ll hear from the some of the most experienced experts in the field:

Michael Crandell, Chief Executive Officer of RightScale

Erik Troan, founder and Chief Technology Officer of rPath

Dr. Rich Wolski, Chief Technology Officer of Eucalyptus Systems

Matt Zimmerman, Chief Technology Officer of Canonical

David Berlind , Chief Content Officer of TechWeb

We’re looking forward to participating on this webinar, so please join us on 24 September 2009 at 11:00 a.m. PST.

For more information and registration please go to the the rPath registration page.

Read more

Next week (31 August through 3 September) VMorld 2009 kicks off in San Francisco at the Moscone Center. For the second year, Canonical has a booth to demonstrate Ubuntu’s virtualization and cloud computing capabilities.

Last year VMWorld 2008 was in sunny Las Vegas. We talked to thousands of people throughout the show, and only found a handful who hadn’t used Ubuntu – don’t worry we sent every one away with a free CD so they could put that right! It was a great show with lots of interest in Ubuntu following on from the 8.04 LTS release, and our virtualization solution.

We expect the 2009 show to be just as much fun. Ubuntu has been on the top of the VMWare charts as a base OS for many virtual machine images, so we hope that the new virtualization features coming in 9.10 will be well received. In 9.04 we previewed Ubuntu Enterprise Cloud (UEC) our private or on-premises cloud. This gives anyone who has their own servers the ability to set-up a cloud similar to Amazon’s EC2.

We’ll be presenting a talk for enterprises on how cloud computing can help them at the Solution Exchange Theatre on Wednesday 2nd September at 11:50 am. Entitled “The Clear Path to a Cloudy Enterprise”, it will be given by John Pugh, one of Canonical’s Partner Managers. If you would like to hear about the future of cloud computing, how open source offers a real alternative, and how Ubuntu can be used in this scenario then this talk should be informative and fun.

If you are going to be at VMWorld then please come along to the Canonical booth (#2403) and say hello to us. We would love to talk to you about Ubuntu, how you’re using it, and how you can get more from it – see you
in San Francisco!

Read more