Daemonset to update a file in worker node

Hi Team,
Whenever I add a new node(Windows) to cluster, it always come up with default values in C:\k\cni\config\cni.conf. My requirement is to have a custom value in cni.conf. Is this be achievable by using daemonset ? if any one have tried this before, could you please share the yaml file for this.

Hi @aneeshks1982

It depends. Ideally you will build the base image from which the nodes are provisioned with the correct values burned in. How you do that depends on where your cluster is hosted (AWS, Azure, VMware etc) as to how you prepare your node images.
I’m not sure that using something inside Kubernetes to provision something that Kubernetes relies on is a good idea. It may be that the pods won’t even come up before the cni config is correct.

Hi Alistair,
Thanks much for the response. As you said, ideally these settings should be part of the base OS image. Unfortunately this was not configured when we built the base image. We are using GKE on-prem(Kubernetes running on VMWare). So, now we are looking for a work around instead recreating the node pool and changing the base OS image.

It is very mucky and may not even work, but the only solution I can think of is to create enough HostPath persistent volumes to cover the maximum number of nodes you expect to have (allowing for cluster scaling), with the host path pointing to the C:\k\cni\config directory.

The daemonset pod would then have a Persistent Volume Claim which would claim the PV on the host on which it is running.

The pod would then need to write the entire content of the directory then go into an infinite sleep so it does not exit - else the volume content will be deleted. This also assumes that the same content is required for all nodes, else you’ll need some funky logic that can read the node data (labels, annotations) to determine what to write.
Create a config map containing the files to copy, and mount that as a volume in the pod, then the pod only needs to copy those files from the config map mount point to the PVC mount point.

Still the best solution is to have the base image rebuilt, because it’s clearly not fit for purpose as it is.

1 Like

Thanks a lot for this suggestion. I’ll definitely try this.