Microk8s: Handle Disk Pressure by configuring snap to use external disk

Created on 3 Mar 2020  路  3Comments  路  Source: ubuntu/microk8s

I am unable to figure out a way to install microk8s with snap in a way to use external disk for storing the snap data for microk8s. I am running microk8s on system with limited disk space but a huge SSD connected to it. Microk8s is filling up the /var/snap/microk8s directory when pulling docker images and the pod is running into disk pressure.

Is there a way to configure my microk8s installation to use external disk instead?

Most helpful comment

In MicroK8s containerd creates containers under /var/snap/microk8s/common/ you may be able to either set this path to another location in /var/snap/microk8s/current/args/containerd (${SNAP_COMMON} refers to /var/snap/microk8s/common/) or bind mount [1] another directory over.

[1] https://unix.stackexchange.com/questions/198590/what-is-a-bind-mount

All 3 comments

In MicroK8s containerd creates containers under /var/snap/microk8s/common/ you may be able to either set this path to another location in /var/snap/microk8s/current/args/containerd (${SNAP_COMMON} refers to /var/snap/microk8s/common/) or bind mount [1] another directory over.

[1] https://unix.stackexchange.com/questions/198590/what-is-a-bind-mount

The bind mount worked. Had to restart the snap.

microk8s now seems to fail to mount NFS persistent volumes into pods after I created a rbind mount /var/snap/microk8s/common/ to an external disk. I get the error:

Mounting command: systemd-run
Mounting arguments: --description=Kubernetes transient mount for /var/snap/microk8s/common/var/lib/kubelet/pods/266aa9d7-0f04-46fa-b139-9b8fd183e4b1/volumes/kubernetes.io~nfs/nfs-nas --scope -- mount -t nfs 192.168.32.5:/media/NewVolume/STC_NFS_SHARE/stclogs /var/snap/microk8s/common/var/lib/kubelet/pods/266aa9d7-0f04-46fa-b139-9b8fd183e4b1/volumes/kubernetes.io~nfs/nfs-nas
Output: Running scope as unit: run-r4d27282f874d41ec8ead328fe836b5a5.scope
mount: /var/snap/microk8s/common/var/lib/kubelet/pods/266aa9d7-0f04-46fa-b139-9b8fd183e4b1/volumes/kubernetes.io~nfs/nfs-nas: bad option; for several filesystems (e.g. nfs, cifs) you might need a /sbin/mount.<type> helper program.
  Warning  FailedMount  13s  kubelet, 192.168.32.124  MountVolume.SetUp failed for volume "nfs-nas-data" : mount failed: exit status 32

I have nfs common installed and (as root) mounting the said NFS volume works on the node.

Was this page helpful?
0 / 5 - 0 ratings