kubernetes

How to get up and running with Kubernetes using MicroK8s

on Mar 26, 19 • by Shuddhasatwa Bhattacharya • with No Comments

An incredibly fast method to get up and running on a Kubernetes (“k8s”) cluster...

Home » Featured, Open Source » How to get up and running with Kubernetes using MicroK8s

Last year, Google and Canonical created the MicroK8s snap for Kubernetes. According to its website, the MicroK8s snap is “A single package of k8s that installs on 42 flavours of Linux. Made for developers and great for appliances.”

Step-by-step instructions: Get up and running with Kubernetes

In this post, I’ll show you an incredibly fast method to get up and running on a Kubernetes (“k8s”) cluster.

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.

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

Prerequisites

1. Get and Update the EPEL
sudo yum install epel-release
Get and Update the EPEL

2. 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

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

Check status of the freshly installed MicroK8s implementation.
freshly installed MicroK8s implementation

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

Ensure iptables are set to forward.

Enable the DNS and the dashboard.

Verify the version.

Check the progress of the cluster on all namespaces:
microk8s.kubectl get all --all-namespaces
Check the progress of the cluster on all namespaces

Check the cluster with cluster-info.
Check the cluster with cluster-info

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.

It uses the following API versions:

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 ~]#

Related reading

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.

We’re here to help

Rogue Wave’s OpenLogic open source architects are available to assist you with this and other popular open source solutions. Contact us to learn more about our solutions.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top