David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 1 | # Copyright 2017 the original author or authors. |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 2 | # |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 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. |
| 14 | |
Richard Jankowski | cb33c47 | 2017-08-24 14:21:59 -0400 | [diff] [blame] | 15 | # 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 Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 21 | # |
| 22 | # docker stack deploy -c docker-compose-consul-cluster.yml consul |
| 23 | # |
| 24 | # This command will create overlay network 'consul_net'. |
Richard Jankowski | cb33c47 | 2017-08-24 14:21:59 -0400 | [diff] [blame] | 25 | |
Richard Jankowski | 63ce1b4 | 2017-08-08 11:31:51 -0400 | [diff] [blame] | 26 | version: "3" |
| 27 | services: |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 28 | |
| 29 | consul: |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 30 | image: "${REGISTRY}consul:${CONSUL_TAG:-0.9.2}" |
David K. Bainbridge | 4e920b7 | 2017-10-12 07:49:14 -0700 | [diff] [blame] | 31 | logging: |
| 32 | driver: "json-file" |
| 33 | options: |
| 34 | max-size: "10m" |
| 35 | max-file: 3 |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 36 | |
| 37 | # Deploy to all docker manager nodes |
| 38 | deploy: |
Richard Jankowski | cb33c47 | 2017-08-24 14:21:59 -0400 | [diff] [blame] | 39 | mode: global |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 40 | placement: |
| 41 | constraints: |
| 42 | - node.role == manager |
| 43 | restart_policy: |
| 44 | condition: on-failure |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 45 | entrypoint: |
| 46 | - consul |
| 47 | - agent |
| 48 | - -server |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 49 | - -bootstrap-expect=${SWARM_MANAGER_COUNT:-3} |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 50 | - -config-dir=/consul/config |
| 51 | - -data-dir=/consul/data # mandatory property |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 52 | - -client=0.0.0.0 |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 53 | - -advertise={{ GetAllInterfaces | include "network" "172.29.20.0/29" | sort "size,address" | attr "address" }} |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 54 | - -ui |
Richard Jankowski | cb33c47 | 2017-08-24 14:21:59 -0400 | [diff] [blame] | 55 | - -raft-protocol=3 |
| 56 | - -rejoin |
Richard Jankowski | 63ce1b4 | 2017-08-08 11:31:51 -0400 | [diff] [blame] | 57 | - -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 Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 63 | networks: |
| 64 | - net |
| 65 | - voltha-net |
| 66 | ports: |
| 67 | - "8300:8300" |
| 68 | - "8400:8400" |
| 69 | - "8500:8500" |
| 70 | - "8600:8600/udp" |
Richard Jankowski | cb33c47 | 2017-08-24 14:21:59 -0400 | [diff] [blame] | 71 | volumes: |
David K. Bainbridge | 1246305 | 2018-01-19 09:26:09 -0800 | [diff] [blame] | 72 | - ${CONSUL_ROOT:-/cord/incubator/voltha/consul}/data:/consul/data |
| 73 | - ${CONSUL_ROOT:-/cord/incubator/voltha/consul}/config:/consul/config |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 74 | |
| 75 | networks: |
| 76 | net: |
| 77 | driver: overlay |
schowdhury | d908496 | 2017-06-21 14:51:49 -0700 | [diff] [blame] | 78 | driver_opts: |
| 79 | encrypted: "true" |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 80 | ipam: |
| 81 | driver: default |
| 82 | config: |
Richard Jankowski | 63ce1b4 | 2017-08-08 11:31:51 -0400 | [diff] [blame] | 83 | - subnet: 172.29.20.0/29 |
Richard Jankowski | a186796 | 2017-06-20 13:35:31 -0400 | [diff] [blame] | 84 | voltha-net: |
| 85 | external: |
| 86 | name: voltha_net |