Is there a deploy mode 'global' in Kubernetes?

3/14/2019

I am used to work with Docker swarm and whenever I wanted to deploy one container replica per node available I would use the 'global' deploy mode, as exemplified in this Docker stack 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:

This would deploy one and only one logstash replica in each node available. I am new to Kubernetes and I was attempting to reproduce this behaviour, is there an equivalent mode? If not, what are my alternatives?

Thank you.

-- João Matos
docker
kubernetes

1 Answer

3/14/2019

DaemonSet is the controller that you wants:

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.

The official doc even mention your needs:

Some typical uses of a DaemonSet are:
[...]
- running a logs collection daemon on every node, such as fluentd or logstash.

-- Eduardo Baitello
Source: StackOverflow