Image Blog How to Get Up and Running with Kubernetes
March 26, 2019

How to Get Up and Running With Kubernetes Using MicroK8s

Containers

MicroK8s offers a new way to install Kubernetes. In this blog, we provide detailed instructions for installing Kubernetes with MicroK8s.

Back to top

What Is MicroK8s?

MicroK8s is a single package of k8s (Kubernetes) for Linux. The MicroK8s snap for Kubernetes was created by Google and Canonical in 2018.

Back to top

Why Is Kubernetes Called K8s?

Kubernetes is called K8s, because the numeral "8" replaces the last eight letters in Kubernetes.

Back to top

How to Install Kubernetes With MicroK8s

Here's how to install Kubernetes using MicroK8s.

Note: Securing your cluster properly is very important. At Tesla, an unsecured administrative console for Kubernetes caused one if its cloud accounts to be compromised. In addition, unsuspecting folks had their microk8s cluster compromised, then used to mine bitcoin.

1. Get MicroK8s

Since this post is about a quick MicroK8s installation, I include some of the snap MicroK8s features prior to the imperative operation commands using the kubectl cli command set.

a. Get and Update the EPEL:

 sudo yum install epel-release

Get and Update the EPEL

b. Install and Update snap core: 

sudo yum install snapd

Install and update snap core

sudo systemctl enable --now snapd.socket

sudo systemctl enable --now snapd.socket

sudo ln -s /var/lib/snapd/snap /snap

sudo ln -s /var/lib/snapd/snap /snap

2. Use MicroK8s to Install Kubernetes

Now, that the prerequisites are done, we leverage MicroK8s to make Kubernetes installation a snap! sudo snap install microk8s --classic

sudo snap install microk8s --classic

a. Check Status of the Freshly Installed MicroK8s Implementation

Micro k

You can create an alias for kubectl, docker if typing 9 extra characters is undesirable. I chose to leave it as is, as the images below can attest.

create an alias for kubectl, docker
create an alias for kubectl, docker

On the command span info MicroK8s we are able to see that in the snap channel, the latest version of Kubernetes has been updated.

command span info MicroK8s
command span info MicroK8s

b. Ensure iptables Are Set to Forward

Ensure iptables are set to forward.

c. Enable the DNS and the Dashboard

Enable the DNS and the dashboard.

d. Verify the Version

Verify the version.

e. Check the Progress of the Cluster on All Namespaces:

microk8s.kubectl get all --all-namespaces

Check the progress of the cluster on all namespaces

f. Check the Cluster With cluster-info

Check the cluster with cluster-info

g. View the Configuration of the New Cluster

View the configuration of the new cluster

As Kubernetes is primarily a cluster management framework, get the list of clusters and verify the cluster name within the specific context.

Kubernetes is primarily a cluster management framework

It uses the following API versions:

It uses the following API versions:

Finally, feel free to play around with Kubernetes and MicroK8s. It’s allowed, really!

Finally – feel free to muck around. It’s allowed, really!

Don’t worry if the cluster becomes unhealthy. You can reset the cluster using: microk8s.reset The following was edited to represent the reset steps:


[root@localhost ~]# microk8s.reset
Calling clean_cluster
Cleaning resources in namespace default
endpoints "kubernetes" deleted
secret "default-token-s65lp" deleted
serviceaccount "default" deleted
service "kubernetes" deleted
Cleaning resources in namespace kube-public
Cleaning resources in namespace kube-system
configmap "eventer-config" deleted
service "kubernetes-dashboard" deleted
service "monitoring-grafana" deleted
service "monitoring-influxdb" deleted
deployment.apps "heapster-v1.5.2" deleted
deployment.apps "kube-dns" deleted
deployment.apps "kubernetes-dashboard" deleted
deployment.apps "monitoring-influxdb-grafana-v4" deleted
replicaset.apps "heapster-v1.5.2-6bc7c4965d" deleted
replicaset.apps "kube-dns-6ccd496668" deleted
replicaset.apps "kubernetes-dashboard-654cfb4879" deleted
replicaset.apps "monitoring-influxdb-grafana-v4-6679c46745" deleted
event.events.k8s.io "heapster-v1.5.2-6bc7c4965d-786hb.158a1215c9dbc66a" deleted
event.events.k8s.io "monitoring-influxdb-grafana-v4-6679c46745.158a1215cc8b290c" deleted
configmap "extension-apiserver-authentication" deleted
configmap "heapster-config" deleted
endpoints "monitoring-influxdb" deleted
event "monitoring-influxdb-grafana-v4-6679c46745-7zdfl.158975c8f47bb8c6" deleted
pod "monitoring-influxdb-grafana-v4-6679c46745-7zdfl" deleted
secret "default-token-w4gxg" deleted
serviceaccount "kubernetes-dashboard" deleted
service "monitoring-influxdb" deleted
deployment.apps "monitoring-influxdb-grafana-v4" deleted
replicaset.apps "monitoring-influxdb-grafana-v4-6679c46745" deleted
event.events.k8s.io "monitoring-influxdb-grafana-v4-6679c46745.158a1215cc8b290c" deleted
Waiting for kubernetes resources to be released
[root@localhost ~]#

 

Back to top

More on Kubernetes and MicroK8s

Now that I’ve shown you how to get up and running with Kubernetes, let me tell you about the real fun: making an already unhealthy cluster healthy. On the Ubuntu blog, there's an interesting post on setting up Kubernetes a Raspberry Pi with MicroK8s. Also, I found a post that lists projects using MicroK8s.

Back to top

Get Help With MicroK8s and Kubernetes

This blog provided tips to help you install Kubernetes with MicroK8s faster. But the fastest way to get up and running with Kubernetes — and revolutionize your business — is to enlist the help of experts.

OpenLogic experts are skilled in Kubernetes. We can help you:

  • Migrate to Kubernetes.
  • Deploy a fully automated Kubernetes Production Cluster on any substrate of your choice with our Kubernetes Foundations Service.
  • Get ongoing enterprise support for Kubernetes.

Talk to one of our Kubernetes experts today to learn how we can help you.

Talk to a Kubernetes Expert

 

Related Content

Back to top