Skip to content

Commit 925bb8e

Browse files
deploymentkingLee Myring
andauthored
Feature/enable tls (#20)
* feat(tls): remove readonlyrest plugin and config * feat(tls): add certs generation docker compose * also rename network so it's not efk_efk * feat(tls): fix health checks * chore: bump version for sarif output --------- Co-authored-by: Lee Myring <[email protected]>
1 parent 638d5f3 commit 925bb8e

22 files changed

+152
-201
lines changed

.github/workflows/rubocop-analysis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,6 @@ jobs:
3030
"
3131
3232
- name: Upload Sarif output
33-
uses: github/codeql-action/upload-sarif@v1
33+
uses: github/codeql-action/upload-sarif@v2
3434
with:
3535
sarif_file: rubocop.sarif

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,4 @@ target
2424
coverage
2525
VERSION
2626
output.log
27-
2827
es-passwords.txt

Rakefile

Lines changed: 36 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,11 @@ task :all_sources do
99
sh 'docker ps -a --format "table {{.ID}}\t{{.Status}}\t{{.Names}}\t{{.Ports}}"'
1010
end
1111

12+
desc 'Generate the certs Docker volume'
13+
task :certs do
14+
sh 'docker-compose -f docker-compose-create-certs.yml run --rm create_certs'
15+
end
16+
1217
desc 'Clean some generated files'
1318
task :clean do
1419
%w[
@@ -23,22 +28,32 @@ task :clean do
2328
].each { |f| FileUtils.rm_rf(Dir.glob(f)) }
2429
end
2530

26-
desc 'Stop the entire EFK stack, any additional sources and the minikube cluster'
31+
32+
desc 'Start the client instances Kibana and ElasticHQ (Elasticsearch cluster must be up and running first)'
33+
task :clients do
34+
trap('SIGINT') do
35+
puts 'Cancelled Kibana launch...'
36+
exit
37+
end
38+
sh './scripts/start-clients.sh'
39+
end
40+
41+
desc 'Kill the entire EFK stack, any additional sources and the minikube cluster'
2742
task :down do
28-
sh './scripts/stop-efk.sh || true'
43+
sh './scripts/down-es-cluster.sh || true'
2944
end
3045

31-
desc 'Start the EFK stack components (including elasticHQ)'
32-
task :efk do
46+
desc 'Start the Elasticsearch cluster (including elasticHQ)'
47+
task :elasticsearch do
3348
trap('SIGINT') do
34-
puts 'Cancelled EFK stack launch...'
49+
puts 'Cancelled Elasticsearch cluster launch...'
3550
exit
3651
end
37-
sh './scripts/start-efk.sh'
52+
sh './scripts/start-es-cluster.sh'
3853
end
3954

4055
desc 'Run ALL the rake tasks: clean test and build'
41-
task everything: %w[down clean style test efk k8s all_sources]
56+
task everything: %w[down clean style test elasticsearch kibana k8s all_sources]
4257

4358
desc 'Start the Kubernetes Minikube components'
4459
task :k8s do
@@ -59,6 +74,15 @@ task :logs do
5974
sh 'docker-compose logs -f'
6075
end
6176

77+
task :passwords do
78+
sh '
79+
docker exec elasticsearch-master /bin/bash \
80+
-c "bin/elasticsearch-setup-passwords auto \
81+
--batch \
82+
--url https://elasticsearch:9200" > es-passwords.txt
83+
'
84+
end
85+
6286
desc 'Start the Prometheus stack component'
6387
task :prometheus do
6488
trap('SIGINT') do
@@ -93,6 +117,11 @@ task :start, :source do |_task, args|
93117
sh "./scripts/start-source.sh #{args[:source]}"
94118
end
95119

120+
desc 'Stop the EFK cluster'
121+
task :stop do
122+
sh './scripts/stop-es-cluster.sh'
123+
end
124+
96125
desc 'Run all style checks'
97126
task style: %w[rubocop]
98127

docker-compose-clients.yml

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
version: '3.6'
2+
3+
services:
4+
kibana:
5+
build:
6+
context: ./kibana
7+
args:
8+
VERSION_EFK: ${VERSION_EFK}
9+
container_name: kibana
10+
environment:
11+
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_KIBANA_PASSWORD}
12+
SERVER_SSL_KEYPASSPHRASE: ${KEY_PASSPHRASE}
13+
hostname: kibana
14+
networks:
15+
- cluster
16+
ports:
17+
- 5601:5601
18+
volumes:
19+
- certs:/usr/share/kibana/config/certificates
20+
- ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
21+
22+
elastichq:
23+
build:
24+
context: ./elasticHQ
25+
args:
26+
VERSION_ELASTICHQ: ${VERSION_ELASTICHQ}
27+
container_name: elastichq
28+
environment:
29+
HQ_DEFAULT_URL: https://elastic:${ELASTICSEARCH_ELASTIC_PASSWORD}@elasticsearch:9200
30+
HQ_ENABLE_SSL: "True"
31+
HQ_CA_CERTS: /usr/share/elastichq/ca/ca.crt
32+
HQ_VERIFY_CERTS: "False"
33+
hostname: elastichq
34+
networks:
35+
- cluster
36+
ports:
37+
- 5000:5000
38+
volumes:
39+
- certs:/usr/share/elastichq
40+
41+
networks:
42+
cluster:
43+
driver: bridge
44+
45+
volumes:
46+
certs:
47+
driver: local

docker-compose-create-certs.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,12 @@ services:
3030
- certs:/certs
3131
- ./elasticsearch/certs/instances.yml:/usr/share/elasticsearch/instances.yml
3232
networks:
33-
- efk
33+
- cluster
3434

3535
volumes:
3636
certs:
3737
driver: local
3838

3939
networks:
40-
efk:
40+
cluster:
4141
driver: bridge

docker-compose.yml

Lines changed: 9 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,10 @@ services:
1111
environment:
1212
- ${ES_JAVA_OPTS:-/dev/null}
1313
- KEY_PASSPHRASE=${KEY_PASSPHRASE}
14-
healthcheck:
15-
test: curl --cacert $CERTS_DIR/ca.crt -s https://elasticsearch:9200 >/dev/null; if [[ $$? == 52 ]]; then echo 0; else echo 1; fi
16-
interval: 30s
17-
timeout: 10s
18-
retries: 5
14+
- CERTS_DIR=${CERTS_DIR}
1915
hostname: elasticsearch
2016
networks:
21-
- efk
17+
- cluster
2218
ports:
2319
- "9200:9200"
2420
- "9300:9300"
@@ -33,8 +29,7 @@ services:
3329
- certs:$CERTS_DIR
3430
- elasticsearch_master:/usr/share/elasticsearch/data
3531
- ./elasticsearch/entrypoint.sh:/usr/share/elasticsearch/custom-entrypoint.sh
36-
- ./elasticsearch/config/master/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
37-
- ./elasticsearch/config/readonlyrest.yml:/usr/share/elasticsearch/config/readonlyrest.yml
32+
- ./elasticsearch/config/master.yml:/usr/share/elasticsearch/config/elasticsearch.yml
3833

3934
elasticsearch-hot:
4035
build:
@@ -48,7 +43,7 @@ services:
4843
- KEY_PASSPHRASE=${KEY_PASSPHRASE}
4944
hostname: elasticsearch-hot
5045
networks:
51-
- efk
46+
- cluster
5247
ulimits:
5348
nofile:
5449
soft: 65536
@@ -60,8 +55,7 @@ services:
6055
- certs:$CERTS_DIR
6156
- elasticsearch_hot:/usr/share/elasticsearch/data
6257
- ./elasticsearch/entrypoint.sh:/usr/share/elasticsearch/custom-entrypoint.sh
63-
- ./elasticsearch/config/hot/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
64-
- ./elasticsearch/config/readonlyrest.yml:/usr/share/elasticsearch/config/readonlyrest.yml
58+
- ./elasticsearch/config/hot.yml:/usr/share/elasticsearch/config/elasticsearch.yml
6559

6660
elasticsearch-warm:
6761
build:
@@ -75,7 +69,7 @@ services:
7569
- KEY_PASSPHRASE=${KEY_PASSPHRASE}
7670
hostname: elasticsearch-warm
7771
networks:
78-
- efk
72+
- cluster
7973
ulimits:
8074
nofile:
8175
soft: 65536
@@ -87,8 +81,7 @@ services:
8781
- certs:$CERTS_DIR
8882
- elasticsearch_warm:/usr/share/elasticsearch/data
8983
- ./elasticsearch/entrypoint.sh:/usr/share/elasticsearch/custom-entrypoint.sh
90-
- ./elasticsearch/config/warm/elasticsearch.yml:/usr/share/elasticsearch/config/elasticsearch.yml
91-
- ./elasticsearch/config/readonlyrest.yml:/usr/share/elasticsearch/config/readonlyrest.yml
84+
- ./elasticsearch/config/warm.yml:/usr/share/elasticsearch/config/elasticsearch.yml
9285

9386
# fluentd:
9487
# build:
@@ -103,7 +96,7 @@ services:
10396
# - ./fluentd/fluentd.properties
10497
# hostname: fluentd
10598
# networks:
106-
# - efk
99+
# - cluster
107100
# ports:
108101
# - "5140:5140"
109102
# - "5140:5140/udp"
@@ -116,50 +109,9 @@ services:
116109
# volumes:
117110
# - ./fluentd/config:/fluentd/etc
118111
# - ./fluentd/certs:/fluentd/certs
119-
#
120-
kibana:
121-
build:
122-
context: ./kibana
123-
args:
124-
VERSION_EFK: ${VERSION_EFK}
125-
container_name: kibana
126-
depends_on:
127-
- elasticsearch
128-
environment:
129-
ELASTICSEARCH_PASSWORD: ${ELASTICSEARCH_PASSWORD}
130-
SERVER_SSL_KEYPASSPHRASE: ${KEY_PASSPHRASE}
131-
hostname: kibana
132-
networks:
133-
- efk
134-
ports:
135-
- 5601:5601
136-
volumes:
137-
- certs:/usr/share/kibana/config/certificates
138-
- ./kibana/config/kibana.yml:/usr/share/kibana/config/kibana.yml
139-
140-
# elastichq:
141-
# build:
142-
# context: ./elasticHQ
143-
# args:
144-
# VERSION_ELASTICHQ: ${VERSION_ELASTICHQ}
145-
# container_name: elastichq
146-
# depends_on:
147-
# - elasticsearch
148-
# environment:
149-
# HQ_DEFAULT_URL: https://elasticsearch:9200
150-
# HQ_ENABLE_SSL: "True"
151-
# HQ_CA_CERTS: /usr/share/elastichq/ca/ca.crt
152-
# HQ_VERIFY_CERTS: "False"
153-
# hostname: elastichq
154-
# networks:
155-
# - efk
156-
# ports:
157-
# - 5000:5000
158-
# volumes:
159-
# - certs:/usr/share/elastichq
160112

161113
networks:
162-
efk:
114+
cluster:
163115
driver: bridge
164116

165117
volumes:

elastichq/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ LABEL Description="ElasticHQ instance"
66
LABEL Version="2.0.0"
77

88
EXPOSE 5000
9-
10-
HEALTHCHECK --interval=5s --timeout=2s --retries=15 \
11-
CMD nc -z localhost 5000 || exit 1
9+
HEALTHCHECK --interval=5s --timeout=2s --retries=15 CMD nc -z localhost 5000 || exit 1

elasticsearch/Dockerfile

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,4 @@ LABEL Description="Elasticsearch instance"
66
LABEL Version="2.0.0"
77

88
EXPOSE 9200 9300
9-
10-
HEALTHCHECK --interval=5s --timeout=2s --retries=15 \
11-
CMD curl --silent --fail localhost:9200/_cluster/health || exit 1
9+
HEALTHCHECK --interval=5s --timeout=2s --retries=15 CMD nc -z elasticsearch 9200 || exit 1
File renamed without changes.
File renamed without changes.

0 commit comments

Comments
 (0)