This guide will show you how to install Kubernetes using MicroK8s on Ubuntu. MicroK8s make it super easy to get going with Kubernetes. Also, MicroK8s is bundled with tools such as Prometheus. So you enable a feature if you need it.
Canonical is the publisher of MicroK8s, and you can install it on Linux, macOS, and Windows. As per Canonical, MicroK8s is a: low-ops, minimal production Kubernetes for devs, cloud, clusters, workstations, Edge, and IoT.
- Supports high availability and does self-healing with no administrative interventions.
- It is small, with sensible defaults that just work.
- It has the same APIs as provided by Kubernetes.
- Has full enterprise support available with no license fees.
- Will apply security updates automatically by default. You can defer them if you want.
- MicroK8s runs in an immutable container, so your Kubernetes itself is fully containerized.
- It is bundled with a whole bunch of apps that just need to be enabled. For example, Prometheus, Jaeger, Istio, LinkerD, and KNative.
Let’s get started!
First, run the following command to install MicroK8s on Linux:
sudo snap install microk8s – classic
You then want to create a group for MicroK8s and add your user to the group.
sudo usermod -a -G microk8s $USER sudo chown -f -R $USER ~/.kube su - $USER
You can then verify the install status of MicroK8s using the following command:
microk8s status – wait-ready
Next, note that MicroK8s bundles its own version of kubectl for accessing Kubernetes. So instead of using “kubectl get nodes”, you will use “microk8s kubectl get nodes”. You can fix this by adding the following line to your ~/.bash_aliases file:
alias kubectl='microk8s kubectl'
Use the following command to get the status:
Then, if you want, use this command to see the MicroK8s configuration:
Also, you can start MicroK8s using this command:
Then use this command to stop MicroK8s:
Finally, you can enable MicroK8s using this command:
snap enable microk8s
Or, you can disable MicroK8s using this command:
snap disable microk8s
You can also remove MicroK8s if you wish using this command:
snap remove microk8s
You use the following commands to get around your Kubernetes installation:
- Use this command to get all the nodes in the cluster: microk8s kubectl get nodes
- This command will show all the services: microk8s kubectl get services -o wide – all-namespaces
- Next, you can create a deployment using this command: microk8s kubectl create deployment nginx – image=nginx
- Finally, use this command to enable features: microk8s enable dashboard dns storage
Lastly, you can get the auth token for using these commands:
token=$(microk8s kubectl -n kube-system get secret | grep default-token | cut -d " " -f1) microk8s kubectl -n kube-system describe secret $token
You have now installed Kubernetes on your Ubuntu machine using MicroK8s. Which tools do you plan to enable on your fresh Kubernetes install?
You may also be interested in
About the Authors
Anto's editorial team loves the cloud as much as you! Each member of Anto's editorial team is a Cloud expert in their own right. Anto Online takes great pride in helping fellow Cloud enthusiasts. Let us know if you have an excellent idea for the next topic! Contact Anto Online if you want to contribute.
Support the Cause
Support Anto Online and buy us a coffee. Anything is possible with coffee and code.