Is there a way to apply different configmap for each pod generated by damonset?

2/18/2020

I am using filebeat as a daemonset and I would like each generated pod to export to a single port for the logstash.

Is there an approach to be used for this?

-- WillianSteiangel
filebeat
kubernetes
logstash

2 Answers

2/18/2020

As you can read here:

A DaemonSet ensures that all (or some) Nodes run a copy of a Pod.

...a copy of Pod based on a single template and this is the reason why you cannot specify different ConfigMaps to be used by different Pods managed by DaemonSet Controller.

As an alternative you can configure many different DaemonSets where each one will be responsible for running copy of a Pod specified in the template only on specific node.

Another alternative is using static pods:

It is possible to create Pods by writing a file to a certain directory watched by Kubelet. These are called static pods. Unlike DaemonSet, static Pods cannot be managed with kubectl or other Kubernetes API clients. Static Pods do not depend on the apiserver, making them useful in cluster bootstrapping cases. Also, static Pods may be deprecated in the future.

The whole procedure of creation a static Pod is described here.

I hope it helps.

-- mario
Source: StackOverflow

2/18/2020

No. You cannot provide different configmap to the pods of same daemonset or deployment. If you want each of your pods of daemonset to have different configurations then you can mount some local-volume (using hostpath) so that all the pods will take configuration from that path and that can be different on each node. Or you need to deploy different daemonsets with different configmaps and select different nodes for each of them.

-- anmol agrawal
Source: StackOverflow