Sunday, March 04, 2018

Turning Swap Off on Kubelet Startup

It seems that recent releases of Kubernetes force you to turn off swap in order for kubelet service to start.  This is happening in VM's that i am running via Virt Manager in Ubuntu 16.0.4 with the latest version of kubelet

I have come up with the following fix that allows the kubelet to come up on rebooting the


[Service]
Environment="KUBELET_KUBECONFIG_ARGS=--bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeconfig=/etc/kubernetes/kubelet.conf"
Environment="KUBELET_SYSTEM_PODS_ARGS=--pod-manifest-path=/etc/kubernetes/manifests --allow-privileged=true"
Environment="KUBELET_NETWORK_ARGS=--network-plugin=cni --cni-conf-dir=/etc/cni/net.d --cni-bin-dir=/opt/cni/bin"
Environment="KUBELET_DNS_ARGS=--cluster-dns=10.96.0.10 --cluster-domain=cluster.local"
Environment="KUBELET_AUTHZ_ARGS=--authorization-mode=Webhook --client-ca-file=/etc/kubernetes/pki/ca.crt"
Environment="KUBELET_CADVISOR_ARGS=--cadvisor-port=0"
Environment="KUBELET_CERTIFICATE_ARGS=--rotate-certificates=true --cert-dir=/var/lib/kubelet/pki"
ExecStart=
ExecStart=/usr/bin/kubelet $KUBELET_KUBECONFIG_ARGS $KUBELET_SYSTEM_PODS_ARGS $KUBELET_NETWORK_ARGS $KUBELET_DNS_ARGS $KUBELET_AUTHZ_ARGS $KUBELET_CADVISOR_ARGS $KUBELET_CERTIFICATE_ARGS $KUBELET_EXTRA_ARGS
ExecStartPre=/sbin/swapoff -a


ubuntu@kubernetes1:~$ systemctl status kubelet
● kubelet.service - kubelet: The Kubernetes Node Agent
   Loaded: loaded (/lib/systemd/system/kubelet.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/kubelet.service.d
           └─10-kubeadm.conf
   Active: active (running) since Sun 2018-03-04 10:01:57 EST; 18s ago
     Docs: http://kubernetes.io/docs/
  Process: 886 ExecStartPre=/sbin/swapoff -a (code=exited, status=0/SUCCESS)
 Main PID: 957 (kubelet)
    Tasks: 26
   Memory: 119.1M
      CPU: 1.586s
   CGroup: /system.slice/kubelet.service
           ├─ 957 /usr/bin/kubelet --bootstrap-kubeconfig=/etc/kubernetes/bootstrap-kubelet.conf --kubeco
           ├─1489 /opt/cni/bin/calico
           └─1607 /opt/cni/bin/calico

No comments: