|
1 |
| -version: "2.2" |
2 |
| -services: |
3 |
| - es-node01: |
4 |
| - image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
5 |
| - container_name: es-node01 |
6 |
| - environment: |
7 |
| - - node.name=es-node01 |
8 |
| - - cluster.name=es-docker-cluster |
9 |
| - - discovery.seed_hosts=es-node02,es-node03 |
10 |
| - - cluster.initial_master_nodes=es-node01,es-node02,es-node03 |
11 |
| - - bootstrap.memory_lock=true |
12 |
| - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" |
13 |
| - ulimits: |
14 |
| - memlock: |
15 |
| - soft: -1 |
16 |
| - hard: -1 |
17 |
| - volumes: |
18 |
| - - data01:/usr/share/elasticsearch/data |
19 |
| - ports: |
20 |
| - - 9200:9200 |
21 |
| - networks: |
22 |
| - - elastic |
23 |
| - |
24 |
| - es-node02: |
25 |
| - image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
26 |
| - container_name: es-node02 |
27 |
| - environment: |
28 |
| - - node.name=es-node02 |
29 |
| - - cluster.name=es-docker-cluster |
30 |
| - - discovery.seed_hosts=es-node01,es-node03 |
31 |
| - - cluster.initial_master_nodes=es-node01,es-node02,es-node03 |
32 |
| - - bootstrap.memory_lock=true |
33 |
| - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" |
34 |
| - ulimits: |
35 |
| - memlock: |
36 |
| - soft: -1 |
37 |
| - hard: -1 |
38 |
| - volumes: |
39 |
| - - data02:/usr/share/elasticsearch/data |
40 |
| - networks: |
41 |
| - - elastic |
42 |
| - |
43 |
| - es-node03: |
44 |
| - image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
45 |
| - container_name: es-node03 |
46 |
| - environment: |
47 |
| - - node.name=es-node03 |
48 |
| - - cluster.name=es-docker-cluster |
49 |
| - - discovery.seed_hosts=es-node01,es-node02 |
50 |
| - - cluster.initial_master_nodes=es-node01,es-node02,es-node03 |
51 |
| - - bootstrap.memory_lock=true |
52 |
| - - "ES_JAVA_OPTS=-Xms512m -Xmx512m" |
53 |
| - ulimits: |
54 |
| - memlock: |
55 |
| - soft: -1 |
56 |
| - hard: -1 |
57 |
| - volumes: |
58 |
| - - data03:/usr/share/elasticsearch/data |
59 |
| - networks: |
60 |
| - - elastic |
61 |
| - |
62 |
| - kib01: |
63 |
| - image: docker.elastic.co/kibana/kibana:{version} |
64 |
| - container_name: kib01 |
65 |
| - ports: |
66 |
| - - 5601:5601 |
67 |
| - environment: |
68 |
| - ELASTICSEARCH_URL: http://es-node01:9200 |
69 |
| - ELASTICSEARCH_HOSTS: '["http://es-node01:9200","http://es-node02:9200","http://es-node03:9200"]' |
70 |
| - networks: |
71 |
| - - elastic |
72 |
| - |
73 |
| -volumes: |
74 |
| - data01: |
75 |
| - driver: local |
76 |
| - data02: |
77 |
| - driver: local |
78 |
| - data03: |
79 |
| - driver: local |
80 |
| - |
81 |
| -networks: |
82 |
| - elastic: |
83 |
| - driver: bridge |
| 1 | +version: "2.2" |
| 2 | + |
| 3 | +services: |
| 4 | + setup: |
| 5 | + image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
| 6 | + volumes: |
| 7 | + - certs:/usr/share/elasticsearch/config/certs |
| 8 | + user: "0" |
| 9 | + command: > |
| 10 | + bash -c ' |
| 11 | + if [ x${ELASTIC_PASSWORD} == x ]; then |
| 12 | + echo "Set the ELASTIC_PASSWORD environment variable in the .env file"; |
| 13 | + exit 1; |
| 14 | + elif [ x${KIBANA_PASSWORD} == x ]; then |
| 15 | + echo "Set the KIBANA_PASSWORD environment variable in the .env file"; |
| 16 | + exit 1; |
| 17 | + fi; |
| 18 | + if [ ! -f certs/ca.zip ]; then |
| 19 | + echo "Creating CA"; |
| 20 | + bin/elasticsearch-certutil ca --silent --pem -out config/certs/ca.zip; |
| 21 | + unzip config/certs/ca.zip -d config/certs; |
| 22 | + fi; |
| 23 | + if [ ! -f certs/certs.zip ]; then |
| 24 | + echo "Creating certs"; |
| 25 | + echo -ne \ |
| 26 | + "instances:\n"\ |
| 27 | + " - name: es01\n"\ |
| 28 | + " dns:\n"\ |
| 29 | + " - es01\n"\ |
| 30 | + " - localhost\n"\ |
| 31 | + " ip:\n"\ |
| 32 | + " - 127.0.0.1\n"\ |
| 33 | + " - name: es02\n"\ |
| 34 | + " dns:\n"\ |
| 35 | + " - es02\n"\ |
| 36 | + " - localhost\n"\ |
| 37 | + " ip:\n"\ |
| 38 | + " - 127.0.0.1\n"\ |
| 39 | + " - name: es03\n"\ |
| 40 | + " dns:\n"\ |
| 41 | + " - es03\n"\ |
| 42 | + " - localhost\n"\ |
| 43 | + " ip:\n"\ |
| 44 | + " - 127.0.0.1\n"\ |
| 45 | + > config/certs/instances.yml; |
| 46 | + bin/elasticsearch-certutil cert --silent --pem -out config/certs/certs.zip --in config/certs/instances.yml --ca-cert config/certs/ca/ca.crt --ca-key config/certs/ca/ca.key; |
| 47 | + unzip config/certs/certs.zip -d config/certs; |
| 48 | + fi; |
| 49 | + echo "Setting file permissions" |
| 50 | + chown -R root:root config/certs; |
| 51 | + find . -type d -exec chmod 750 \{\} \;; |
| 52 | + find . -type f -exec chmod 640 \{\} \;; |
| 53 | + echo "Waiting for Elasticsearch availability"; |
| 54 | + until curl -s --cacert config/certs/ca/ca.crt https://es01:9200 | grep -q "missing authentication credentials"; do sleep 30; done; |
| 55 | + echo "Setting kibana_system password"; |
| 56 | + until curl -s -X POST --cacert config/certs/ca/ca.crt -u elastic:${ELASTIC_PASSWORD} -H "Content-Type: application/json" https://es01:9200/_security/user/kibana_system/_password -d "{\"password\":\"${KIBANA_PASSWORD}\"}" | grep -q "^{}"; do sleep 10; done; |
| 57 | + echo "All done!"; |
| 58 | + ' |
| 59 | + healthcheck: |
| 60 | + test: ["CMD-SHELL", "[ -f config/certs/es01/es01.crt ]"] |
| 61 | + interval: 1s |
| 62 | + timeout: 5s |
| 63 | + retries: 120 |
| 64 | + |
| 65 | + es01: |
| 66 | + depends_on: |
| 67 | + setup: |
| 68 | + condition: service_healthy |
| 69 | + image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
| 70 | + volumes: |
| 71 | + - certs:/usr/share/elasticsearch/config/certs |
| 72 | + - esdata01:/usr/share/elasticsearch/data |
| 73 | + ports: |
| 74 | + - ${ES_PORT}:9200 |
| 75 | + environment: |
| 76 | + - node.name=es01 |
| 77 | + - cluster.name=${CLUSTER_NAME} |
| 78 | + - cluster.initial_master_nodes=es01,es02,es03 |
| 79 | + - discovery.seed_hosts=es02,es03 |
| 80 | + - ELASTIC_PASSWORD=${ELASTIC_PASSWORD} |
| 81 | + - bootstrap.memory_lock=true |
| 82 | + - xpack.security.enabled=true |
| 83 | + - xpack.security.http.ssl.enabled=true |
| 84 | + - xpack.security.http.ssl.key=certs/es01/es01.key |
| 85 | + - xpack.security.http.ssl.certificate=certs/es01/es01.crt |
| 86 | + - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt |
| 87 | + - xpack.security.http.ssl.verification_mode=certificate |
| 88 | + - xpack.security.transport.ssl.enabled=true |
| 89 | + - xpack.security.transport.ssl.key=certs/es01/es01.key |
| 90 | + - xpack.security.transport.ssl.certificate=certs/es01/es01.crt |
| 91 | + - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt |
| 92 | + - xpack.security.transport.ssl.verification_mode=certificate |
| 93 | + - xpack.license.self_generated.type=${LICENSE} |
| 94 | + mem_limit: ${MEM_LIMIT} |
| 95 | + ulimits: |
| 96 | + memlock: |
| 97 | + soft: -1 |
| 98 | + hard: -1 |
| 99 | + healthcheck: |
| 100 | + test: |
| 101 | + [ |
| 102 | + "CMD-SHELL", |
| 103 | + "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'", |
| 104 | + ] |
| 105 | + interval: 10s |
| 106 | + timeout: 10s |
| 107 | + retries: 120 |
| 108 | + |
| 109 | + es02: |
| 110 | + depends_on: |
| 111 | + - es01 |
| 112 | + image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
| 113 | + volumes: |
| 114 | + - certs:/usr/share/elasticsearch/config/certs |
| 115 | + - esdata02:/usr/share/elasticsearch/data |
| 116 | + environment: |
| 117 | + - node.name=es02 |
| 118 | + - cluster.name=${CLUSTER_NAME} |
| 119 | + - cluster.initial_master_nodes=es01,es02,es03 |
| 120 | + - discovery.seed_hosts=es01,es03 |
| 121 | + - bootstrap.memory_lock=true |
| 122 | + - xpack.security.enabled=true |
| 123 | + - xpack.security.http.ssl.enabled=true |
| 124 | + - xpack.security.http.ssl.key=certs/es02/es02.key |
| 125 | + - xpack.security.http.ssl.certificate=certs/es02/es02.crt |
| 126 | + - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt |
| 127 | + - xpack.security.http.ssl.verification_mode=certificate |
| 128 | + - xpack.security.transport.ssl.enabled=true |
| 129 | + - xpack.security.transport.ssl.key=certs/es02/es02.key |
| 130 | + - xpack.security.transport.ssl.certificate=certs/es02/es02.crt |
| 131 | + - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt |
| 132 | + - xpack.security.transport.ssl.verification_mode=certificate |
| 133 | + - xpack.license.self_generated.type=${LICENSE} |
| 134 | + mem_limit: ${MEM_LIMIT} |
| 135 | + ulimits: |
| 136 | + memlock: |
| 137 | + soft: -1 |
| 138 | + hard: -1 |
| 139 | + healthcheck: |
| 140 | + test: |
| 141 | + [ |
| 142 | + "CMD-SHELL", |
| 143 | + "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'", |
| 144 | + ] |
| 145 | + interval: 10s |
| 146 | + timeout: 10s |
| 147 | + retries: 120 |
| 148 | + |
| 149 | + es03: |
| 150 | + depends_on: |
| 151 | + - es02 |
| 152 | + image: docker.elastic.co/elasticsearch/elasticsearch:{version} |
| 153 | + volumes: |
| 154 | + - certs:/usr/share/elasticsearch/config/certs |
| 155 | + - esdata03:/usr/share/elasticsearch/data |
| 156 | + environment: |
| 157 | + - node.name=es03 |
| 158 | + - cluster.name=${CLUSTER_NAME} |
| 159 | + - cluster.initial_master_nodes=es01,es02,es03 |
| 160 | + - discovery.seed_hosts=es01,es02 |
| 161 | + - bootstrap.memory_lock=true |
| 162 | + - xpack.security.enabled=true |
| 163 | + - xpack.security.http.ssl.enabled=true |
| 164 | + - xpack.security.http.ssl.key=certs/es03/es03.key |
| 165 | + - xpack.security.http.ssl.certificate=certs/es03/es03.crt |
| 166 | + - xpack.security.http.ssl.certificate_authorities=certs/ca/ca.crt |
| 167 | + - xpack.security.http.ssl.verification_mode=certificate |
| 168 | + - xpack.security.transport.ssl.enabled=true |
| 169 | + - xpack.security.transport.ssl.key=certs/es03/es03.key |
| 170 | + - xpack.security.transport.ssl.certificate=certs/es03/es03.crt |
| 171 | + - xpack.security.transport.ssl.certificate_authorities=certs/ca/ca.crt |
| 172 | + - xpack.security.transport.ssl.verification_mode=certificate |
| 173 | + - xpack.license.self_generated.type=${LICENSE} |
| 174 | + mem_limit: ${MEM_LIMIT} |
| 175 | + ulimits: |
| 176 | + memlock: |
| 177 | + soft: -1 |
| 178 | + hard: -1 |
| 179 | + healthcheck: |
| 180 | + test: |
| 181 | + [ |
| 182 | + "CMD-SHELL", |
| 183 | + "curl -s --cacert config/certs/ca/ca.crt https://localhost:9200 | grep -q 'missing authentication credentials'", |
| 184 | + ] |
| 185 | + interval: 10s |
| 186 | + timeout: 10s |
| 187 | + retries: 120 |
| 188 | + |
| 189 | + kibana: |
| 190 | + depends_on: |
| 191 | + es01: |
| 192 | + condition: service_healthy |
| 193 | + es02: |
| 194 | + condition: service_healthy |
| 195 | + es03: |
| 196 | + condition: service_healthy |
| 197 | + image: docker.elastic.co/kibana/kibana:{version} |
| 198 | + volumes: |
| 199 | + - certs:/usr/share/kibana/config/certs |
| 200 | + - kibanadata:/usr/share/kibana/data |
| 201 | + ports: |
| 202 | + - ${KIBANA_PORT}:5601 |
| 203 | + environment: |
| 204 | + - SERVERNAME=kibana |
| 205 | + - ELASTICSEARCH_HOSTS=https://es01:9200 |
| 206 | + - ELASTICSEARCH_USERNAME=kibana_system |
| 207 | + - ELASTICSEARCH_PASSWORD=${KIBANA_PASSWORD} |
| 208 | + - ELASTICSEARCH_SSL_CERTIFICATEAUTHORITIES=config/certs/ca/ca.crt |
| 209 | + mem_limit: ${MEM_LIMIT} |
| 210 | + healthcheck: |
| 211 | + test: |
| 212 | + [ |
| 213 | + "CMD-SHELL", |
| 214 | + "curl -s -I http://localhost:5601 | grep -q 'HTTP/1.1 302 Found'", |
| 215 | + ] |
| 216 | + interval: 10s |
| 217 | + timeout: 10s |
| 218 | + retries: 120 |
| 219 | + |
| 220 | +volumes: |
| 221 | + certs: |
| 222 | + driver: local |
| 223 | + esdata01: |
| 224 | + driver: local |
| 225 | + esdata02: |
| 226 | + driver: local |
| 227 | + esdata03: |
| 228 | + driver: local |
| 229 | + kibanadata: |
| 230 | + driver: local |
0 commit comments