<p>I am migrating from minikube to Microk8s and I want to change the configs of Microk8s and control the resources that it can use (cpu, memory, etc.).</p>

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

<pre><code>minikube config set memory 8192
minikube config set cpus 2
</code></pre>

<p>But I don't know how to do it in Microk8s. I used below commands (with and without sudo):</p>

<pre><code>microk8s.config set cpus 4
microk8s.config set cpu 4
</code></pre>

<p>And they returned:</p>

<pre><code>apiVersion: v1
clusters:
- cluster:
    certificate-authority-data: VORCBDRVJUSUZJQ0FURS0tLS0...
    server: https://10.203.101.163:16443
  name: microk8s-cluster
contexts:
- context:
    cluster: microk8s-cluster
    user: admin
  name: microk8s
current-context: microk8s
kind: Config
preferences: {}
users:
- name: admin
  user:
    username: admin
    password: ...
</code></pre>

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

<pre><code>Capacity:
 cpu:                8
 ephemeral-storage:  220173272Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             32649924Ki
 pods:               110
Allocatable:
 cpu:                8
 ephemeral-storage:  219124696Ki
 hugepages-1Gi:      0
 hugepages-2Mi:      0
 memory:             32547524Ki
 pods:               110
</code></pre>

<p>How can I change the config of Microk8s?</p>

AVarf
<p>You have a wrong understanding of the microk8s concept. </p>

<p>Unlike minikube, microk8s is not provisioning any VMs for you, it's running on you host machine, hence all resources of the host are allocated for microk8s.</p>

<p>So, in order to keep your cluster resource in borders, you have to manage it with k8s pod/container <a href="https://kubernetes.io/docs/concepts/configuration/manage-compute-resources-container/" rel="noreferrer">resource limits</a>   </p>

<p>Let's say, your host has 4 CPUs and you don't want your microk8s cluster to use more then half of it's capacity.</p>

<p>You will need to set below limits based on the number of running pods. For a single pod, it'll be like follows:</p>

<pre><code>resources:
      requests:
        memory: "64Mi"
        cpu: 2
      limits:
        memory: "128Mi"
        cpu: 2
</code></pre>
