Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 1 | ########################################################################################### |
| 2 | # |
| 3 | # Deploy a Zookeeper/Kafka messaging cluster |
| 4 | # |
| 5 | # It is meant to be deployed within a swarm cluster using the docker stack functionality. |
| 6 | # This file will deploy 3 zookeeper containers and 1 kafka container per swarm node. |
| 7 | # |
| 8 | # This file will also create an overlay network which can be referred by other services. |
| 9 | # |
| 10 | # Example: |
| 11 | # |
| 12 | # docker stack deploy -c docker-compose-kafka-ha-cluster.yml kafka |
| 13 | # |
| 14 | ########################################################################################### |
| 15 | |
| 16 | version: '3' |
| 17 | services: |
| 18 | zk1: |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 19 | image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}" |
David K. Bainbridge | 4e920b7 | 2017-10-12 07:49:14 -0700 | [diff] [blame] | 20 | logging: |
| 21 | driver: "json-file" |
| 22 | options: |
| 23 | max-size: "10m" |
| 24 | max-file: 3 |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 25 | networks: |
David K. Bainbridge | 3d5b22d | 2018-01-22 12:57:52 -0800 | [diff] [blame] | 26 | - kafka-net |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 27 | environment: |
| 28 | ZOO_MY_ID: 1 |
| 29 | ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888 |
| 30 | |
| 31 | zk2: |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 32 | image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}" |
David K. Bainbridge | 4e920b7 | 2017-10-12 07:49:14 -0700 | [diff] [blame] | 33 | logging: |
| 34 | driver: "json-file" |
| 35 | options: |
| 36 | max-size: "10m" |
| 37 | max-file: 3 |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 38 | networks: |
David K. Bainbridge | 3d5b22d | 2018-01-22 12:57:52 -0800 | [diff] [blame] | 39 | - kafka-net |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 40 | environment: |
| 41 | ZOO_MY_ID: 2 |
| 42 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk3:2888:3888 |
| 43 | |
| 44 | zk3: |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 45 | image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}" |
David K. Bainbridge | 4e920b7 | 2017-10-12 07:49:14 -0700 | [diff] [blame] | 46 | logging: |
| 47 | driver: "json-file" |
| 48 | options: |
| 49 | max-size: "10m" |
| 50 | max-file: 3 |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 51 | networks: |
David K. Bainbridge | 3d5b22d | 2018-01-22 12:57:52 -0800 | [diff] [blame] | 52 | - kafka-net |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 53 | environment: |
| 54 | ZOO_MY_ID: 3 |
| 55 | ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=0.0.0.0:2888:3888 |
| 56 | |
| 57 | kafka: |
| 58 | deploy: |
| 59 | mode: global |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 60 | image: "${REGISTRY}wurstmeister/kafka:${KAFKA_TAG:-latest}" |
David K. Bainbridge | 4e920b7 | 2017-10-12 07:49:14 -0700 | [diff] [blame] | 61 | logging: |
| 62 | driver: "json-file" |
| 63 | options: |
| 64 | max-size: "10m" |
| 65 | max-file: 3 |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 66 | environment: |
| 67 | KAFKA_ADVERTISED_PORT: 9092 |
| 68 | KAFKA_ZOOKEEPER_CONNECT: zk1:2181,zk2:2181,zk3:2181 |
| 69 | KAFKA_HEAP_OPTS: -Xmx256M -Xms128M |
| 70 | volumes: |
| 71 | - /var/run/docker.sock:/var/run/docker.sock |
| 72 | networks: |
David K. Bainbridge | 3d5b22d | 2018-01-22 12:57:52 -0800 | [diff] [blame] | 73 | - kafka-net |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 74 | - voltha-net |
| 75 | ports: |
| 76 | - 9092:9092 |
| 77 | |
| 78 | networks: |
David K. Bainbridge | 3d5b22d | 2018-01-22 12:57:52 -0800 | [diff] [blame] | 79 | kafka-net: |
| 80 | external: |
| 81 | name: kafka_net |
Stephane Barbarie | 7ba064f | 2017-06-20 10:57:20 -0400 | [diff] [blame] | 82 | |
| 83 | voltha-net: |
| 84 | external: |
| 85 | name: voltha_net |
| 86 | |