LinuxTutorialsUbuntu

How To Install MicroK8s on Ubuntu 20.04 LTS

Install MicroK8s on Ubuntu 20.04

In this tutorial, we will show you how to install MicroK8s on Ubuntu 20.04 LTS. For those of you who didn’t know, MicroK8s is a lightweight upstream Kubernetes distribution package to run as an immutable container. MicroK8s follows upstream Kubernetes releases and focuses on providing an effortless installation and management experience. Here’s how to get started running your own cluster.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MicroK8s on Ubuntu 20.04 (Focal Fossa). You can follow the same instructions for Ubuntu 18.04, 16.04, and any other Debian-based distribution like Linux Mint.

Prerequisites

  • A server running one of the following operating systems: Ubuntu 20.04, 18.04, and any other Debian-based distribution like Linux Mint or elementary OS.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install MicroK8s on Ubuntu 20.04 LTS Focal Fossa

Step 1. First, make sure that all your system packages are up-to-date by running the following apt commands in the terminal.

sudo apt update
sudo apt upgrade

Step 2. Enable Snap.

By default, Snap is installed on the Ubuntu server but if it’s not running, run the following command below to start it first:

sudo systemctl start snapd.socket

Step 3. Installing MicroK8s on Ubuntu 20.04.

Now run the following command to install MicroK8s on your Ubuntu system:

sudo snap install microk8s --classic

Also, you can select a specific release using the --channel flag:

sudo snap install microk8s --classic --channel=1.22/stable

Once successfully installed, verify the MicroK8s status with the following command below:

### show status ###
root@idroot.us:~# microk8s status

microk8s is running
addons:
ambassador: disabled
cilium: disabled
dashboard: disabled
dns: disabled
fluentd: disabled
gpu: disabled
helm: disabled
helm3: disabled
host-access: disabled
ingress: disabled
istio: disabled
jaeger: disabled
knative: disabled
kubeflow: enable
linkerd: disabled
metallb: disabled
metrics-server: disabled
multus: disabled
prometheus: disabled
rbac: disabled
registry: disabled
storage: disabled

### show config ###
root@idroot.us:~# microk8s config

apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: LS0tL...
    server: https://192.0.0.30:16443
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    token: THhlZmeilanaxNW00eDR0ulfakk5V2Z5c0mariaxWkdxWT0K

root@idroot.us:~# microk8s kubectl get all

NAME                 TYPE        CLUSTER-IP     EXTERNAL-IP   PORT(S)   AGE
service/kubernetes   ClusterIP   192.168.77.21                443/TCP   3m47s

root@idroot.us:~# microk8s kubectl get nodes

NAME            STATUS   ROLES    AGE     VERSION
mey.idroot.us   Ready       4m10s   v1.18.6-1+64f5e461fe36a7

### stop MicroK8s ###
root@idroot.us:~# microk8s stop
stop of [microk8s.daemon-apiserver microk8s.daemon-apiserver-kicker microk8s.da…
Stopped.

root@idroot.us:~# microk8s status
microk8s is not running. Use microk8s inspect for a deeper inspection.

### start MicroK8s ###
root@idroot.us:~# microk8s start
Started.

Congratulations! You have successfully installed MicroK8s. Thanks for using this tutorial for installing the MicroK8s on Ubuntu 20.04 LTS Focal Fossa system. For additional help or useful information, we recommend you check the official MicroK8s website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!

r00t

r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button