我习惯于使用 Docker swarm,每当我想为每个可用节点部署一个容器副本时,我都会使用“全局”部署模式,如这个 Docker 堆栈 yaml 中所示:
logstash:
image: myregistry:443/mydomain/logstash
deploy:
mode: global
restart_policy:
condition: on-failure
ports:
- "12201:12201/udp"
environment:
LS_JAVA_OPTS: "-Xmx256m -Xms256m"
networks:
mylan:
这将在每个可用节点中部署一个且仅一个 logstash 副本。我是 Kubernetes 的新手,我试图重现这种行为,是否有等效的模式?如果不能,我有什么选择?
谢谢。
请您参考如下方法:
DaemonSet是你想要的 Controller :
A DaemonSet ensures that all (or some) Nodes run a copy of a Pod. As nodes are added to the cluster, Pods are added to them. As nodes are removed from the cluster, those Pods are garbage collected. Deleting a DaemonSet will clean up the Pods it created.
官方文档甚至提到了您的需求:
Some typical uses of a DaemonSet are:
[...]
- running a logs collection daemon on every node, such as fluentd or logstash.