I deployed a Kubernetes cluster using kubeadm
.
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
ip-172-31-33-9.us-east-2.compute.internal NotReady <none> 48m v1.22.2
ip-172-31-46-53.us-east-2.compute.internal NotReady control-plane,master 49m v1.22.2
ip-172-31-47-245.us-east-2.compute.internal NotReady <none> 6s v1.22.2
The nodes are NotReady
because I haven't installed a networking plugin. I want to use keep it simple and use kubenet
. The instructions say:
Kubelet must be run with the --network-plugin=kubenet argument to enable the plugin
but I can't figure out how to do that. I have tried adding it to various configuration files, such as /usr/lib/systemd/system/kubelet.service.d/10-kubeadm.conf
and /etc/sysconfig/kubelet
, and restaring kubelet, but none of it works.
How do I use kubenet
with kubeadm
?
You can use the
/etc/default/kubelet
file to override kubelet arguments. As can be found in the10-kubeadm.conf
file:I'll show you how it works.
First, I set up the Kubernetes control plane:
After successful initialization, we can check the value of the
--network-plugin
argument that kubelet is currently using and the status of thecoredns
Pods:From the above output, we can see that
--network-plugin=cni
andcoredns
Pods are in thePending
state.Let's create the
/etc/default/kubelet
file and write the kubelet arguments there:NOTE: You may need to customize the
--pod-cidr
and--pod-infra-container-image
to suit your needs.Then we need to reload systemd manager configuration and restart
kubelet
:Finally, we can check if it works as expected:
You can follow these steps for all of your nodes.
Additionally, please remember that (more information can be found in the kubenet documentation):
kubeadm
gives the possibility to use a--config
yaml file that is documented here. In this file you can use the cli parameters from kubelet as extra args like--network-plugin=kubelet
asnetwork-plugin: kubelet
: