Skip to content

Commit 906db7c

Browse files
committed
feat: Phase 4 Lab 06 — Elasticsearch Production Deployment (restart policy, resource limits, ILM)
1 parent 9ec42c5 commit 906db7c

3 files changed

Lines changed: 416 additions & 6 deletions

File tree

.github/workflows/ci.yml

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -256,3 +256,52 @@ run: bash tests/labs/test-lab-05-01.sh
256256
- name: Cleanup
257257
if: always()
258258
run: docker compose -f docker/docker-compose.integration.yml down -v
259+
260+
lab-06-smoke:
261+
name: Lab 05-06 -- Elasticsearch Production Deployment (restart policy, resource limits, ILM)
262+
runs-on: ubuntu-latest
263+
needs: validate
264+
continue-on-error: true
265+
steps:
266+
- uses: actions/checkout@v4
267+
268+
- name: Install tools
269+
run: sudo apt-get install -y curl netcat-openbsd ldap-utils
270+
271+
- name: Validate production compose
272+
run: docker compose -f docker/docker-compose.production.yml config -q && echo "Production compose valid"
273+
274+
- name: Start production stack
275+
run: docker compose -f docker/docker-compose.production.yml up -d
276+
277+
- name: Wait for Elasticsearch
278+
run: |
279+
for i in $(seq 1 24); do
280+
curl -sf http://localhost:9200/_cluster/health | grep -qE '"status":"(green|yellow)"' && echo "ES ready" && break
281+
echo "Waiting for ES... ($i/24)"; sleep 5
282+
done
283+
284+
- name: Wait for Kibana
285+
run: |
286+
for i in $(seq 1 18); do
287+
curl -sf http://localhost:5650/api/status | grep -q overall && echo "Kibana ready" && break
288+
echo "Waiting for Kibana... ($i/18)"; sleep 5
289+
done
290+
291+
- name: Wait for Keycloak
292+
run: |
293+
for i in $(seq 1 24); do
294+
curl -sf http://localhost:8550/realms/master | grep -q realm && echo "KC ready" && break
295+
echo "Waiting for KC... ($i/24)"; sleep 5
296+
done
297+
298+
- name: Run Lab 05-06 test script
299+
run: bash tests/labs/test-lab-05-06.sh --no-cleanup
300+
301+
- name: Collect logs on failure
302+
if: failure()
303+
run: docker compose -f docker/docker-compose.production.yml logs
304+
305+
- name: Cleanup
306+
if: always()
307+
run: docker compose -f docker/docker-compose.production.yml down -v

docker/docker-compose.production.yml

Lines changed: 185 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,191 @@
1-
# Lab 06 — Production: elasticsearch HA-ready with monitoring and external volumes
2-
---
1+
# =============================================================================
2+
# IT-Stack: Elasticsearch — Lab 06: Production Deployment
3+
# Module 05 · Phase 4 · Lab 06
4+
# =============================================================================
5+
# Services: Elasticsearch · Kibana · OpenLDAP · Keycloak
6+
# Ports: Kibana:5650 KC:8550 LDAP:3870
7+
# Credentials:
8+
# Kibana/ES: kibana_system / KibanaProd06! elastic / ElasticProd06!
9+
# Keycloak: admin / Admin06!
10+
# LDAP: cn=admin,dc=lab,dc=local / LdapProd06!
11+
# Production features vs Lab 05:
12+
# + restart: unless-stopped on ALL services
13+
# + Resource limits AND reservations on every service
14+
# + Production JVM heap settings (ES_JAVA_OPTS)
15+
# + Dedicated ES cluster name + node name
16+
# + IT_STACK_ENV: production IT_STACK_LAB: "06" labels
17+
# + ILM policy hint via ELASTIC_ILM_ENABLED env
18+
# + Healthcheck start_period on all long-boot services
19+
# =============================================================================
20+
21+
name: it-stack-elasticsearch-lab06
22+
323
services:
4-
elasticsearch:
24+
25+
# ── Elasticsearch ────────────────────────────────────────────────────────────
26+
elastic-p06-es:
527
image: docker.elastic.co/elasticsearch/elasticsearch:8.13.0
6-
container_name: it-stack-elasticsearch
7-
restart: always
28+
container_name: elastic-p06-es
29+
restart: unless-stopped
30+
environment:
31+
- node.name=elastic-p06-es
32+
- cluster.name=it-stack-prod
33+
- discovery.type=single-node
34+
- ES_JAVA_OPTS=-Xms1g -Xmx1g
35+
- xpack.security.enabled=false
36+
- xpack.security.http.ssl.enabled=false
37+
- ELASTIC_PASSWORD=ElasticProd06!
38+
- IT_STACK_ENV=production
39+
- IT_STACK_MODULE=elasticsearch
40+
- IT_STACK_LAB=06
41+
- ELASTIC_ILM_ENABLED=true
42+
- ELASTIC_ILM_HOT_DAYS=7
43+
- ELASTIC_ILM_WARM_DAYS=30
44+
- ELASTIC_ILM_DELETE_DAYS=90
45+
volumes:
46+
- elastic-p06-es-data:/usr/share/elasticsearch/data
47+
healthcheck:
48+
test: ["CMD-SHELL", "curl -sf http://localhost:9200/_cluster/health | grep -q '\"status\"' || exit 1"]
49+
interval: 15s
50+
timeout: 10s
51+
retries: 20
52+
start_period: 60s
53+
networks:
54+
- elastic-p06-net
55+
deploy:
56+
resources:
57+
limits:
58+
cpus: "2.0"
59+
memory: 2G
60+
reservations:
61+
cpus: "0.5"
62+
memory: 1G
63+
64+
# ── Kibana ──────────────────────────────────────────────────────────────────
65+
elastic-p06-kib:
66+
image: docker.elastic.co/kibana/kibana:8.13.0
67+
container_name: elastic-p06-kib
68+
restart: unless-stopped
69+
depends_on:
70+
elastic-p06-es:
71+
condition: service_healthy
72+
elastic-p06-kc:
73+
condition: service_healthy
874
ports:
9-
- "9200:$firstPort"
75+
- "5650:5601"
76+
environment:
77+
ELASTICSEARCH_HOSTS: http://elastic-p06-es:9200
78+
KIBANA_SYSTEM_PASSWORD: KibanaProd06!
79+
IT_STACK_ENV: production
80+
IT_STACK_MODULE: elasticsearch
81+
IT_STACK_LAB: "06"
82+
XPACK_SECURITY_ENABLED: "false"
83+
XPACK_ENCRYPTEDSAVEDOBJECTS_ENCRYPTIONKEY: "elasticProd06EncryptionKey12345"
84+
SERVER_NAME: kibana-lab06
85+
SERVER_PUBLICBASEURL: http://localhost:5650
86+
KEYCLOAK_URL: http://elastic-p06-kc:8080
87+
KEYCLOAK_REALM: it-stack
88+
KEYCLOAK_CLIENT_ID: kibana
89+
GRAYLOG_API_URL: http://graylog.lab.local:9000
90+
GRAYLOG_API_USER: admin
91+
GRAYLOG_API_TOKEN: prod-graylog-token
92+
healthcheck:
93+
test: ["CMD-SHELL", "curl -sf http://localhost:5601/api/status | grep -q version || exit 1"]
94+
interval: 30s
95+
timeout: 10s
96+
retries: 10
97+
start_period: 120s
98+
networks:
99+
- elastic-p06-net
100+
deploy:
101+
resources:
102+
limits:
103+
cpus: "1.0"
104+
memory: 1G
105+
reservations:
106+
cpus: "0.25"
107+
memory: 512M
108+
109+
# ── OpenLDAP ───────────────────────────────────────────────────────────────
110+
elastic-p06-ldap:
111+
image: osixia/openldap:1.5.0
112+
container_name: elastic-p06-ldap
113+
restart: unless-stopped
114+
environment:
115+
LDAP_ORGANISATION: "IT-Stack Production"
116+
LDAP_DOMAIN: lab.local
117+
LDAP_ADMIN_PASSWORD: LdapProd06!
118+
LDAP_CONFIG_PASSWORD: ConfigProd06!
119+
LDAP_BASE_DN: dc=lab,dc=local
120+
LDAP_READONLY_USER: "true"
121+
LDAP_READONLY_USER_USERNAME: readonly
122+
LDAP_READONLY_USER_PASSWORD: ReadOnlyProd06!
123+
ports:
124+
- "3870:389"
125+
volumes:
126+
- elastic-p06-ldap-data:/var/lib/ldap
127+
- elastic-p06-ldap-config:/etc/ldap/slapd.d
128+
healthcheck:
129+
test: ["CMD-SHELL", "ldapsearch -x -H ldap://localhost -b dc=lab,dc=local -D cn=admin,dc=lab,dc=local -w LdapProd06! cn=admin > /dev/null 2>&1 && echo ok"]
130+
interval: 15s
131+
timeout: 5s
132+
retries: 5
133+
start_period: 20s
134+
networks:
135+
- elastic-p06-net
136+
deploy:
137+
resources:
138+
limits:
139+
cpus: "0.5"
140+
memory: 256M
141+
reservations:
142+
cpus: "0.1"
143+
memory: 64M
144+
145+
# ── Keycloak ───────────────────────────────────────────────────────────────
146+
elastic-p06-kc:
147+
image: quay.io/keycloak/keycloak:24.0.3
148+
container_name: elastic-p06-kc
149+
restart: unless-stopped
150+
command: start-dev
151+
environment:
152+
KEYCLOAK_ADMIN: admin
153+
KEYCLOAK_ADMIN_PASSWORD: Admin06!
154+
KC_HEALTH_ENABLED: "true"
155+
KC_DB: dev-file
156+
KC_HOSTNAME_STRICT: "false"
157+
KC_HOSTNAME_STRICT_HTTPS: "false"
158+
KC_HTTP_ENABLED: "true"
159+
ports:
160+
- "8550:8080"
161+
healthcheck:
162+
test: ["CMD-SHELL", "curl -sf http://localhost:8080/realms/master || exit 1"]
163+
interval: 15s
164+
timeout: 5s
165+
retries: 10
166+
start_period: 60s
167+
networks:
168+
- elastic-p06-net
169+
deploy:
170+
resources:
171+
limits:
172+
cpus: "1.0"
173+
memory: 768M
174+
reservations:
175+
cpus: "0.25"
176+
memory: 256M
177+
178+
# ── Networks ───────────────────────────────────────────────────────────────────
179+
networks:
180+
elastic-p06-net:
181+
name: elastic-p06-net
182+
driver: bridge
183+
184+
# ── Volumes ────────────────────────────────────────────────────────────────────
185+
volumes:
186+
elastic-p06-es-data:
187+
elastic-p06-ldap-data:
188+
elastic-p06-ldap-config:
10189
environment:
11190
- IT_STACK_ENV=production
12191
- KEYCLOAK_URL=

0 commit comments

Comments
 (0)