Logo

Armand.nz

Home / About / Linkedin / Github

Muilti node Microk8s clusters using multipass

#kubernetes #microk8s #ubuntu |

Source: Multipass microk8s cluster

Multipass

Multiplass is a very and fast tool to create vms; the network stack integrates seamless with the OS in linux, Mac and Windows and vms run as natively as possible, on linux uses kvm , on Mac uses Hypervisor.framework / hyperkit and on Windows uses Hyper-V. There are also other combinations using Virtualbox and more

To install multipass just follow the official installation for your OS of preferences here.

In this example we will run a three node cluster, one master and two worker nodes:

# The first launch takes a while as we need to Retrieving the image for the first time. Subsequent launches are faster

# Create master
$ multipass launch --name master -m 2G
Launched: master

# Create workers
$ multipass launch --name worker1 -m 2G
Launched: worker1

$ multipass launch --name worker2 -m 2G
Launched: worker2

# Show the newly created vms
$ multipass ls
master                  Running           10.94.112.77     Ubuntu 20.04 LTS
worker1                 Running           10.94.112.254    Ubuntu 20.04 LTS
worker2                 Running           10.94.112.204    Ubuntu 20.04 LTS
worker2                 Running           192.168.64.6     Ubuntu 18.04 LTS

microk8s

We will also use microk8s because it integrates seamless with multipass

To create the master I will install microk8s and get some basic configuration and modules up and running.

# Log in to the master
$ multipass shell master

# Install the microk8s snap
$ sudo snap install microk8s --classic --channel=1.22/stable
2020-06-13T12:03:41-03:00 INFO Waiting for restart...
microk8s (1.18/stable) v1.18.3 from Canonical✓ installed

# Adjust the permisions so the current user can access
# micrik8s wihtout restrictions
# you might need to exit and login
# again for permisions to get applied
$ sudo usermod -a -G microk8s $USER
$ sudo chown -f -R $USER ~/.kube

# Check the status of microk8s
$ microk8s status --wait-ready
microk8s is running
addons:
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
helm3: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
kubeflow: disabled
linkerd: disabled
metallb: disabled
metrics-server: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled

# Create an alieas for kubectl
$ echo "alias kubectl='microk8s kubectl'" >> ~/.bash_aliases
$ source ~/.bash_aliases


# Lets add some basic things to the cluster
$ microk8s enable dns storage
Enabling DNS
Applying manifest
serviceaccount/coredns created
configmap/coredns created
deployment.apps/coredns created
service/kube-dns created
clusterrole.rbac.authorization.k8s.io/coredns created
clusterrolebinding.rbac.authorization.k8s.io/coredns created
Restarting kubelet
DNS is enabled
Enabling default storage class
deployment.apps/hostpath-provisioner created
storageclass.storage.k8s.io/microk8s-hostpath created
serviceaccount/microk8s-hostpath created
clusterrole.rbac.authorization.k8s.io/microk8s-hostpath created
clusterrolebinding.rbac.authorization.k8s.io/microk8s-hostpath created
Storage will be available soon
comments powered byDisqus

Copyright © Armand