Installing and configuring a microk8s edge cluster
Introduction
This content provides a summary of how to install microk8s, a lightweight and small Kubernetes cluster, on an Ubuntu Linux AMD64-based system. (For more detailed instructions, see the microk8s documentation .)
Pre-requisites
- Architecture must be x86_64
- Operating system must be an Ubuntu LTS distribution
Note: This type of single node edge cluster is meant for development and test only. A single worker node Kubernetes cluster does not provide the scalability or high availability performance characteristics that a production system should have.
Installing
-
Install microk8s:
sudo snap install microk8s --classic --channel=stable
-
If you are not running as root, add your user to the microk8s group:
sudo usermod -a -G microk8s $USER sudo chown -f -R $USER ~/.kube su - $USER # create new session for group update to take place
-
Enable โdnsโ and โstorageโ modules in microk8s:
microk8s.enable dns microk8s.enable storage
Note: Microk8s uses
8.8.8.8
and8.8.4.4
as upstream name servers by default. If these name servers cannot resolve the management hub hostname, you must change the name servers that microk8s is using:-
Retrieve the list of upstream name servers in
/etc/resolv.conf
or/run/systemd/resolve/resolv.conf
. -
Edit
coredns
configmap in thekube-system
namespace. Set the upstream nameservers in theforward
section.microk8s.kubectl edit -n kube-system cm/coredns
-
For more information about Kubernetes DNS, see the Kubernetes documentation .
-
-
Check the status:
microk8s.status --wait-ready
-
The microK8s kubectl command is called microk8s.kubectl to prevent conflicts with an already installed kubectl command. Assuming that kubectl is not installed, add this alias for microk8s.kubectl:
echo 'alias kubectl=microk8s.kubectl' >> ~/.bash_aliases source ~/.bash_aliases
-
Enable the container registry and configure Docker to tolerate the insecure registry:
-
Enable the container registry:
microk8s.enable registry export REGISTRY_ENDPOINT=localhost:32000 export REGISTRY_IP_ENDPOINT=$(kubectl get service registry -n container-registry | grep registry | awk '{print $3;}'):5000
-
Install docker (if not already installed):
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" apt-get install docker-ce docker-ce-cli containerd.io
-
Define this registry as insecure to docker. Create or add to /etc/docker/daemon.json by replacing
<registry-endpoint>
with the$REGISTRY_ENDPOINT
environment variable value that you obtained in a previous step. Also, replace<registry-ip-endpoint>
with the value of the$REGISTRY_IP_ENDPOINT
environment variable value that you obtained in a previous step.{ "insecure-registries": [ "<registry-endpoint>", "<registry-ip-endpoint>" ] }
-
Restart docker to pick up the change:
sudo systemctl restart docker
-