23 February 2022

MicroK8s on Ubuntu Server

Aim: To install MicroK8s on Ubuntu Server

Also see k8s docs here.

Download version of Ubuntu Server and create a bootable USB

Easiest to do from another machine running Ubuntu: See the tutorial

It is possible from Windows or Mac but there are some hoops to jump through.

Boot from the USB and Install

Plug in the USB and reboot, ensuring your BIOS is set o boot from USB. Follow the guide to continue the setup procedure. Note that the last step of installing security updates will take a long time.

  • Do install SSH so you can connect remotely. Suggest downloading keys e.g. from GitHub

Post Install

Install MicroK8s

You can install via snap or apt: Snap includes all dependencies and provides automatic updates but likely runs slower as installed independently. Apt requires that you install the dependencies correctly.
Enable ad ons e.g. 
microk8s enable dns
microk8s enable storage
microk8s enable helm
NB: If you're using kubesail.io follow their docs here

Setup kubectl

MicroK8s comes with it's own microk8s.kubectl cmd, so if you want to you can either configure kubectl or setup an alias

Configure kubctl

  1. Install kubectl if you don't have it already: either from native package manager or snap.
    snap install kubectl --classic && kubectl version --client
  2. Configure it to work with MicroK8s. If the only configuration:
    cd $HOME
    mkdir .kube
    cd .kube
    microk8s config > config

Setup Alias

Edit bashrc file: echo "alias kubectl='microk8s kubectl'" >> ~/.bashrc
Execute: . ~/.bashrc

Install Helm

A number of packages are distributed using helm so its worth having that locally:

sudo snap install helm --classic

Join a Cluster

https://microk8s.io/docs/clustering

On existing node: microk8s add-node
On joining node: microk8s join ...

If the machines are local you might need to add the hostnames to /etc/hosts:
vi /etc/hosts
Append:
[ip address] [hostname]

No comments:

Post a Comment