How to configure Microk8s

I am migrating from minikube to Microk8s (because of some problem with resource consumption) and I want to change the configs of Microk8s and control the resources that it can use (cpu, memory, etc.).

In minikube we can use commands like below to set the amount of resources for minikube:

minikube config set memory 8192
minikube config set cpus 2

But I don’t know how to do it in Microk8s. I used below commands (with and without sudo):

microk8s.config set cpus 4
microk8s.config set cpu 4

And they returned:

apiVersion: v1
- cluster:
    certificate-authority-data: VORCBDRVJUSUZJQ0FURS0tLS0...
  name: microk8s-cluster
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
- name: admin
    username: admin
    password: ...

But when I get the describe for that node I see that Microk8s is using 8 cpu:

 cpu:                8
 ephemeral-storage:  220173272Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             32649924Ki
 pods:               110
 cpu:                8
 ephemeral-storage:  219124696Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             32547524Ki
 pods:               110
1 Like

I don’t think microk8s.config does what you think it does…

The documentation is very sparse, but this command:

mickok8s.config --help


Retrieve the client config, similar to microk8s.kubectl config view --raw

 -h, --help          Show this help
 -l, --use-loopback  Report the cluster address using the loopback address
                     ( rather than the default interface address

So basically returns the configuration (~/.kube/config) for the “cluster”.

However I too am very interested in how to go about configuring microk8s (CPU, memory, disk, etc) like minikube.


Indeed microk8s.config is not the right way to set resource usage limits.

MicroK8s turns your machine into a Kubernetes node. There is no VM so as to appoint overall CPU and memory limits. Instead you should apply resource utilization constraints to the running containers as you would have done in any other Kubernetes cluster. The official docs is a good place to check your options: Managing Compute Resources for Containers - Kubernetes

1 Like

As this is a tool for developing applications on Kubernetes I think it would be good to add some resource management to it independent from the deployment/pod resource management because developers will run this on their own machine and not on a powerful server.

I am using MicroK8s in MacOS which uses Multipass as the VM provider.

I ran the following to remove the VM and recreate the VM with bigger CPU.

microk8s stop
microk8s uninstall
multipass delete <instance-name>
multipass purge
microk8s install --cpu=4 # default cpu is 2