forked from mtusi2026/mtusi2026lab7
lab7: TLS ко всем зависимостям и телеметрии; раздельные роли PostgreSQL (GRANT по коду), ACL Valkey, AMQPS, HTTPS S3, mTLS Collector/Prometheus/Loki/Tempo/Grafana
This commit is contained in:
@@ -1047,7 +1047,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "rate(otelcol_process_cpu_seconds[$__rate_interval])",
|
||||
"expr": "rate(otelcol_process_cpu_seconds_total[$__rate_interval])",
|
||||
"legendFormat": "otel-collector",
|
||||
"range": true
|
||||
}
|
||||
@@ -1112,7 +1112,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "otelcol_process_memory_rss",
|
||||
"expr": "otelcol_process_memory_rss_bytes",
|
||||
"legendFormat": "otel-collector RSS",
|
||||
"range": true
|
||||
}
|
||||
@@ -1445,7 +1445,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"description": "otelcol_* self-metrics, scraped from :8888. sent < accepted with tail sampling (dropped by policy).\n\nUnit: ops.",
|
||||
"description": "otelcol_* self-metrics, pushed over OTLP/HTTPS (lab 7). sent < accepted with tail sampling (dropped by policy).\n\nUnit: ops.",
|
||||
"gridPos": {
|
||||
"h": 8,
|
||||
"w": 8,
|
||||
@@ -1486,7 +1486,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_spans[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_spans_total[$__rate_interval]))",
|
||||
"legendFormat": "accepted",
|
||||
"range": true
|
||||
},
|
||||
@@ -1496,7 +1496,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_receiver_refused_spans[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_receiver_refused_spans_total[$__rate_interval]))",
|
||||
"legendFormat": "refused (memory_limiter)",
|
||||
"range": true
|
||||
},
|
||||
@@ -1506,7 +1506,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_exporter_sent_spans[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_exporter_sent_spans_total[$__rate_interval]))",
|
||||
"legendFormat": "sent to Tempo",
|
||||
"range": true
|
||||
},
|
||||
@@ -1516,7 +1516,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_spans[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_spans_total[$__rate_interval]))",
|
||||
"legendFormat": "send failed (dropped)",
|
||||
"range": true
|
||||
}
|
||||
@@ -1571,7 +1571,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_log_records[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_log_records_total[$__rate_interval]))",
|
||||
"legendFormat": "logs accepted",
|
||||
"range": true
|
||||
},
|
||||
@@ -1581,7 +1581,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_log_records[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_log_records_total[$__rate_interval]))",
|
||||
"legendFormat": "logs failed",
|
||||
"range": true
|
||||
},
|
||||
@@ -1591,7 +1591,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_metric_points[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_receiver_accepted_metric_points_total[$__rate_interval]))",
|
||||
"legendFormat": "metric points accepted",
|
||||
"range": true
|
||||
},
|
||||
@@ -1601,7 +1601,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_metric_points[$__rate_interval]))",
|
||||
"expr": "sum(rate(otelcol_exporter_send_failed_metric_points_total[$__rate_interval]))",
|
||||
"legendFormat": "metric points failed",
|
||||
"range": true
|
||||
}
|
||||
@@ -1787,7 +1787,7 @@
|
||||
"type": "prometheus",
|
||||
"uid": "prometheus"
|
||||
},
|
||||
"expr": "up{job=~\"otel-collector|prometheus|loki|tempo|grafana\"}",
|
||||
"expr": "up{job=~\"prometheus|loki|tempo\"}",
|
||||
"legendFormat": "{{job}}",
|
||||
"range": true
|
||||
}
|
||||
|
||||
@@ -2,6 +2,10 @@
|
||||
# the dashboard JSON, the trace->logs and logs->trace links refer to exactly these UIDs
|
||||
# (prometheus / loki / tempo). A datasource without a fixed uid gets a random one and every
|
||||
# reference to it breaks ("data source not found").
|
||||
# Lab 7: every datasource is HTTPS with server verification (internal CA, serverName = the SAN)
|
||||
# and Grafana's own client certificate (SAN grafana): the three backends require one, Prometheus
|
||||
# also checks the SAN allowlist. The PEM files are read at provisioning time ($__file{}), from
|
||||
# Docker secrets mounted only into Grafana.
|
||||
apiVersion: 1
|
||||
|
||||
deleteDatasources:
|
||||
@@ -14,10 +18,17 @@ datasources:
|
||||
uid: prometheus
|
||||
type: prometheus
|
||||
access: proxy
|
||||
url: http://prometheus:9090
|
||||
url: https://prometheus:9090
|
||||
isDefault: true
|
||||
editable: false
|
||||
secureJsonData: &tls_files
|
||||
tlsCACert: $__file{/run/secrets/internal-ca.crt}
|
||||
tlsClientCert: $__file{/run/secrets/grafana.crt}
|
||||
tlsClientKey: $__file{/run/secrets/grafana.key}
|
||||
jsonData:
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
serverName: prometheus
|
||||
httpMethod: POST
|
||||
timeInterval: 15s # = scrape/evaluation interval: $__rate_interval >= 4 x 15 s
|
||||
prometheusType: Prometheus
|
||||
@@ -29,9 +40,13 @@ datasources:
|
||||
uid: loki
|
||||
type: loki
|
||||
access: proxy
|
||||
url: http://loki:3100
|
||||
url: https://loki:3100
|
||||
editable: false
|
||||
secureJsonData: *tls_files
|
||||
jsonData:
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
serverName: loki
|
||||
maxLines: 1000
|
||||
# log line -> its trace in Tempo (trace_id is structured metadata of the OTLP record)
|
||||
derivedFields:
|
||||
@@ -46,9 +61,13 @@ datasources:
|
||||
uid: tempo
|
||||
type: tempo
|
||||
access: proxy
|
||||
url: http://tempo:3200
|
||||
url: https://tempo:3200
|
||||
editable: false
|
||||
secureJsonData: *tls_files
|
||||
jsonData:
|
||||
tlsAuth: true
|
||||
tlsAuthWithCACert: true
|
||||
serverName: tempo
|
||||
# span -> the log records of the same trace (and service) in Loki
|
||||
tracesToLogsV2:
|
||||
datasourceUid: loki
|
||||
|
||||
@@ -12,7 +12,15 @@ auth_enabled: false
|
||||
server:
|
||||
http_listen_port: 3100
|
||||
grpc_listen_port: 9096
|
||||
grpc_listen_address: 127.0.0.1
|
||||
log_level: warn
|
||||
# Lab 7: HTTPS + mandatory client certificate of the internal CA (otel-collector pushes,
|
||||
# grafana queries, prometheus scrapes). gRPC is internal to the single binary: loopback only.
|
||||
http_tls_config:
|
||||
cert_file: /run/secrets/loki.crt
|
||||
key_file: /run/secrets/loki.key
|
||||
client_auth_type: RequireAndVerifyClientCert
|
||||
client_ca_file: /run/secrets/internal-ca.crt
|
||||
|
||||
common:
|
||||
instance_addr: 127.0.0.1
|
||||
|
||||
+42
-20
@@ -1,24 +1,29 @@
|
||||
# OpenTelemetry Collector (otel/opentelemetry-collector-contrib 0.165.0), lab 6.
|
||||
# OpenTelemetry Collector (otel/opentelemetry-collector-contrib 0.165.0), labs 6-7.
|
||||
#
|
||||
# API x2 / relay / worker --OTLP/HTTP protobuf :4318--> [receiver otlp]
|
||||
# -> memory_limiter -> batch -> exporters:
|
||||
# traces -> Tempo (otlp_http/tempo, http://tempo:4318/v1/traces)
|
||||
# metrics -> Prometheus (otlp_http/prometheus, http://prometheus:9090/api/v1/otlp/v1/metrics)
|
||||
# logs -> Loki (otlp_http/loki, http://loki:3100/otlp/v1/logs)
|
||||
# API x2 / relay / worker --OTLP/HTTPS (mTLS) :4318--> [receiver otlp]
|
||||
# -> memory_limiter -> batch -> exporters (all HTTPS + client certificate otel-collector):
|
||||
# traces -> Tempo (otlp_http/tempo, https://tempo:4318/v1/traces)
|
||||
# metrics -> Prometheus (otlp_http/prometheus, https://prometheus:9090/api/v1/otlp/v1/metrics)
|
||||
# logs -> Loki (otlp_http/loki, https://loki:3100/otlp/v1/logs)
|
||||
#
|
||||
# Lab 7 (contracts/trust-matrix.md): the receiver speaks TLS only and REQUIRES a client certificate
|
||||
# of the internal CA (client_ca_file): a process on the `telemetry` network without such a
|
||||
# certificate cannot ingest anything. Every exporter verifies the backend (internal CA + hostname)
|
||||
# and authenticates with the Collector's own certificate (SAN otel-collector); Prometheus also
|
||||
# checks that SAN against its allowlist.
|
||||
# The Collector stores nothing for long: it receives, limits, batches and forwards. When a backend
|
||||
# is down, each exporter keeps a BOUNDED queue (sending_queue) and retries for at most
|
||||
# max_elapsed_time; then the data is dropped and counted (otelcol_exporter_send_failed_*,
|
||||
# otelcol_exporter_enqueue_failed_*). memory_limiter refuses new data above its limit (the SDKs
|
||||
# get a retryable error and drop after their own bounded queue) instead of growing until OOM.
|
||||
# Its own metrics: Prometheus scrapes :8888 (otelcol_*). Only on the internal `telemetry` network.
|
||||
# otelcol_exporter_enqueue_failed_*). memory_limiter refuses new data above its limit.
|
||||
# Its own metrics: PUSHED over OTLP/HTTPS to Prometheus (lab 7; the lab 6 pull endpoint :8888 had no
|
||||
# TLS). health_check listens on the container's loopback only.
|
||||
#
|
||||
# Traces pipeline variants (track 1, docs/TRACK1.md): this file keeps EVERY span; the overlay
|
||||
# Traces pipeline variants (lab 6 track 1): this file keeps EVERY span; the overlay
|
||||
# traces-tail.yaml (passed as a second --config, compose OTEL_COLLECTOR_TRACES) adds tail sampling.
|
||||
|
||||
extensions:
|
||||
health_check:
|
||||
endpoint: 0.0.0.0:13133
|
||||
endpoint: 127.0.0.1:13133
|
||||
|
||||
receivers:
|
||||
otlp:
|
||||
@@ -26,11 +31,15 @@ receivers:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
max_request_body_size: 8388608 # 8 MiB per export request
|
||||
tls:
|
||||
cert_file: /run/secrets/otel-collector.crt
|
||||
key_file: /run/secrets/otel-collector.key
|
||||
client_ca_file: /run/secrets/internal-ca.crt # = RequireAndVerifyClientCert
|
||||
min_version: "1.2"
|
||||
|
||||
processors:
|
||||
# First in every pipeline. Container limit 512 MiB: soft limit = 400 - 80 = 320 MiB (start
|
||||
# refusing + GC), hard limit 400 MiB (forced GC). The contrib binary alone is ~150 MiB RSS;
|
||||
# 256 MiB of container memory left the limiter refusing data at idle. GOMEMLIMIT = 360 MiB.
|
||||
# refusing + GC), hard limit 400 MiB (forced GC). The contrib binary alone is ~150 MiB RSS.
|
||||
memory_limiter:
|
||||
check_interval: 1s
|
||||
limit_mib: 400
|
||||
@@ -43,8 +52,13 @@ processors:
|
||||
|
||||
exporters:
|
||||
otlp_http/tempo:
|
||||
endpoint: http://tempo:4318
|
||||
endpoint: https://tempo:4318
|
||||
timeout: 5s
|
||||
tls: &mtls
|
||||
ca_file: /run/secrets/internal-ca.crt
|
||||
cert_file: /run/secrets/otel-collector.crt
|
||||
key_file: /run/secrets/otel-collector.key
|
||||
min_version: "1.2"
|
||||
sending_queue: &queue
|
||||
enabled: true
|
||||
num_consumers: 2
|
||||
@@ -55,29 +69,37 @@ exporters:
|
||||
max_interval: 10s
|
||||
max_elapsed_time: 60s # then the batch is dropped (counted), never retried forever
|
||||
otlp_http/prometheus:
|
||||
endpoint: http://prometheus:9090/api/v1/otlp
|
||||
endpoint: https://prometheus:9090/api/v1/otlp
|
||||
timeout: 5s
|
||||
tls: *mtls
|
||||
sending_queue: *queue
|
||||
retry_on_failure: *retry
|
||||
otlp_http/loki:
|
||||
endpoint: http://loki:3100/otlp
|
||||
endpoint: https://loki:3100/otlp
|
||||
timeout: 5s
|
||||
tls: *mtls
|
||||
sending_queue: *queue
|
||||
retry_on_failure: *retry
|
||||
|
||||
service:
|
||||
extensions: [health_check]
|
||||
telemetry:
|
||||
resource:
|
||||
service.name: otel-collector
|
||||
logs:
|
||||
level: warn
|
||||
metrics:
|
||||
level: normal
|
||||
readers:
|
||||
- pull:
|
||||
- periodic:
|
||||
interval: 15000
|
||||
exporter:
|
||||
prometheus:
|
||||
host: 0.0.0.0
|
||||
port: 8888
|
||||
otlp:
|
||||
protocol: http/protobuf
|
||||
endpoint: https://prometheus:9090/api/v1/otlp/v1/metrics
|
||||
certificate: /run/secrets/internal-ca.crt
|
||||
client_certificate: /run/secrets/otel-collector.crt
|
||||
client_key: /run/secrets/otel-collector.key
|
||||
pipelines:
|
||||
traces:
|
||||
receivers: [otlp]
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
#!/bin/sh
|
||||
# Runs ONCE, when the volume pgdata is initialised (docker-entrypoint-initdb.d), as OS user postgres
|
||||
# over the local socket. Creates one login role per service; the passwords come from Docker secret
|
||||
# files and are passed to psql as variables (never on a command line, never printed).
|
||||
# messenger_migrate owns the database objects (applies migrations, service `migrate`)
|
||||
# messenger_api / messenger_relay / messenger_worker GRANTs in migrations/0007_least_privilege.sql
|
||||
# messenger_jobctl / messenger_auditor operator tools (profile tools)
|
||||
# Nobody but `postgres` (no network login, see pg_hba.conf) is a superuser.
|
||||
set -eu
|
||||
for role in migrate api relay worker jobctl auditor; do
|
||||
pw="$(tr -d '\r\n' < "/run/secrets/pg_${role}_password")"
|
||||
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres -v role="messenger_${role}" -v pw="$pw" <<'SQL'
|
||||
CREATE ROLE :"role" LOGIN PASSWORD :'pw' NOSUPERUSER NOCREATEDB NOCREATEROLE NOREPLICATION;
|
||||
SQL
|
||||
done
|
||||
psql -v ON_ERROR_STOP=1 --username postgres --dbname postgres <<'SQL'
|
||||
ALTER DATABASE messenger OWNER TO messenger_migrate;
|
||||
-- Only the service roles may connect to the application database.
|
||||
REVOKE ALL ON DATABASE messenger FROM PUBLIC;
|
||||
GRANT CONNECT ON DATABASE messenger TO messenger_migrate, messenger_api, messenger_relay, messenger_worker,
|
||||
messenger_jobctl, messenger_auditor;
|
||||
SQL
|
||||
psql -v ON_ERROR_STOP=1 --username postgres --dbname messenger <<'SQL'
|
||||
-- PostgreSQL 15+: schema public belongs to pg_database_owner (= messenger_migrate now), and
|
||||
-- PUBLIC has no CREATE on it. Make it explicit: only the owner creates objects.
|
||||
REVOKE CREATE ON SCHEMA public FROM PUBLIC;
|
||||
GRANT USAGE ON SCHEMA public TO messenger_api, messenger_relay, messenger_worker, messenger_jobctl, messenger_auditor;
|
||||
SQL
|
||||
echo "initdb: service roles created"
|
||||
@@ -0,0 +1,18 @@
|
||||
# PostgreSQL client authentication, lab 7 (passed with -c hba_file=..., compose service postgres).
|
||||
# First matching line wins.
|
||||
#
|
||||
# Unix socket inside the container only (docker compose exec): the superuser `postgres` by peer
|
||||
# (OS user postgres), everyone else by password. initdb scripts and the operator use this path.
|
||||
# TYPE DATABASE USER ADDRESS METHOD
|
||||
local all postgres peer
|
||||
local all all scram-sha-256
|
||||
# Network: TLS ONLY and only the service roles, password = SCRAM. The superuser never logs in
|
||||
# over the network. Clients verify the server with sslmode=verify-full (internal CA, SAN postgres).
|
||||
hostssl messenger messenger_migrate all scram-sha-256
|
||||
hostssl messenger messenger_api all scram-sha-256
|
||||
hostssl messenger messenger_relay all scram-sha-256
|
||||
hostssl messenger messenger_worker all scram-sha-256
|
||||
hostssl messenger messenger_jobctl all scram-sha-256
|
||||
hostssl messenger messenger_auditor all scram-sha-256
|
||||
# Everything else - any plaintext connection, any other role/database - is refused.
|
||||
host all all all reject
|
||||
@@ -1,11 +1,15 @@
|
||||
# Prometheus 3.16 (prom/prometheus:v3.16.0), lab 6: the METRICS store.
|
||||
# Prometheus 3.16 (prom/prometheus:v3.16.0), labs 6-7: the METRICS store.
|
||||
#
|
||||
# Application metrics are PUSHED by the Collector over OTLP (flag --web.enable-otlp-receiver,
|
||||
# endpoint /api/v1/otlp/v1/metrics). Prometheus derives `job` = service.name and
|
||||
# `instance` = service.instance.id from the OTLP resource, and translates the OTel names with
|
||||
# suffixes: http.server.request.duration (unit s) -> http_server_request_duration_seconds_bucket,
|
||||
# messenger.jobs.processed -> messenger_jobs_processed_total (mapping: docs/OBSERVABILITY.md).
|
||||
# The telemetry components themselves are SCRAPED (pull) below.
|
||||
# Application metrics AND the Collector's own metrics are PUSHED by the Collector over OTLP/HTTPS
|
||||
# (flag --web.enable-otlp-receiver, endpoint /api/v1/otlp/v1/metrics). Prometheus derives
|
||||
# `job` = service.name and `instance` = service.instance.id from the OTLP resource, and translates
|
||||
# the OTel names with suffixes: http.server.request.duration (unit s) ->
|
||||
# http_server_request_duration_seconds_bucket (mapping: docs/OBSERVABILITY.md).
|
||||
#
|
||||
# Lab 7: the web listener is HTTPS with a REQUIRED client certificate of the internal CA and a SAN
|
||||
# allowlist (web-config.yml): only otel-collector (push), grafana (queries) and prometheus itself
|
||||
# (self-scrape, promtool healthcheck) get in. Scrapes of Loki/Tempo use HTTPS + this server's
|
||||
# own client certificate (they require one too).
|
||||
global:
|
||||
scrape_interval: 15s
|
||||
evaluation_interval: 15s # alert rules: detection delay = condition + `for` + <= 15 s
|
||||
@@ -24,13 +28,19 @@ rule_files:
|
||||
- /etc/prometheus/rules/*.yml
|
||||
|
||||
scrape_configs:
|
||||
- job_name: otel-collector # otelcol_* : accepted/refused/sent/failed, queue size, RSS
|
||||
static_configs: [{targets: ["otel-collector:8888"]}]
|
||||
- job_name: prometheus
|
||||
scheme: https
|
||||
tls_config: &mtls
|
||||
ca_file: /run/secrets/internal-ca.crt
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
min_version: TLS12
|
||||
static_configs: [{targets: ["localhost:9090"]}]
|
||||
- job_name: loki
|
||||
scheme: https
|
||||
tls_config: *mtls
|
||||
static_configs: [{targets: ["loki:3100"]}]
|
||||
- job_name: tempo
|
||||
scheme: https
|
||||
tls_config: *mtls
|
||||
static_configs: [{targets: ["tempo:3200"]}]
|
||||
- job_name: grafana
|
||||
static_configs: [{targets: ["grafana:3000"]}]
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# HTTP client config of the container healthcheck (`promtool check healthy`): the same mTLS as any
|
||||
# other client - Prometheus' own client certificate (SAN prometheus, in the allowlist).
|
||||
tls_config:
|
||||
ca_file: /run/secrets/internal-ca.crt
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
server_name: localhost
|
||||
@@ -78,9 +78,9 @@ groups:
|
||||
# in its bounded queue and then dropped. The application itself is not affected.
|
||||
expr: |
|
||||
sum by (exporter) (
|
||||
rate(otelcol_exporter_send_failed_spans[2m])
|
||||
or rate(otelcol_exporter_send_failed_log_records[2m])
|
||||
or rate(otelcol_exporter_send_failed_metric_points[2m])
|
||||
rate(otelcol_exporter_send_failed_spans_total[2m])
|
||||
or rate(otelcol_exporter_send_failed_log_records_total[2m])
|
||||
or rate(otelcol_exporter_send_failed_metric_points_total[2m])
|
||||
) > 0
|
||||
for: 30s
|
||||
labels:
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
# Prometheus web listener (--web.config.file), lab 7: HTTPS + mandatory client certificate of the
|
||||
# internal CA + allowlist of client identities (SAN). A certificate of the same CA with another
|
||||
# name (api, worker, loki, ...) is refused in the TLS handshake.
|
||||
tls_server_config:
|
||||
cert_file: /run/secrets/prometheus.crt
|
||||
key_file: /run/secrets/prometheus.key
|
||||
client_auth_type: RequireAndVerifyClientCert
|
||||
client_ca_file: /run/secrets/internal-ca.crt
|
||||
client_allowed_sans: [otel-collector, grafana, prometheus]
|
||||
min_version: TLS12
|
||||
@@ -1,7 +1,18 @@
|
||||
# RabbitMQ 4.3 of the lab 5 stand (compose service `broker`), mounted as conf.d/20-lab5.conf.
|
||||
# Only AMQP 0-9-1 on 5672 inside the internal network `queue`: no management UI, no Prometheus
|
||||
# listener (enabled_plugins is empty), nothing published on the host.
|
||||
listeners.tcp.default = 5672
|
||||
# RabbitMQ 4.3 of the stand (compose service `broker`), mounted as conf.d/20-lab.conf.
|
||||
# Lab 7: AMQP 0-9-1 over TLS ONLY (amqps, 5671) inside the internal network `queue`. The plaintext
|
||||
# listener is off, there is no management UI and no Prometheus listener (enabled_plugins is
|
||||
# empty), nothing is published on the host. Clients verify the server certificate (internal CA,
|
||||
# SAN broker); their identity is the user relay / worker with its own permissions (grade 3: no
|
||||
# client certificates; mTLS to the broker is grade 4).
|
||||
listeners.tcp = none
|
||||
listeners.ssl.default = 5671
|
||||
ssl_options.cacertfile = /run/secrets/internal-ca.crt
|
||||
ssl_options.certfile = /run/secrets/broker.crt
|
||||
ssl_options.keyfile = /run/secrets/broker.key
|
||||
ssl_options.verify = verify_none
|
||||
ssl_options.fail_if_no_peer_cert = false
|
||||
ssl_options.versions.1 = tlsv1.3
|
||||
ssl_options.versions.2 = tlsv1.2
|
||||
|
||||
# Users, permissions and topology are imported from files at every boot (idempotent):
|
||||
# /etc/rabbitmq/definitions.d/topology.json exchanges, quorum queues, bindings (this repo)
|
||||
|
||||
@@ -14,6 +14,9 @@
|
||||
# Exposure: master (9333), volume (8080), filer (8888) with their web UIs and gRPC listen on
|
||||
# 127.0.0.1 INSIDE the container only (-ip.bind); only the S3 API port 8333 listens on the
|
||||
# container network `storage` (internal, not published on the host). Telemetry is off.
|
||||
# Lab 7: the S3 port speaks HTTPS only (-s3.cert.file/-s3.key.file: internal CA, SAN s3); the
|
||||
# clients verify chain + hostname (aiobotocore verify=TLS_CA_FILE). The plaintext master/volume/filer
|
||||
# hops stay on the container's own loopback (closed local hop, not reachable from the network).
|
||||
set -eu
|
||||
umask 077
|
||||
secret() { tr -d '\r\n' < "/run/secrets/$1"; }
|
||||
@@ -49,4 +52,5 @@ exec weed server \
|
||||
-filer -filer.disableDirListing -filer.concurrentUploadLimitMB=128 \
|
||||
-volume.concurrentUploadLimitMB=128 \
|
||||
-s3 -s3.ip.bind=0.0.0.0 -s3.port=8333 -s3.config=/tmp/s3.json -s3.concurrentUploadLimitMB=128 \
|
||||
-s3.cert.file=/run/secrets/s3.crt -s3.key.file=/run/secrets/s3.key \
|
||||
-s3.iam=false -s3.autoCreateBucket=false -s3.port.iceberg=0 -s3.port.lance=0
|
||||
|
||||
@@ -6,7 +6,15 @@ stream_over_http_enabled: true
|
||||
|
||||
server:
|
||||
http_listen_port: 3200
|
||||
grpc_listen_address: 127.0.0.1
|
||||
log_level: warn
|
||||
# Lab 7: HTTPS + mandatory client certificate of the internal CA (otel-collector pushes,
|
||||
# grafana queries, prometheus scrapes). gRPC is internal to the single binary: loopback only.
|
||||
http_tls_config:
|
||||
cert_file: /run/secrets/tempo.crt
|
||||
key_file: /run/secrets/tempo.key
|
||||
client_auth_type: RequireAndVerifyClientCert
|
||||
client_ca_file: /run/secrets/internal-ca.crt
|
||||
|
||||
distributor:
|
||||
receivers:
|
||||
@@ -14,6 +22,11 @@ distributor:
|
||||
protocols:
|
||||
http:
|
||||
endpoint: 0.0.0.0:4318
|
||||
tls: # only the Collector (client certificate of the internal CA)
|
||||
cert_file: /run/secrets/tempo.crt
|
||||
key_file: /run/secrets/tempo.key
|
||||
client_ca_file: /run/secrets/internal-ca.crt
|
||||
min_version: "1.2"
|
||||
|
||||
ingester:
|
||||
max_block_duration: 5m # small blocks: a restart loses at most the WAL replay time
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
#!/bin/sh
|
||||
# Entry point of the compose service `valkey` (lab 7). Writes the ACL file from the Docker secret and
|
||||
# starts Valkey through the image's entrypoint (which drops root to the valkey user).
|
||||
# user default off no anonymous/shared-password access at all
|
||||
# user api SHA-256 of its password only (the plain password never lands in a file here),
|
||||
# keys session:* (sessions.py) and ratelimit:* (login limit), commands it uses:
|
||||
# GET/SET/DEL (sessions), INCR/PEXPIRE/PTTL in MULTI/EXEC (rate limit), PING
|
||||
# (readiness), CLIENT SETINFO (sent by redis-py on connect). FLUSHALL, CONFIG,
|
||||
# KEYS, DEBUG, ACL, ... are refused with NOPERM.
|
||||
set -eu
|
||||
umask 077
|
||||
mkdir -p /tmp/valkey
|
||||
hash="$(tr -d '\r\n' < /run/secrets/valkey_api_password | sha256sum | cut -d' ' -f1)"
|
||||
printf 'user default off\n' > /tmp/valkey/users.acl
|
||||
printf 'user api on #%s resetkeys ~session:* ~ratelimit:* resetchannels -@all +get +set +del +incr +pexpire +pttl +multi +exec +discard +ping +client|setinfo\n' \
|
||||
"$hash" >> /tmp/valkey/users.acl
|
||||
chown -R valkey /tmp/valkey
|
||||
exec docker-entrypoint.sh valkey-server /etc/valkey/valkey.conf
|
||||
@@ -8,10 +8,20 @@ appenddirname "appendonlydir"
|
||||
# RDB snapshots are not needed on top of AOF.
|
||||
save ""
|
||||
dir /data
|
||||
port 6379
|
||||
protected-mode yes
|
||||
# Lab 7: TLS only. The plaintext port is closed (port 0); clients verify the server certificate
|
||||
# (internal CA, SAN valkey). No client certificates at grade 3 (tls-auth-clients no): the client
|
||||
# identity is the ACL user + password below.
|
||||
port 0
|
||||
tls-port 6379
|
||||
tls-cert-file /run/secrets/valkey.crt
|
||||
tls-key-file /run/secrets/valkey.key
|
||||
tls-ca-cert-file /run/secrets/internal-ca.crt
|
||||
tls-auth-clients no
|
||||
tls-protocols "TLSv1.2 TLSv1.3"
|
||||
# Sessions are never evicted silently: if memory is full, writes fail and login returns 503.
|
||||
maxmemory 128mb
|
||||
maxmemory-policy noeviction
|
||||
# Password, generated by scripts/init_secrets.py and written here at container start.
|
||||
include /tmp/requirepass.conf
|
||||
# Lab 7: ACL users instead of one shared password (file written by infra/valkey/start.sh at start):
|
||||
# `default` is off, `api` may touch only session:* / ratelimit:* keys with the commands it uses.
|
||||
aclfile /tmp/valkey/users.acl
|
||||
|
||||
Reference in New Issue
Block a user