Skip to content
Henryk Paluch edited this page Nov 7, 2021 · 4 revisions

Ubuntu Kubernetes (k8s) setup

How to quickly setup Kubernetes under Ubuntu.

Required OS:

  • Ubuntu 20 LTS Tested:
  • Ubuntu 20.04.3 LTS

TIP: See:

Setup

At first you have to install snapd packages using: (see a bit unhelpful https://snapcraft.io/docs/installing-snap-on-ubuntu)

sudo apt-get install snapd

WARNING! There also exists package snap which has nothing common with snapcraft (it is some kind of DNA tool :-)

Now we have to follow guide from:

sudo snap install microk8s --classic
microk8s status --wait-ready

You will likely get permission error and will be guided how to fix it:

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

Now relogin (you can use newgrp microk8s instead, but it will invoke new shell)

After relogin try:

microk8s status --wait-ready
# we changed plugint list a bit
microk8s enable dashboard dns rbac

Normally you have to run kubectl using microk8s wrapper: (from guide)

microk8s kubectl get all --all-namespaces

NOTE: you can ignore the messages from dashboard (about RBAC). To get token you just need to run:

microk8s dashboard-proxy

It will print Dashboard URL and necessary token

What next - you can follow for example:

Example from above guide:

microk8s kubectl create deployment nginx --image=nginx

Now you have to wait until command below will show Status: Running and READY: 1/:

microk8s kubectl get pods
NAME                     READY   STATUS    RESTARTS   AGE
nginx-6799fc88d8-kc7zq   1/1     Running   0          59s

How to reach Nginx Pod? According to official docs

Once you are finished with k8s you should stop it to relieve your computer resources:

microk8s stop

TODO

Resources:

Clone this wiki locally