Deleting a Network drivers in Kubernetes


In a Kubernetes cluster network add-ons has to be installed/deployed so that the hosts/pods in a cluster can communicate with each other.

This doc shall talk about deleting a network driver that is not successfully deployed or goes in a CrashLoopBackOff. And how it is different than deleting a regular pod.

Lets consider a regular pod case – To delete a pod, we have to delete the deployment first and then the pod gets deleted. If you don’t do it so then even after deletion of a pod a new pod immediately gets spinned within a fraction of seconds.

(#kubectl get deployment –namespace=kube-system)

But in case of Network drivers – You won’t find any related deployment for that network add-on service. And hence despite of deleting pod it gets spinned up again.

Following are the network pods that we want to delete –

[[email protected] ~]# kubectl get pods –namespace=kube-system

And the answer to this lies here – “Network drivers in Kubernetes run as a daemonSet”.

What is a DaemonSet?

DaemonSet make sure that all or some kubernetes Nodes run a copy of a Pod. When a new node is added to the cluster, a Pod is added to it to match the rest of the nodes and when a node is removed from the cluster, the Pod is garbage collected. Deleting a DaemonSet will clean up the Pods it created. In simple terms, this is what a DaemonSet is. As the name implies, it allow us to run a daemon on every node.

[[email protected] ~]# kubectl get ds -n kube-system

To delete a network driver You have to delete a daemonSet first.

[[email protected] ~]# kubectl delete daemonset kube-flannel-ds-amd64 kube-flannel-ds-arm kube-flannel-ds-arm64 –namespace=kube-system

[[email protected] ~]# kubectl get pods –namespace=kube-system

You can go ahead and spin a new pod for network driver using ‘kubectl apply’ to bring back the network connectivity in a Kubernetes cluster.

Notify of
Inline Feedbacks
View all comments