elastic / stack-docker

Project no longer maintained.
Apache License 2.0
1.18k stars 448 forks source link

Swarm Support #64

Closed sauravnz closed 5 years ago

sauravnz commented 5 years ago

Hello Admins,

Can we also add docker swarm support, I am able to configure and run elastic stack 6.5.0 on a swarm cluster. I would like to contribute but not sure how to add that in this current structure.

fxdgear commented 5 years ago

@sauravdevops thanks for the issue.

I'd love to add swarm support for this. The intention on the way the rewrite of the stack-docker was to go down the avenue of being "swarm-able".

Though there's a significant amount of work required to make this "easy to start" for demo purposes/getting started with the Elastic Stack and being hardened and ready for use in docker swarm.

I havn't given up on this goal, though at this point in time I'm unsure the best way to tackle both of these solutions in one project... without making it significantly complex.

sauravnz commented 5 years ago

Thankyou @fxdgear

I know there are a lot of people who are trying out elastic on docker (swarm/kubernetes) I really found it to be very quick and reliable on docker swarm. Keeping in line with the structure of this repo, which was very helpful to built my elastic stack on swarm, many thanks for that. In future if there is a project for swarm support, I would surely like to chip in.

For now I am posting the swarm config for a basic setup (without ssl) for anyone wanting to try it out on swarm.

version: '3.3'
services:
  elasticsearch:
    image: 'docker.elastic.co/elasticsearch/elasticsearch:6.5.3'
    deploy:
      restart_policy:
        condition: any
      mode: global
    environment:
      network.host: _eth0:ipv4_
      discovery.type: zen
      discovery.zen.ping.unicast.hosts: tasks.elasticsearch
      cluster.name: elasticdemo
    networks:
      - elastinet
    volumes:
      - esdata:/usr/share/elasticsearch/data
    healthcheck:
      test: curl -s http://elasticsearch:9300 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
      interval: 30s
      timeout: 10s
      retries: 5

  kibana:
    image: 'docker.elastic.co/kibana/kibana:6.5.3'
    ports:
      - "80:5601"
    environment: 
      elasticsearch.url: "http://elasticsearch:9200"
      server.ssl.enabled: "false"
      xpack.monitoring.ui.container.elasticsearch.enabled: "true"
      xpack.monitoring.collection.enabled: "true"
    deploy:
      restart_policy:
        condition: any
      mode: global
    networks: 
      - elastinet
    depends_on: ['elasticsearch']
    healthcheck:
      test: curl -s http://localhost:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
      interval: 30s
      timeout: 10s
      retries: 5

  apm-server:
    image: 'docker.elastic.co/apm/apm-server:6.5.3'
    command: "--strict.perms=false -e"
    ports:
      - "8200:8200"
    environment: 
      apm-server.frontend.enabled: "true"
      output.elasticsearch.hosts: "elasticsearch:9200"
      output.elasticsearch.protocol: "http"
      setup.kibana.host: "http://kibana:5601"
      setup.kibana.protocol: "http"
      setup.kibana.ssl.enabled: "false"
    deploy:
      restart_policy:
        condition: any
      mode: global
    networks: 
      - elastinet
    depends_on: ['elasticsearch']
    healthcheck:
      test: curl -s http://localhost:8200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
      interval: 30s
      timeout: 10s
      retries: 5

  logstash:
    image: 'docker.elastic.co/logstash/logstash:6.5.3'
    ports:
      - "5044:5044"
    environment:
      xpack.monitoring.elasticsearch.url: "http://elasticsearch:9200"
    configs:
      - source: logstash.conf
        target: /usr/share/logstash/pipeline/logstash.conf
    deploy:
      restart_policy:
        condition: any
      mode: global
    networks:
      - elastinet
    depends_on: ['elasticsearch']
    healthcheck:
      test: bin/logstash -t
      interval: 60s
      timeout: 50s
      retries: 5

  metricbeat:
    image: 'docker.elastic.co/beats/metricbeat:6.5.3'
    configs:
      - source: metricbeat.yml
        target: /usr/share/metricbeat/metricbeat.yml
    deploy:
      restart_policy:
        condition: any
      mode: global
    networks: 
      - elastinet
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    depends_on: ['elasticsearch']
    healthcheck:
      test: metricbeat test config
      interval: 30s
      timeout: 15s
      retries: 5

networks:
  elastinet:
volumes:
  esdata:
configs:
  metricbeat.yml:
    file: config/metricbeat/metricbeat.yml
  logstash.conf:
    file: config/logstash/pipeline/logstash.conf