Multi-node k8s cluster and elasticity on localhost

microk8s
minikube

#1

A k8s newbie here. I’d read-around a bit about k8s several months back without much hands-on work, but trying to pickup where I left. I’m in the need of an offline learning environment, with an objective to learn also about multi-node clusters. Based on a bit of hurried reading around, I understand that while:

  • Minikube distribution enables one to run a 1-node k8s cluster on localhost,
  • MicroK8s distribution enables one to run a k8s cluster on localhost too, but potentially with multiple-nodes

It is the perceived claim about support of multiple-nodes in a k8s cluster that I am not so sure that I understood correctly. Even it is correct what all can be done with such a cluster, and whether it supports the notion of elasticity or not ?

At the microk8s.io website, I see statements that cause those doubts:

  1. Single node Kubernetes done right”
  2. “It’s not elastic, but it is on rails”
  3. While I (think I) understand that microk8s enables ones to use a local development environment, offline – the k8s CLI appear to be prefixed with “microk8s.”. Is that a replacement of the kubectl CLI ? Does it mean that moving to k8s on Cloud will need some re-familiarization of another CLI ?

Thanks for bearing with my newbie questions.


#2

I don’t know about microk8s, but You can also consider using VMs and kubeadm.


#3

Hi @Banibrata_Dutta

MicroK8s gives you a certified single node Kubernetes cluster. The single node is your localhost.

There are a few points we need to clarify.

  • MicroK8s ships with the upstream kubectl. kubectl is available namespaced under microk8s.kubectl. If you move to a cloud you should have exactly the same CLI experience.
  • Elasticity is supported at the level of the deployments. You can have your deployments scale by adding more pods. However, since you have a single node all pods will be scheduled to that single node.
  • The MicroK8s cluster is local but the experience you will get if you go offline will probably be bad. For example, enabling addons works by going out to public repositories an fetching images. Local cluster: yes, offline: no.

Your feedback is very important to us. Would you be able to open an issue at https://github.com/canonical-websites/microk8s.io/issues/new with suggestions on how we can make the docs more accurate.

Thank you for considering MicroK8s.


#4

Hi,

The microk8s docs at https://microk8s.io/docs/ says that microk8s.kubectl is the same program as kubectl. The difference is that microk8s.kubectl is preconfigured to access the microk8s based cluster.

The docs also indicate that you can alias microk8s.kubectl to kubectl (so that when you enter the kubectl command, it will actually run microk8s.kubectl)

Further, if you already have kubectl installed, you can continue to use that by writing the microk8s config to a file, then setting the KUBECONFIG env variable to point to that config file.

from the docs…

If you do not already have a kubectl installed you can alias microk8s.kubectl to kubectl using the following command

snap alias microk8s.kubectl kubectl

This measure can be safely reverted at anytime by doing

snap unalias kubectl

If you already have kubectl installed and you want to use it to access the MicroK8s deployment you can export the cluster’s config with:

microk8s.kubectl config view --raw > $HOME/.kube/config