blob: 4cbf02b44a8a4b298b8382e15c2396ef3ca12d95 [file] [log] [blame]
Zack Williams41513bf2018-07-07 20:08:35 -07001# Copyright 2017-present Open Networking Foundation
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040014###########################################################################################
15#
16# Deploy a Zookeeper/Kafka messaging cluster
17#
18# It is meant to be deployed within a swarm cluster using the docker stack functionality.
19# This file will deploy 3 zookeeper containers and 1 kafka container per swarm node.
20#
21# This file will also create an overlay network which can be referred by other services.
22#
23# Example:
24#
25# docker stack deploy -c docker-compose-kafka-ha-cluster.yml kafka
26#
27###########################################################################################
28
29version: '3'
30services:
31 zk1:
David K. Bainbridgebba65ff2018-01-19 09:26:09 -080032 image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}"
David K. Bainbridge4e920b72017-10-12 07:49:14 -070033 logging:
34 driver: "json-file"
35 options:
36 max-size: "10m"
37 max-file: 3
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040038 networks:
David K. Bainbridge737b74f2018-01-22 12:57:52 -080039 - kafka-net
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040040 environment:
41 ZOO_MY_ID: 1
42 ZOO_SERVERS: server.1=0.0.0.0:2888:3888 server.2=zk2:2888:3888 server.3=zk3:2888:3888
43
44 zk2:
David K. Bainbridgebba65ff2018-01-19 09:26:09 -080045 image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}"
David K. Bainbridge4e920b72017-10-12 07:49:14 -070046 logging:
47 driver: "json-file"
48 options:
49 max-size: "10m"
50 max-file: 3
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040051 networks:
David K. Bainbridge737b74f2018-01-22 12:57:52 -080052 - kafka-net
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040053 environment:
54 ZOO_MY_ID: 2
55 ZOO_SERVERS: server.1=zk1:2888:3888 server.2=0.0.0.0:2888:3888 server.3=zk3:2888:3888
56
57 zk3:
David K. Bainbridgebba65ff2018-01-19 09:26:09 -080058 image: "${REGISTRY}wurstmeister/zookeeper:${ZK_TAG:-latest}"
David K. Bainbridge4e920b72017-10-12 07:49:14 -070059 logging:
60 driver: "json-file"
61 options:
62 max-size: "10m"
63 max-file: 3
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040064 networks:
David K. Bainbridge737b74f2018-01-22 12:57:52 -080065 - kafka-net
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040066 environment:
67 ZOO_MY_ID: 3
68 ZOO_SERVERS: server.1=zk1:2888:3888 server.2=zk2:2888:3888 server.3=0.0.0.0:2888:3888
69
70 kafka:
71 deploy:
72 mode: global
David K. Bainbridgebba65ff2018-01-19 09:26:09 -080073 image: "${REGISTRY}wurstmeister/kafka:${KAFKA_TAG:-latest}"
David K. Bainbridge4e920b72017-10-12 07:49:14 -070074 logging:
75 driver: "json-file"
76 options:
77 max-size: "10m"
78 max-file: 3
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040079 environment:
Jonathan Hart0584a1e2018-04-17 08:36:21 -070080 KAFKA_LISTENERS: PLAINTEXT://:9092
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040081 KAFKA_ZOOKEEPER_CONNECT: zk1:2181,zk2:2181,zk3:2181
82 KAFKA_HEAP_OPTS: -Xmx256M -Xms128M
83 volumes:
84 - /var/run/docker.sock:/var/run/docker.sock
85 networks:
David K. Bainbridge737b74f2018-01-22 12:57:52 -080086 - kafka-net
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040087 - voltha-net
88 ports:
89 - 9092:9092
90
91networks:
David K. Bainbridge737b74f2018-01-22 12:57:52 -080092 kafka-net:
93 external:
94 name: kafka_net
Stephane Barbarie7ba064f2017-06-20 10:57:20 -040095
96 voltha-net:
97 external:
98 name: voltha_net