Creating a MicroK8s cluster¶
Follow the instructions below to set up a MicroK8s instance from scratch, including all the necessary dependencies and configurations.
1. Prepare your environment¶
Prepare your environment to set up the MicroK8s instance.
You will need a machine running Ubuntu Server 18.04 LTS that:
Make sure that you have Helm version 3.2.1 installed.
The next steps assume that you are starting from a clean install of Ubuntu Server and require that you run commands on a local or remote command line session on the machine.
2. Installing MicroK8s¶
Install MicroK8s on the machine:
Make sure that the package
sudo apt update && sudo apt install nfs-common -y
Install MicroK8s from the
sudo snap install microk8s --classic --channel=1.16/stable sudo usermod -a -G microk8s $USER sudo su - $USER
Check that MicroK8s is running:
3. Configuring MicroK8s¶
Now that MicroK8s is running on the machine we can proceed to enabling the necessary addons:
Configure MicroK8s to allow privileged containers:
sudo mkdir -p /var/snap/microk8s/current/args sudo echo "--allow-privileged=true" >> /var/snap/microk8s/current/args/kube-apiserver microk8s.status --wait-ready
Enable the following MicroK8s addons:
microk8s.enable dns microk8s.status --wait-ready microk8s.enable storage microk8s.status --wait-ready microk8s.enable ingress microk8s.status --wait-ready
Check the output of the commands to make sure that all the addons are enabled correctly.
If by chance any of the addons fails to be enabled, re-execute the
microk8s.enablecommand for that addon.
Restart MicroK8s and its services to make sure that all configurations are working:
microk8s.stop microk8s.start microk8s.status --wait-ready
Export your kubeconfig so that Helm knows on which cluster to install the charts:
microk8s.config > ~/.kube/config
The addons are now enabled and the MicroK8s instance bootstrapped. However, we must wait for some MicroK8s pods to be ready, as failing to do so can result in the pods entering a
microk8s.kubectl wait -n kube-system --for=condition=Ready pod -l k8s-app=kube-dns microk8s.kubectl wait -n kube-system --for=condition=Ready pod -l k8s-app=hostpath-provisioner # If the following command fails, you probably installed the wrong MicroK8s version microk8s.kubectl wait --all-namespaces --for=condition=Ready pod -l name=nginx-ingress-microk8s
Verify that the MicroK8s configuration was successful:
The output of the command should be the following:
microk8s is running addons: knative: disabled jaeger: disabled fluentd: disabled gpu: disabled cilium: disabled storage: enabled registry: disabled rbac: disabled ingress: enabled dns: enabled metrics-server: disabled linkerd: disabled prometheus: disabled istio: disabled dashboard: disabled
After these steps you have ensured that DNS, HTTP, and NGINX Ingress are enabled and working properly inside the MicroK8s instance.
Notes on installing Codacy¶
You can now follow the generic Codacy installation instructions but please note the following:
You must execute all
To simplify this, we suggest that you create an alias so that you can run the commands directly as provided on the instructions:
When running the
helm upgradecommand that installs the Codacy chart, you will be instructed to also use the file
values-microk8s.yamlthat downsizes some component limits, making it easier to fit Codacy in the lightweight MicroK8s solution.