有没有办法为 damonset 生成的每个 pod 应用不同的 configmap?

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

我正在使用 filebeat 作为 daemonset,我希望每个生成的 pod 都导出到用于 logstash 的单个端口。

是否有方法可以用于此?

如你所见here:

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

...基于单一模板Pod副本,这就是为什么你不能指定不同ConfigMapsDaemonSet Controller.

管理的不同 Pods 使用

作为替代方案,您可以配置许多不同的 DaemonSets,其中每个 运行 模板 only on specific node 中指定的 Pod 副本。

另一种选择是使用 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.

创建 static Pod 的整个过程已在 here.

中描述

希望对您有所帮助。

没有。您不能为同一守护进程或部署的 pods 提供不同的配置映射。如果您希望每个 pods 的 daemonset 具有不同的配置,那么您可以安装一些本地卷(使用主机路径),以便所有 pods 将从该路径获取配置并且可以不同每个节点。或者你需要部署不同的 daemonsets 与不同的 configmaps 和 select 每个不同的节点。

您可以在每个节点中使用包含配置的 ConfigMap,并将 spec.nodeName 环境暴露给您的 pods。然后你的 pods 可以知道它在哪个节点上 运行 并决定它加载哪个配置。