microk8s
microk8s copied to clipboard
Microk8s can't get swap to enable
Summary
Thanks for checking. I already enabled swap on my os. To enable swap on the kubernetes node, I followed the comment in issue #3100, however I failed to enable swap. I know this by deploying a pod having memory usage close to even greater than the physical memory on my node, but the swap file on that node wasn't used and the deployment stuck in ContainerCreating state until the node crashes.
What Should Happen Instead?
The swap file should be used and pod should be deployed.
Reproduction Steps
I deployed microk8s on two bare-metal servers. One of them is raspberry pi 4 and is where i want to configure swap. I try to deploy a transformer model onto the raspberry pi.
/var/snap/microk8s/current/args/kubelet file:
--config ${SNAP_DATA}/args/kubelet.conf
--resolv-conf=/etc/resolv.conf
--kubeconfig=${SNAP_DATA}/credentials/kubelet.config
--cert-dir=${SNAP_DATA}/certs
--client-ca-file=${SNAP_DATA}/certs/ca.crt
--anonymous-auth=false
--root-dir=${SNAP_COMMON}/var/lib/kubelet
--fail-swap-on=false
--eviction-hard="memory.available<100Mi,nodefs.available<1Gi,imagefs.available<1Gi"
--container-runtime-endpoint=${SNAP_COMMON}/run/containerd.sock
--containerd=${SNAP_COMMON}/run/containerd.sock
--node-labels="microk8s.io/cluster=true,node.kubernetes.io/microk8s-controlplane=microk8s-controlplane"
--authentication-token-webhook=true
--read-only-port=0
--tls-cipher-suites=TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256,TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384,TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305,TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_256_GCM_SHA384,TLS_RSA_WITH_AES_128_GCM_SHA256
--serialize-image-pulls=false
--cluster-domain=cluster.local
--cluster-dns=10.152.183.10
/var/snap/microk8s/current/args/kubelet.conf:
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
memorySwap:
swapBehavior: UnlimitedSwap
then I restart microk8s:
sudo snap restart microk8s
Introspection Report
Hi @ming-afk this does not seem related to MicroK8s. MicroK8s does not enable swap.
The error that causes kubelet to fail is:
Mar 04 00:47:41 raspberrypi microk8s.daemon-kubelite[2143435]: Error: failed to validate kubelet configuration, error: invalid configuration: memorySwap.swapBehavior cannot be set when NodeSwap feature flag is disabled, path: &TypeMeta{Kind:,APIVersion:,}
Mar 04 00:47:41 raspberrypi microk8s.daemon-kubelite[2143435]: F0304 00:47:41.442516 2143435 daemon.go:57] Kubelet exited failed to validate kubelet configuration, error: invalid configuration: memorySwap.swapBehavior cannot be set when NodeSwap feature flag is disabled, path: &TypeMeta{Kind:,APIVersion:,}
There is also this error coming from the kernel:
[97551.663662] systemd-fstab-generator[1924672]: Failed to create unit file /run/systemd/generator/swapfile.swap, as it already exists. Duplicate entry in /etc/fstab?
Thank you for replying! Later we worked our way around this issue. But thanks anyways
Facing similar issue.
@ming-afk Might I ask how you fixed this?