blob: dd5d372040f05621f74e46946053c9a27740cb58 [file] [log] [blame]
David K. Bainbridge12463052018-01-19 09:26:09 -08001# Copyright 2017 the original author or authors.
Richard Jankowskia1867962017-06-20 13:35:31 -04002#
David K. Bainbridge12463052018-01-19 09:26:09 -08003# 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.
14
Richard Jankowskicb33c472017-08-24 14:21:59 -040015# This stackfile deploys a Consul cluster to a docker swarm.
16#
17# The Consul cluster depends on:
18# - voltha_net (overlay network)
19#
20# To deploy the cluster, issue the command:
Richard Jankowskia1867962017-06-20 13:35:31 -040021#
22# docker stack deploy -c docker-compose-consul-cluster.yml consul
23#
24# This command will create overlay network 'consul_net'.
Richard Jankowskicb33c472017-08-24 14:21:59 -040025
Richard Jankowski63ce1b42017-08-08 11:31:51 -040026version: "3"
27services:
Richard Jankowskia1867962017-06-20 13:35:31 -040028
Jonathan Hartd67db4a2018-02-12 17:15:35 -080029 vconsul:
David K. Bainbridge12463052018-01-19 09:26:09 -080030 image: "${REGISTRY}consul:${CONSUL_TAG:-0.9.2}"
David K. Bainbridge4e920b72017-10-12 07:49:14 -070031 logging:
32 driver: "json-file"
33 options:
34 max-size: "10m"
35 max-file: 3
Richard Jankowskia1867962017-06-20 13:35:31 -040036
37 # Deploy to all docker manager nodes
38 deploy:
Richard Jankowskicb33c472017-08-24 14:21:59 -040039 mode: global
Richard Jankowskia1867962017-06-20 13:35:31 -040040 placement:
41 constraints:
42 - node.role == manager
43 restart_policy:
44 condition: on-failure
Richard Jankowskia1867962017-06-20 13:35:31 -040045 entrypoint:
46 - consul
47 - agent
48 - -server
David K. Bainbridge12463052018-01-19 09:26:09 -080049 - -bootstrap-expect=${SWARM_MANAGER_COUNT:-3}
Richard Jankowskia1867962017-06-20 13:35:31 -040050 - -config-dir=/consul/config
51 - -data-dir=/consul/data # mandatory property
Richard Jankowskia1867962017-06-20 13:35:31 -040052 - -client=0.0.0.0
David K. Bainbridge12463052018-01-19 09:26:09 -080053 - -advertise={{ GetAllInterfaces | include "network" "172.29.20.0/29" | sort "size,address" | attr "address" }}
Richard Jankowskia1867962017-06-20 13:35:31 -040054 - -ui
Richard Jankowskicb33c472017-08-24 14:21:59 -040055 - -raft-protocol=3
56 - -rejoin
Richard Jankowski63ce1b42017-08-08 11:31:51 -040057 - -retry-join=172.29.20.2
58 - -retry-join=172.29.20.3
59 - -retry-join=172.29.20.4
60 - -retry-join=172.29.20.5
61 - -retry-join=172.29.20.6
62 - -retry-join=172.29.20.7
Richard Jankowskia1867962017-06-20 13:35:31 -040063 networks:
64 - net
65 - voltha-net
66 ports:
67 - "8300:8300"
68 - "8400:8400"
69 - "8500:8500"
70 - "8600:8600/udp"
Richard Jankowskicb33c472017-08-24 14:21:59 -040071 volumes:
David K. Bainbridge12463052018-01-19 09:26:09 -080072 - ${CONSUL_ROOT:-/cord/incubator/voltha/consul}/data:/consul/data
73 - ${CONSUL_ROOT:-/cord/incubator/voltha/consul}/config:/consul/config
Richard Jankowskia1867962017-06-20 13:35:31 -040074
75networks:
76 net:
77 driver: overlay
schowdhuryd9084962017-06-21 14:51:49 -070078 driver_opts:
79 encrypted: "true"
Richard Jankowskia1867962017-06-20 13:35:31 -040080 ipam:
81 driver: default
82 config:
Richard Jankowski63ce1b42017-08-08 11:31:51 -040083 - subnet: 172.29.20.0/29
Richard Jankowskia1867962017-06-20 13:35:31 -040084 voltha-net:
85 external:
86 name: voltha_net