For the latest updates and improvements, see the latest Cloud documentation instead.
Creating a MicroK8s cluster#
Follow the instructions below to set up a MicroK8s instance from scratch, including all the necessary dependencies and configurations.
MicroK8s is a lightweight, fully conformant, single-package Kubernetes developed by Canonical. The project is publicly available on GitHub.
1. Prepare your environment#
Prepare your environment to set up the MicroK8s instance.
-
You will need a machine running Ubuntu Server 20.04 LTS that:
- Is correctly provisioned with the resources described for MicroK8s in the system requirements
- Is able to establish a connection to the PostgreSQL instance described in the system requirements
-
Make sure that you have Helm version 3.8.1 installed.
The next steps assume that you're 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
nfs-common
is installed:sudo apt update && sudo apt install nfs-common -y
-
Install MicroK8s from the
1.19/stable
channel:sudo snap install microk8s --classic --channel=1.19/stable sudo usermod -a -G microk8s $USER sudo su - $USER
-
Check that MicroK8s is running:
microk8s.status --wait-ready
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
Important
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.enable
command 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
CrashLoopBackoff
state: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:
microk8s.status --wait-ready
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
kubectl
commands asmicrok8s.kubectl
commands instead.To simplify this, we suggest that you create an alias so that you can run the commands directly as provided on the instructions:
alias kubectl=microk8s.kubectl
-
When running the
helm upgrade
command that installs the Codacy chart, you will be instructed to also use the filevalues-microk8s.yaml
that downsizes some component limits, making it easier to fit Codacy in the lightweight MicroK8s solution.
Share your feedback 📢
Did this page help you?
Thanks for the feedback! Is there anything else you'd like to tell us about this page?
255 characters left
We're sorry to hear that. Please let us know what we can improve:
255 characters left
Alternatively, you can create a more detailed issue on our GitHub repository.
Thanks for helping improve the Codacy documentation.
If you have a question or need help please contact support@codacy.com.