forked from mtusi2026/mtusi2026lab7
Перенесён минимум lab6 (API без изменений), добавлена защита на границах доверия: - внешний HTTPS; обязательный mTLS LB -> API с allowlist identity и отзывом по serial; - TLS на всех связях: PostgreSQL verify-full, MinIO HTTPS, RabbitMQ AMQPS mTLS (EXTERNAL), Valkey TLS + ACL, Collector и хранилища телеметрии через mTLS с отдельными CA; - OpenBao в server mode: cert auth, токены 15 мин, политики только на свой путь; - роли БД, S3-политики и права брокера по принципу минимальных прав; - Argon2id с замером, rehash, общий лимит входа, бюджет защиты от login DoS; - hardening всех контейнеров, scan образов с разбором, модель угроз, матрица доверия; - отрицательные тесты: TLS-аудит (135 проверок), ACL, ротации, sealed OpenBao.
605 lines
23 KiB
YAML
605 lines
23 KiB
YAML
name: mtusi-lab7
|
|
# Trust layout: contracts/trust-matrix.md. Every TLS key reaches only its own container (Docker secrets from
|
|
# secrets/pki, created by scripts/pki.sh). API and worker receive NO passwords: they authenticate to OpenBao with
|
|
# their client certificate and read their scoped KV secret (scripts/bao.sh bootstrap).
|
|
|
|
x-hardened: &hardened
|
|
cap_drop: [ALL]
|
|
security_opt: ["no-new-privileges:true"]
|
|
read_only: true
|
|
restart: unless-stopped
|
|
|
|
x-otel-env: &otel-env
|
|
OTEL_SDK_DISABLED: ${OTEL_SDK_DISABLED:-false}
|
|
OTEL_TRACES_SAMPLER_ARG: ${OTEL_TRACES_SAMPLER_ARG:-1.0}
|
|
OTEL_EXPORTER_OTLP_ENDPOINT: https://otel-collector:4318
|
|
OTEL_EXPORTER_OTLP_PROTOCOL: http/protobuf
|
|
OTEL_EXPORTER_OTLP_CERTIFICATE: /run/secrets/ca.crt
|
|
OTEL_EXPORTER_OTLP_CLIENT_CERTIFICATE: /run/secrets/otel.crt
|
|
OTEL_EXPORTER_OTLP_CLIENT_KEY: /run/secrets/otel.key
|
|
OTEL_EXPORTER_OTLP_TIMEOUT: "5"
|
|
OTEL_RESOURCE_ATTRIBUTES: deployment.environment.name=lab
|
|
OTEL_SEMCONV_STABILITY_OPT_IN: http
|
|
OTEL_METRIC_EXPORT_INTERVAL: "10000"
|
|
OTEL_BSP_MAX_QUEUE_SIZE: "2048"
|
|
OTEL_BSP_SCHEDULE_DELAY: "2000"
|
|
OTEL_BLRP_MAX_QUEUE_SIZE: "2048"
|
|
SERVICE_VERSION: "1.7.0"
|
|
|
|
x-app-env: &app-env
|
|
TLS_CA_FILE: /run/secrets/ca.crt
|
|
TLS_CLIENT_CERT_FILE: /run/secrets/client.crt
|
|
TLS_CLIENT_KEY_FILE: /run/secrets/client.key
|
|
BAO_ADDR: https://openbao:8200
|
|
S3_ENDPOINT: https://minio:9000
|
|
BROKER_URL: amqps://rabbitmq:5671/messenger?auth=external&heartbeat=30
|
|
DATABASE_SSLMODE: verify-full
|
|
|
|
x-api: &api
|
|
<<: *hardened
|
|
build:
|
|
context: .
|
|
image: mtusi-messenger:lab7
|
|
env_file: [.env]
|
|
tmpfs: ["/tmp:size=128m,mode=1777"]
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
rabbitmq: {condition: service_healthy}
|
|
valkey: {condition: service_healthy}
|
|
openbao: {condition: service_healthy}
|
|
minio-init: {condition: service_completed_successfully}
|
|
migrate: {condition: service_completed_successfully}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.50", memory: 512M, pids: 256}
|
|
# Business port 8080 is mTLS-only; the healthcheck uses the loopback-only health listener 127.0.0.1:8081.
|
|
healthcheck:
|
|
test: ["CMD", "python", "-c", "import urllib.request,sys; sys.exit(0 if urllib.request.urlopen('http://127.0.0.1:8081/health/ready', timeout=2).status == 200 else 1)"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
services:
|
|
nginx:
|
|
<<: *hardened
|
|
image: nginx:1.30.6-alpine@sha256:583b7f2fce1cdb8da5ad5c39ebd3c33b98b87d493190e548bdee1fa8c619c311
|
|
user: "101:101"
|
|
command: ["/bin/sh", "/opt/nginx-health.sh"]
|
|
environment:
|
|
API_UPSTREAMS: ${API_UPSTREAMS:-api-1 api-2}
|
|
HEALTH_INTERVAL: "1"
|
|
HEALTH_FALL: "2"
|
|
HEALTH_RISE: "2"
|
|
ports:
|
|
- "127.0.0.1:8443:8443" # the only business ingress: TLS
|
|
tmpfs: ["/tmp:uid=101,gid=101,mode=0700", "/var/cache/nginx:uid=101,gid=101,mode=0700",
|
|
"/var/run:uid=101,gid=101,mode=0755", "/etc/nginx/upstream:uid=101,gid=101,mode=0755"]
|
|
volumes:
|
|
- ./infra/nginx.conf:/etc/nginx/nginx.conf:ro
|
|
- ./infra/nginx-health.sh:/opt/nginx-health.sh:ro
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: lb_server_crt, target: server.crt}
|
|
- {source: lb_server_key, target: server.key}
|
|
- {source: lb_client_crt, target: client.crt}
|
|
- {source: lb_client_key, target: client.key}
|
|
depends_on:
|
|
api-1: {condition: service_healthy}
|
|
api-2: {condition: service_healthy}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.25", memory: 64M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -sf --cacert /run/secrets/ca.crt https://localhost:8443/health/live >/dev/null"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 5s
|
|
|
|
api-1:
|
|
<<: *api
|
|
environment:
|
|
<<: [*otel-env, *app-env]
|
|
INSTANCE_ID: api-1
|
|
LOGIN_RATE_LIMIT_PER_IP: ${LOGIN_RATE_LIMIT_PER_IP:-120}
|
|
PASSWORD_HASH_CONCURRENCY: ${PASSWORD_HASH_CONCURRENCY:-4}
|
|
BAO_AUTH_ROLE: api
|
|
BAO_KV_PATH: api
|
|
TLS_SERVER_CERT_FILE: /run/secrets/server.crt
|
|
TLS_SERVER_KEY_FILE: /run/secrets/server.key
|
|
ALLOWED_CLIENT_IDENTITIES: lb.client.messenger
|
|
REVOKED_SERIALS_FILE: /run/secrets/revoked-serials.txt
|
|
MAX_PENDING_JOBS: ${MAX_PENDING_JOBS:-200}
|
|
secrets: &api-secrets
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: api_1_crt, target: server.crt}
|
|
- {source: api_1_key, target: server.key}
|
|
- {source: api_client_crt, target: client.crt}
|
|
- {source: api_client_key, target: client.key}
|
|
- {source: api_otel_crt, target: otel.crt}
|
|
- {source: api_otel_key, target: otel.key}
|
|
- {source: revoked_serials, target: revoked-serials.txt}
|
|
|
|
api-2:
|
|
<<: *api
|
|
environment:
|
|
<<: [*otel-env, *app-env]
|
|
INSTANCE_ID: api-2
|
|
LOGIN_RATE_LIMIT_PER_IP: ${LOGIN_RATE_LIMIT_PER_IP:-120}
|
|
PASSWORD_HASH_CONCURRENCY: ${PASSWORD_HASH_CONCURRENCY:-4}
|
|
BAO_AUTH_ROLE: api
|
|
BAO_KV_PATH: api
|
|
TLS_SERVER_CERT_FILE: /run/secrets/server.crt
|
|
TLS_SERVER_KEY_FILE: /run/secrets/server.key
|
|
ALLOWED_CLIENT_IDENTITIES: lb.client.messenger
|
|
REVOKED_SERIALS_FILE: /run/secrets/revoked-serials.txt
|
|
MAX_PENDING_JOBS: ${MAX_PENDING_JOBS:-200}
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: api_2_crt, target: server.crt}
|
|
- {source: api_2_key, target: server.key}
|
|
- {source: api_client_crt, target: client.crt}
|
|
- {source: api_client_key, target: client.key}
|
|
- {source: api_otel_crt, target: otel.crt}
|
|
- {source: api_otel_key, target: otel.key}
|
|
- {source: revoked_serials, target: revoked-serials.txt}
|
|
|
|
worker:
|
|
<<: *hardened
|
|
build:
|
|
context: .
|
|
image: mtusi-messenger:lab7
|
|
command: ["python", "-m", "app.worker"]
|
|
env_file: [.env]
|
|
environment:
|
|
<<: [*otel-env, *app-env]
|
|
INSTANCE_ID: ""
|
|
BAO_AUTH_ROLE: worker
|
|
BAO_KV_PATH: worker
|
|
DB_POOL_MAX: "6"
|
|
WORKER_CONCURRENCY: ${WORKER_CONCURRENCY:-2}
|
|
WORKER_PREFETCH: ${WORKER_PREFETCH:-2}
|
|
tmpfs: ["/tmp:size=512m,mode=1777"]
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: worker_client_crt, target: client.crt}
|
|
- {source: worker_client_key, target: client.key}
|
|
- {source: worker_otel_crt, target: otel.crt}
|
|
- {source: worker_otel_key, target: otel.key}
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
rabbitmq: {condition: service_healthy}
|
|
openbao: {condition: service_healthy}
|
|
minio-init: {condition: service_completed_successfully}
|
|
migrate: {condition: service_completed_successfully}
|
|
stop_grace_period: 30s
|
|
deploy:
|
|
replicas: ${WORKER_REPLICAS:-2}
|
|
resources:
|
|
limits: {cpus: "${WORKER_CPUS:-2.00}", memory: 1536M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "python -c \"import os,sys,time; sys.exit(0 if time.time()-os.path.getmtime('/tmp/worker-heartbeat') < 15 else 1)\""]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 3
|
|
start_period: 30s
|
|
|
|
migrate:
|
|
<<: *hardened
|
|
build:
|
|
context: .
|
|
image: mtusi-messenger:lab7
|
|
command: ["python", "scripts/migrate.py"]
|
|
restart: "no"
|
|
environment:
|
|
DATABASE_URL_FILE: /run/secrets/migrate_database_url
|
|
DATABASE_SSLMODE: verify-full
|
|
TLS_CA_FILE: /run/secrets/ca.crt
|
|
DB_API_PASSWORD_FILE: /run/secrets/db_api_password
|
|
DB_WORKER_PASSWORD_FILE: /run/secrets/db_worker_password
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- migrate_database_url
|
|
- db_api_password
|
|
- db_worker_password
|
|
depends_on:
|
|
postgres: {condition: service_healthy}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.25", memory: 128M, pids: 256}
|
|
|
|
openbao:
|
|
<<: *hardened
|
|
image: openbao/openbao:2.6.5@sha256:09f1eaaee351c329d75a5a89654d6e1ad4792998650c3cbf0c3513a76d9d9b6e
|
|
user: "100:1000"
|
|
entrypoint: ["bao", "server", "-config=/openbao/config/config.hcl"]
|
|
tmpfs: ["/tmp"]
|
|
volumes:
|
|
- ./infra/openbao/config.hcl:/openbao/config/config.hcl:ro
|
|
- baodata:/openbao/file
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: openbao_crt, target: openbao.crt}
|
|
- {source: openbao_key, target: openbao.key}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.50", memory: 256M, pids: 256}
|
|
# Healthy = server answers (sealed or not). Services retry their login while it is sealed.
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "BAO_ADDR=https://127.0.0.1:8200 BAO_CACERT=/run/secrets/ca.crt bao status >/dev/null 2>&1; [ $$? -ne 1 ]"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
|
|
postgres:
|
|
<<: *hardened
|
|
image: postgres:17.7-alpine@sha256:bb377b7239d2774ac8cc76f481596ce96c5a6b5e9d141f6d0a0ee371a6e7c0f2
|
|
user: "70:70"
|
|
environment:
|
|
POSTGRES_DB: messenger
|
|
POSTGRES_USER: messenger
|
|
POSTGRES_PASSWORD_FILE: /run/secrets/postgres_password
|
|
POSTGRES_INITDB_ARGS: --data-checksums --auth-host=scram-sha-256
|
|
# PostgreSQL refuses a key file readable by others: copy it to the tmpfs with mode 0600 first.
|
|
entrypoint: ["sh", "-c", "install -m 600 /run/secrets/server.key /tmp/server.key && exec docker-entrypoint.sh \"$$@\"", "--"]
|
|
command:
|
|
- postgres
|
|
- -c
|
|
- ssl=on
|
|
- -c
|
|
- ssl_cert_file=/run/secrets/server.crt
|
|
- -c
|
|
- ssl_key_file=/tmp/server.key
|
|
- -c
|
|
- ssl_min_protocol_version=TLSv1.2
|
|
- -c
|
|
- hba_file=/etc/postgresql/pg_hba.conf
|
|
- -c
|
|
- password_encryption=scram-sha-256
|
|
- -c
|
|
- synchronous_commit=on
|
|
- -c
|
|
- shared_buffers=128MB
|
|
- -c
|
|
- max_connections=60
|
|
tmpfs: ["/tmp", "/var/run/postgresql"]
|
|
secrets:
|
|
- postgres_password
|
|
- {source: postgres_crt, target: server.crt}
|
|
- {source: postgres_key, target: server.key}
|
|
volumes:
|
|
- pgdata:/var/lib/postgresql/data
|
|
- ./infra/postgres/pg_hba.conf:/etc/postgresql/pg_hba.conf:ro
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 512M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "pg_isready -U messenger -d messenger -h /var/run/postgresql"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
start_period: 10s
|
|
|
|
valkey:
|
|
<<: *hardened
|
|
image: valkey/valkey:8.1-alpine@sha256:081c2f5cb575efc901aa80ff9cdbd1ec6a301682fd35e1ebb4b0990a4a4a8507
|
|
user: "999:1000"
|
|
entrypoint: ["sh", "/opt/valkey-start.sh"]
|
|
tmpfs: ["/tmp", "/data"]
|
|
volumes:
|
|
- ./infra/valkey/valkey-start.sh:/opt/valkey-start.sh:ro
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: valkey_crt, target: server.crt}
|
|
- {source: valkey_key, target: server.key}
|
|
- valkey_api_password
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.25", memory: 128M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD", "valkey-cli", "--tls", "--cacert", "/run/secrets/ca.crt", "--user", "health", "--pass", "health", "-h", "valkey", "ping"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
|
|
rabbitmq:
|
|
<<: *hardened
|
|
image: rabbitmq:4.0.5-alpine@sha256:e045b5166b9188a38eee5c99411709aa1f0ffa2ac75664053e64cb69411f7c32
|
|
user: "100:101"
|
|
hostname: rabbitmq
|
|
environment:
|
|
RABBITMQ_ENABLED_PLUGINS_FILE: /etc/rabbitmq/enabled_plugins
|
|
# Erlang distribution + epmd loopback-only (no cluster; CLI runs inside the container). The node name must
|
|
# then resolve to loopback, hence rabbit@localhost (its data dir is /var/lib/rabbitmq/mnesia/rabbit@localhost).
|
|
RABBITMQ_NODENAME: rabbit@localhost
|
|
ERL_EPMD_ADDRESS: 127.0.0.1
|
|
tmpfs: ["/tmp", "/etc/rabbitmq/conf.d"]
|
|
volumes:
|
|
- rabbitmqdata:/var/lib/rabbitmq
|
|
- ./infra/rabbitmq/rabbitmq.conf:/etc/rabbitmq/rabbitmq.conf:ro
|
|
- ./infra/rabbitmq/enabled_plugins:/etc/rabbitmq/enabled_plugins:ro
|
|
- ./infra/rabbitmq/definitions.json:/etc/rabbitmq/definitions.json:ro
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: rabbitmq_crt, target: server.crt}
|
|
- {source: rabbitmq_key, target: server.key}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 512M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD", "rabbitmq-diagnostics", "-q", "check_running"]
|
|
interval: 5s
|
|
timeout: 10s
|
|
retries: 30
|
|
start_period: 20s
|
|
|
|
minio:
|
|
<<: *hardened
|
|
image: madlabcg/minio@sha256:ad134b2dd572ae0d989d6807c3e45516cc75a34883a8021db2ff04be5d1d496a
|
|
command: ["server", "/data", "--certs-dir", "/tmp/certs"]
|
|
entrypoint: ["sh", "-c", "mkdir -p /tmp/certs/CAs && cp /run/secrets/server.crt /tmp/certs/public.crt && cp /run/secrets/server.key /tmp/certs/private.key && cp /run/secrets/ca.crt /tmp/certs/CAs/ca.crt && exec minio \"$$@\"", "--"]
|
|
environment:
|
|
MINIO_ROOT_USER_FILE: /run/secrets/minio_root_user
|
|
MINIO_ROOT_PASSWORD_FILE: /run/secrets/minio_root_password
|
|
MINIO_BROWSER: "off"
|
|
tmpfs: ["/tmp"]
|
|
secrets:
|
|
- minio_root_user
|
|
- minio_root_password
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: minio_crt, target: server.crt}
|
|
- {source: minio_key, target: server.key}
|
|
volumes:
|
|
- miniodata:/data
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.50", memory: 512M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "mkdir -p /tmp/hc/certs/CAs && cp /run/secrets/ca.crt /tmp/hc/certs/CAs/ca.crt && MC_HOST_hc=https://minio:9000 mc --config-dir /tmp/hc ready hc >/dev/null"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 10
|
|
start_period: 10s
|
|
|
|
minio-init:
|
|
<<: *hardened
|
|
image: madlabcg/minio@sha256:ad134b2dd572ae0d989d6807c3e45516cc75a34883a8021db2ff04be5d1d496a
|
|
entrypoint: ["/bin/sh", "/opt/init.sh"]
|
|
restart: "no"
|
|
environment:
|
|
S3_BUCKET: messenger-attachments
|
|
MC_CONFIG_DIR: /tmp/mc
|
|
tmpfs: ["/tmp"]
|
|
secrets:
|
|
- minio_root_user
|
|
- minio_root_password
|
|
- {source: ca_crt, target: ca.crt}
|
|
- s3_api_access_key
|
|
- s3_api_secret_key
|
|
- s3_worker_access_key
|
|
- s3_worker_secret_key
|
|
volumes:
|
|
- ./infra/minio/init.sh:/opt/init.sh:ro
|
|
- ./infra/minio/policy-api.json:/etc/minio-policy/policy-api.json:ro
|
|
- ./infra/minio/policy-worker.json:/etc/minio-policy/policy-worker.json:ro
|
|
depends_on:
|
|
minio: {condition: service_healthy}
|
|
|
|
# ------------------------------------------------------------------ observability (lab6) behind mTLS
|
|
otel-collector:
|
|
<<: *hardened
|
|
image: otel/opentelemetry-collector-contrib:0.120.0@sha256:85ac41c2db88d0df9bd6145e608a3cb023f5d8443868adbfbbf66efb51087917
|
|
command:
|
|
- --config=/etc/otelcol/collector.yaml
|
|
- --config=/etc/otelcol/profile-${COLLECTOR_PROFILE:-default}.yaml
|
|
volumes:
|
|
- ./infra/otel/collector.yaml:/etc/otelcol/collector.yaml:ro
|
|
- ./infra/otel/profile-default.yaml:/etc/otelcol/profile-default.yaml:ro
|
|
- ./infra/otel/profile-tail.yaml:/etc/otelcol/profile-tail.yaml:ro
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: ingest_ca_crt, target: ingest-ca.crt}
|
|
- {source: otel_collector_crt, target: server.crt}
|
|
- {source: otel_collector_key, target: server.key}
|
|
- {source: collector_out_crt, target: client.crt}
|
|
- {source: collector_out_key, target: client.key}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 256M, pids: 256}
|
|
|
|
prometheus:
|
|
<<: *hardened
|
|
image: prom/prometheus:v3.2.1@sha256:6927e0919a144aa7616fd0137d4816816d42f6b816de3af269ab065250859a62
|
|
command:
|
|
- --config.file=/etc/prometheus/prometheus.yml
|
|
- --web.config.file=/etc/prometheus/web.yml
|
|
- --storage.tsdb.path=/prometheus
|
|
- --storage.tsdb.retention.time=15d
|
|
- --web.enable-otlp-receiver
|
|
volumes:
|
|
- ./infra/prometheus/prometheus.yml:/etc/prometheus/prometheus.yml:ro
|
|
- ./infra/prometheus/web.yml:/etc/prometheus/web.yml:ro
|
|
- ./infra/prometheus/health-client.yml:/etc/prometheus/health-client.yml:ro
|
|
- ./infra/prometheus/rules:/etc/prometheus/rules:ro
|
|
- promdata:/prometheus
|
|
secrets:
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: telemetry_ca_crt, target: telemetry-ca.crt}
|
|
- {source: prometheus_crt, target: server.crt}
|
|
- {source: prometheus_key, target: server.key}
|
|
- {source: operator_crt, target: health.crt}
|
|
- {source: operator_key, target: health.key}
|
|
ports:
|
|
- "127.0.0.1:9090:9090" # mTLS: operator certificate only
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 512M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD", "promtool", "check", "healthy", "--url=https://prometheus:9090", "--http.config.file=/etc/prometheus/health-client.yml"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 20
|
|
|
|
loki:
|
|
<<: *hardened
|
|
image: grafana/loki:3.4.2@sha256:58a6c186ce78ba04d58bfe2a927eff296ba733a430df09645d56cdc158f3ba08
|
|
command: ["-config.file=/etc/loki/loki.yaml"]
|
|
volumes:
|
|
- ./infra/loki/loki.yaml:/etc/loki/loki.yaml:ro
|
|
- lokidata:/loki
|
|
secrets:
|
|
- {source: telemetry_ca_crt, target: telemetry-ca.crt}
|
|
- {source: loki_crt, target: server.crt}
|
|
- {source: loki_key, target: server.key}
|
|
ports:
|
|
- "127.0.0.1:3100:3100" # mTLS: operator certificate only
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 512M, pids: 256}
|
|
healthcheck: # TCP only: every HTTP request needs a telemetry client certificate
|
|
test: ["CMD", "/busybox/nc", "-z", "127.0.0.1", "3100"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 15s
|
|
|
|
tempo:
|
|
<<: *hardened
|
|
image: grafana/tempo:2.7.1@sha256:4443be217c396b065ee34845534199c36fdba4dc619cb96550e228d73fba6e69
|
|
command: ["-config.file=/etc/tempo/tempo.yaml"]
|
|
tmpfs: ["/tmp"]
|
|
volumes:
|
|
- ./infra/tempo/tempo.yaml:/etc/tempo/tempo.yaml:ro
|
|
- tempodata:/var/tempo
|
|
secrets:
|
|
- {source: telemetry_ca_crt, target: telemetry-ca.crt}
|
|
- {source: tempo_crt, target: server.crt}
|
|
- {source: tempo_key, target: server.key}
|
|
ports:
|
|
- "127.0.0.1:3200:3200" # mTLS: operator certificate only
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "1.00", memory: 1024M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD", "nc", "-z", "127.0.0.1", "3200"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 15s
|
|
|
|
grafana:
|
|
<<: *hardened
|
|
image: grafana/grafana:11.5.2@sha256:8b37a2f028f164ce7b9889e1765b9d6ee23fec80f871d156fbf436d6198d32b7
|
|
environment:
|
|
GF_SERVER_PROTOCOL: https
|
|
GF_SERVER_CERT_FILE: /run/secrets/server.crt
|
|
GF_SERVER_CERT_KEY: /run/secrets/server.key
|
|
GF_SECURITY_ADMIN_USER: admin
|
|
GF_SECURITY_ADMIN_PASSWORD__FILE: /run/secrets/grafana_admin_password
|
|
GF_SECURITY_COOKIE_SECURE: "true"
|
|
GF_USERS_ALLOW_SIGN_UP: "false"
|
|
GF_AUTH_ANONYMOUS_ENABLED: "false"
|
|
GF_ANALYTICS_REPORTING_ENABLED: "false"
|
|
GF_ANALYTICS_CHECK_FOR_UPDATES: "false"
|
|
GF_NEWS_NEWS_FEED_ENABLED: "false"
|
|
GF_PLUGINS_PREINSTALL_DISABLED: "true"
|
|
GF_DASHBOARDS_DEFAULT_HOME_DASHBOARD_PATH: /var/lib/grafana/dashboards/messenger.json
|
|
tmpfs: ["/tmp"]
|
|
secrets:
|
|
- grafana_admin_password
|
|
- {source: ca_crt, target: ca.crt}
|
|
- {source: grafana_crt, target: server.crt}
|
|
- {source: grafana_key, target: server.key}
|
|
- {source: grafana_out_crt, target: client.crt}
|
|
- {source: grafana_out_key, target: client.key}
|
|
volumes:
|
|
- ./infra/grafana/provisioning:/etc/grafana/provisioning:ro
|
|
- ./infra/grafana/dashboards:/var/lib/grafana/dashboards:ro
|
|
- grafanadata:/var/lib/grafana
|
|
ports:
|
|
- "127.0.0.1:3000:3000" # HTTPS + admin login
|
|
depends_on:
|
|
prometheus: {condition: service_healthy}
|
|
loki: {condition: service_started}
|
|
tempo: {condition: service_started}
|
|
deploy:
|
|
resources:
|
|
limits: {cpus: "0.50", memory: 256M, pids: 256}
|
|
healthcheck:
|
|
test: ["CMD-SHELL", "curl -sf --cacert /run/secrets/ca.crt https://grafana:3000/api/health >/dev/null"]
|
|
interval: 5s
|
|
timeout: 3s
|
|
retries: 30
|
|
start_period: 15s
|
|
|
|
volumes:
|
|
pgdata:
|
|
miniodata:
|
|
rabbitmqdata:
|
|
baodata:
|
|
promdata:
|
|
lokidata:
|
|
tempodata:
|
|
grafanadata:
|
|
|
|
secrets:
|
|
ca_crt: {file: ./secrets/pki/ca.crt}
|
|
ingest_ca_crt: {file: ./secrets/pki/ingest.crt}
|
|
telemetry_ca_crt: {file: ./secrets/pki/telemetry.crt}
|
|
revoked_serials: {file: ./secrets/pki/revoked-serials.txt}
|
|
lb_server_crt: {file: ./secrets/pki/lb-server.crt}
|
|
lb_server_key: {file: ./secrets/pki/lb-server.key}
|
|
lb_client_crt: {file: ./secrets/pki/lb-client.crt}
|
|
lb_client_key: {file: ./secrets/pki/lb-client.key}
|
|
api_1_crt: {file: ./secrets/pki/api-1.crt}
|
|
api_1_key: {file: ./secrets/pki/api-1.key}
|
|
api_2_crt: {file: ./secrets/pki/api-2.crt}
|
|
api_2_key: {file: ./secrets/pki/api-2.key}
|
|
api_client_crt: {file: ./secrets/pki/api.crt}
|
|
api_client_key: {file: ./secrets/pki/api.key}
|
|
worker_client_crt: {file: ./secrets/pki/worker.crt}
|
|
worker_client_key: {file: ./secrets/pki/worker.key}
|
|
api_otel_crt: {file: ./secrets/pki/api-otel.crt}
|
|
api_otel_key: {file: ./secrets/pki/api-otel.key}
|
|
worker_otel_crt: {file: ./secrets/pki/worker-otel.crt}
|
|
worker_otel_key: {file: ./secrets/pki/worker-otel.key}
|
|
postgres_crt: {file: ./secrets/pki/postgres.crt}
|
|
postgres_key: {file: ./secrets/pki/postgres.key}
|
|
minio_crt: {file: ./secrets/pki/minio.crt}
|
|
minio_key: {file: ./secrets/pki/minio.key}
|
|
rabbitmq_crt: {file: ./secrets/pki/rabbitmq.crt}
|
|
rabbitmq_key: {file: ./secrets/pki/rabbitmq.key}
|
|
valkey_crt: {file: ./secrets/pki/valkey.crt}
|
|
valkey_key: {file: ./secrets/pki/valkey.key}
|
|
openbao_crt: {file: ./secrets/pki/openbao.crt}
|
|
openbao_key: {file: ./secrets/pki/openbao.key}
|
|
otel_collector_crt: {file: ./secrets/pki/otel-collector.crt}
|
|
otel_collector_key: {file: ./secrets/pki/otel-collector.key}
|
|
collector_out_crt: {file: ./secrets/pki/collector-out.crt}
|
|
collector_out_key: {file: ./secrets/pki/collector-out.key}
|
|
prometheus_crt: {file: ./secrets/pki/prometheus.crt}
|
|
prometheus_key: {file: ./secrets/pki/prometheus.key}
|
|
loki_crt: {file: ./secrets/pki/loki.crt}
|
|
loki_key: {file: ./secrets/pki/loki.key}
|
|
tempo_crt: {file: ./secrets/pki/tempo.crt}
|
|
tempo_key: {file: ./secrets/pki/tempo.key}
|
|
grafana_crt: {file: ./secrets/pki/grafana.crt}
|
|
grafana_key: {file: ./secrets/pki/grafana.key}
|
|
grafana_out_crt: {file: ./secrets/pki/grafana-out.crt}
|
|
grafana_out_key: {file: ./secrets/pki/grafana-out.key}
|
|
operator_crt: {file: ./secrets/pki/operator.crt}
|
|
operator_key: {file: ./secrets/pki/operator.key}
|
|
postgres_password: {file: ./secrets/bootstrap/postgres_password}
|
|
migrate_database_url: {file: ./secrets/bootstrap/migrate_database_url}
|
|
db_api_password: {file: ./secrets/bootstrap/db_api_password}
|
|
db_worker_password: {file: ./secrets/bootstrap/db_worker_password}
|
|
minio_root_user: {file: ./secrets/bootstrap/minio_root_user}
|
|
minio_root_password: {file: ./secrets/bootstrap/minio_root_password}
|
|
s3_api_access_key: {file: ./secrets/bootstrap/s3_api_access_key}
|
|
s3_api_secret_key: {file: ./secrets/bootstrap/s3_api_secret_key}
|
|
s3_worker_access_key: {file: ./secrets/bootstrap/s3_worker_access_key}
|
|
s3_worker_secret_key: {file: ./secrets/bootstrap/s3_worker_secret_key}
|
|
valkey_api_password: {file: ./secrets/bootstrap/valkey_api_password}
|
|
grafana_admin_password: {file: ./secrets/bootstrap/grafana_admin_password}
|