AVarf
AVarf

Reputation: 5149

Configure Microk8s

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.).

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
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: ...

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

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

How can I change the config of Microk8s?

Upvotes: 7

Views: 6445

Answers (3)

Gonen
Gonen

Reputation: 4075

Set RAM/CPU resources for MicroK8s on macOS (over a Multipass VM)

As mentioned by Anton Kuzmin and Chris Snow, on macOS
the cluster is running on a Multipass VM and not directly on the host,
so we should change the setting of Multipass.

  1. While MicroK8s is running, check the current settings of Multipass:
    multipass list
    (should get a line for 'microk8s-vm')
    multipass info microk8s-vm
    ...
  2. Stop MicroK8s:
    microk8s stop
  3. Reconfigure Multipass as needed - for example:
    multipass set local.microk8s-vm.cpus=4
    multipass set local.microk8s-vm.memory=8G
  4. Start MicroK8s again:
    microk8s start
  5. Confirm the settings of Multipass were changed:
    multipass info microk8s-vm
    ...
  6. Check how your cluster is doing

See also here

Upvotes: 0

Chris Snow
Chris Snow

Reputation: 24588

On OS/X ...

First stop multipass

sudo launchctl unload /Library/LaunchDaemons/com.canonical.multipassd.plist

Next edit the config file:

sudo su -
vi /var/root/Library/Application\ Support/multipassd/multipassd-vm-instances.json

Start multipassd again

sudo launchctl load /Library/LaunchDaemons/com.canonical.multipassd.plist

Source: https://github.com/canonical/multipass/issues/1158

Upvotes: 4

A_Suh
A_Suh

Reputation: 3936

You have a wrong understanding of the microk8s concept.

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.

So, in order to keep your cluster resource in borders, you have to manage it with k8s pod/container resource limits

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.

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

resources:
      requests:
        memory: "64Mi"
        cpu: 2
      limits:
        memory: "128Mi"
        cpu: 2

Upvotes: 9

Related Questions