Setting up Juju k8s on microk8s

To install from scratch

sudo snap install microk8s --classic --channel=latest/edge

If you’ve never installed microk8s before do the following. If you’ve installed it before you won’t need to do this.

sudo usermod -a -G microk8s $USER
sudo chown -f -R $USER /.kube

Log out and log back in (or reboot VM may be required)

Now enable the required microk8s plugins

microk8s.enable dns dashboard registry storage
microk8s.status --wait-ready

^ Re-run this until you see storage in the “enabled” list

Now bootstrap juju on microk8s

juju bootstrap microk8s

See https://bugs.launchpad.net/juju/+bug/1923141 for issues with juju dashboard on microk8s. To get the correct IP to use:
microk8s.kubectl describe -n controller-microk8s-localhost pod controller-0| grep ‘^IP:’
To get the username and password:
juju dashboard
Now visit https://${IP}:17070/dashboard using the IP from above.

You can now deploy a sample application, such as:

juju add-model mattermost
juju deploy cs:~mattermost-charmers/mattermost
juju deploy cs:~postgresql-charmers/postgresql-k8s
juju relate mattermost postgresql:db

If you need to tear everything down and start again:

sudo snap remove --purge microk8s
juju unregister microk8s-localhost

And then just start from above with reinstalling microk8s