This commit is contained in:
+22
-4
@@ -1,7 +1,25 @@
|
||||
# Инфраструктура студента
|
||||
# Инфраструктура lab7
|
||||
|
||||
Здесь разместите конфигурации выбранных сервисов; основную топологию — в корневом compose.yaml/stack.yaml. `compose.example.yaml` — только worksheet ролей и намеренно не запускается. `contracts/infrastructure.json` задаёт минимальные роли, не готовые образы/пароли.
|
||||
Топология и параметры — в корневом compose.yaml. Секреты в Git не хранятся.
|
||||
|
||||
В REPORT.md сопоставьте роль → service name → версия/digest → health/readiness → volume → сеть/порт → способ передачи credentials. Приведите bootstrap (schema, bucket, broker topology, а с lab6 provisioning) и безопасное повторение этих команд.
|
||||
| Role | Service | Version | Health | Volume | Network / port | Credentials |
|
||||
| --- | --- | --- | --- | --- | --- | --- |
|
||||
| load_balancer | traefik | v3.5.4 | TCP 8443 | - | edge / 127.0.0.1:8443 | public + lb-client leaf |
|
||||
| api x2 | api | local 7.0.0 | /health/live and Traefik /health/ready via mTLS | - | edge, app, data / none | AppRole api -> DB/S3/broker |
|
||||
| worker | worker | local 7.0.0 | worker_health heartbeat | - | app, data / none | AppRole worker |
|
||||
| relay | relay | local 7.0.0 | worker_health heartbeat | - | app, data / none | AppRole relay |
|
||||
| postgres | postgres | 16.15 | pg_isready | pgdata | data / none | bootstrap superuser + app roles |
|
||||
| s3 | minio | digest 14cea493 | https health/live | miniodata | data / none | root only minio-init; scoped users |
|
||||
| broker | rabbitmq | 4.1.4 | diagnostics ping | rabbitmqdata | broker / none | root bootstrap; api/worker users |
|
||||
| mtls gateway | internal-gateway | local 7.0.0 | TCP 5671 | - | app, broker, otelnet / none | gateway leaf + client |
|
||||
| otel_collector | otel-collector | 0.140.0 | health_check 13133 | - | otelnet, telemetry, collectorscrape / none | telemetry-client |
|
||||
| telemetry_storage | prometheus/loki/tempo | 3.7.3 / 3.6.2 / 2.9.0 | Prometheus health | promdata/lokidata/tempodata | private + telemetry / none | mTLS sidecars |
|
||||
| grafana | grafana | 12.2.0 | HTTPS /api/health | grafanadata | telemetry, admin / 127.0.0.1:3000 | admin secret + grafana-client |
|
||||
| openbao | openbao | 2.3.2 | /v1/sys/init | openbaodata | data, admin / 127.0.0.1:8200 | AppRole; root/unseal operator only |
|
||||
|
||||
Приложение строится из исходников. Не используйте заранее существующий образ преподавательского сервера вместо своей реализации. Restart hook перезапускает все соответствующие stores с volumes; failover hook останавливает только заданную API-реплику.
|
||||
Bootstrap: scripts/bootstrap-certs.sh, bootstrap-secrets.sh, db-init.sh (roles
|
||||
before migrations, grants after), minio-init.sh, openbao_bootstrap.py
|
||||
(container openbao-bootstrap), bootstrap-rabbit.sh. Restart/failover:
|
||||
scripts/restart.sh and scripts/stop-one.sh; volumes are not removed.
|
||||
Stateful PostgreSQL/MinIO/RabbitMQ are an explained exception from
|
||||
read_only/cap_drop: they need writable volumes and image capabilities.
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"cert_file": "/certs/api-server.crt",
|
||||
"key_file": "/certs/api-server.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8081,
|
||||
"allow_san": ["lb.messenger.internal"],
|
||||
"backend_host": "127.0.0.1",
|
||||
"backend_port": 8080,
|
||||
"backend_tls": false,
|
||||
"reject_mode": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
{
|
||||
"cert_file": "/certs/collector-tls.crt",
|
||||
"key_file": "/certs/collector-tls.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8889,
|
||||
"allow_san": ["prometheus.messenger.internal"],
|
||||
"backend_host": "otel-collector",
|
||||
"backend_port": 8889,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"reject_mode": "http"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8888,
|
||||
"allow_san": ["prometheus.messenger.internal"],
|
||||
"backend_host": "otel-collector",
|
||||
"backend_port": 8888,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"reject_mode": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
{
|
||||
"cert_file": "/certs/gateway-server.crt",
|
||||
"key_file": "/certs/gateway-server.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"revoked_serials_file": "/certs/revoked-serials.txt",
|
||||
"backend_ca_file": "/certs/ca.crt",
|
||||
"backend_cert_file": "/certs/gateway-client.crt",
|
||||
"backend_key_file": "/certs/gateway-client.key",
|
||||
"backend_server_name": "rabbitmq",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 5671,
|
||||
"allow_san": ["api.messenger.internal", "relay.messenger.internal"],
|
||||
"backend_host": "rabbitmq",
|
||||
"backend_port": 5671,
|
||||
"backend_tls": true,
|
||||
"reject_mode": "close"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 5672,
|
||||
"allow_san": ["worker.messenger.internal"],
|
||||
"backend_host": "rabbitmq",
|
||||
"backend_port": 5671,
|
||||
"backend_tls": true,
|
||||
"reject_mode": "close"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 4318,
|
||||
"allow_san": ["api.messenger.internal"],
|
||||
"backend_host": "otel-collector",
|
||||
"backend_port": 4318,
|
||||
"backend_tls": false,
|
||||
"reject_mode": "http"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 4319,
|
||||
"allow_san": ["worker.messenger.internal"],
|
||||
"backend_host": "otel-collector",
|
||||
"backend_port": 4318,
|
||||
"backend_tls": false,
|
||||
"reject_mode": "http"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 4320,
|
||||
"allow_san": ["relay.messenger.internal"],
|
||||
"backend_host": "otel-collector",
|
||||
"backend_port": 4318,
|
||||
"backend_tls": false,
|
||||
"reject_mode": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"cert_file": "/certs/loki-tls.crt",
|
||||
"key_file": "/certs/loki-tls.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8443,
|
||||
"allow_san": ["otel-collector.messenger.internal", "grafana.messenger.internal"],
|
||||
"backend_host": "loki",
|
||||
"backend_port": 3100,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"reject_mode": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"cert_file": "/certs/prometheus-tls.crt",
|
||||
"key_file": "/certs/prometheus-tls.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8443,
|
||||
"allow_san": ["grafana.messenger.internal"],
|
||||
"backend_host": "prometheus",
|
||||
"backend_port": 9090,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"reject_mode": "http"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
{
|
||||
"cert_file": "/certs/tempo-tls.crt",
|
||||
"key_file": "/certs/tempo-tls.key",
|
||||
"ca_file": "/certs/ca.crt",
|
||||
"listeners": [
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 8443,
|
||||
"allow_san": ["otel-collector.messenger.internal", "grafana.messenger.internal"],
|
||||
"backend_host": "tempo",
|
||||
"backend_port": 3200,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"reject_mode": "http"
|
||||
},
|
||||
{
|
||||
"bind_host": "0.0.0.0",
|
||||
"bind_port": 4317,
|
||||
"allow_san": ["otel-collector.messenger.internal"],
|
||||
"backend_host": "tempo",
|
||||
"backend_port": 4317,
|
||||
"backend_tls": false,
|
||||
"require_client_cert": true,
|
||||
"alpn": ["h2"],
|
||||
"reject_mode": "close"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,7 +1,10 @@
|
||||
# OpenBao — реализовать конфигурацию и политики
|
||||
# OpenBao — реализация
|
||||
|
||||
Добавьте non-dev конфигурацию listener/storage/TLS, API/worker policies, bootstrap и rotation scripts. Credentials и unseal material создаются локально; здесь нет готового root token или private key.
|
||||
|
||||
Решение должно показать реальную сервисную аутентификацию и получение нужного secret по ограниченной policy; просто работающий контейнер OpenBao не засчитывается. На 3 статический KV secret допустим. На 4 покажите expiry/renewal/rotation и allow/deny. Путь KV v2 data/metadata и ACL должен соответствовать фактическому mount; не копируйте широкое `path "*"` для приложения.
|
||||
|
||||
Документируйте шаги оператора init/unseal и восстановление после restart. Скрипт не должен печатать tokens/shares или хранить их в Git. См. contracts/trust-matrix.md и REPORT.md.
|
||||
- config.hcl: file storage, TLS listener, api/cluster address, no dev-mode.
|
||||
- entrypoint.sh: готовит /openbao/data владельцу openbao и запускает server.
|
||||
- bootstrap и policies: scripts/openbao_bootstrap.py (KV v2, AppRole,
|
||||
messenger-api/worker/relay). Root token и unseal shares — только в
|
||||
gitignored secrets/openbao-init.json.
|
||||
- Unseal после рестарта: scripts/restart.sh вызывает openbao-bootstrap.
|
||||
- Приложение: secrets_provider.py, AppRole login, TTL 300/900, policy только
|
||||
на свой kv/data path. Проверки — scripts/mtls_probe.py и openbao_sealed.txt.
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
# OpenBao вне dev-mode: файловое persistent storage и TLS listener.
|
||||
# Unseal выполняет оператор (scripts/bootstrap-openbao.sh / openbao_bootstrap.py),
|
||||
# root token существует только в bootstrap и не передаётся приложениям.
|
||||
ui = false
|
||||
disable_mlock = true
|
||||
api_addr = "https://openbao:8200"
|
||||
cluster_addr = "https://openbao:8201"
|
||||
|
||||
storage "file" {
|
||||
path = "/openbao/data"
|
||||
}
|
||||
|
||||
listener "tcp" {
|
||||
address = "0.0.0.0:8200"
|
||||
tls_disable = false
|
||||
tls_cert_file = "/certs/openbao.crt"
|
||||
tls_key_file = "/certs/openbao.key"
|
||||
tls_min_version = "tls12"
|
||||
}
|
||||
|
||||
telemetry {
|
||||
disable_hostname = true
|
||||
prometheus_retention_time = "24h"
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
#!/bin/sh
|
||||
# OpenBao image запускает сервер от uid 100 (openbao). Named volume создаётся
|
||||
# root-ом, поэтому каталог данных готовится здесь, до su-exec.
|
||||
set -eu
|
||||
mkdir -p /openbao/data
|
||||
chown -R openbao:openbao /openbao/data
|
||||
exec docker-entrypoint.sh server -config=/openbao/config.hcl
|
||||
+10
-6
@@ -1,7 +1,11 @@
|
||||
# Конфигурация наблюдаемости — реализовать
|
||||
# Наблюдаемость — реализация
|
||||
|
||||
Добавьте `collector.yaml` с OTLP receivers, processors и exporters выбранной версии Collector. Укажите явные bind endpoints, внутренние сети, memory limits/batch и поведение при backpressure по уровню. Сопоставьте все три pipeline с реально развёрнутыми backend.
|
||||
|
||||
Добавьте конфигурации storage, Grafana provisioning/datasources, provisioning/dashboards и импортируемые dashboard JSON. На 4 — alert rules и runbooks. Пустой dashboard или debug exporter, который только печатает данные в stdout, не заменяют хранилища/доказательства из `contracts/observability.md`.
|
||||
|
||||
Не публикуйте OTLP/metrics/административные ports в общую сеть без необходимости. В lab7 реализуйте TLS/mTLS по trust matrix; экспорт Authorization и message bodies запрещён.
|
||||
- observability/otel-collector/config.yaml: OTLP HTTP receiver, memory limiter,
|
||||
tail sampling, exporters to Tempo (mTLS) and Loki (mTLS).
|
||||
- Collector не публикует порты. internal-gateway даёт mTLS-фронт для API,
|
||||
worker и relay; collector plaintext только в изолированной lab7_otelnet.
|
||||
- Prometheus scrape -> collector-tls (mTLS, prometheus-client). Grafana ->
|
||||
prometheus-tls/loki-tls/tempo-tls с grafana-client. Sidecar-конфиги в
|
||||
infra/gateway, провижининг — observability/grafana.
|
||||
- Dashboard messenger-lab7, datasources с tlsAuth; evidence — 11-grafana.json,
|
||||
10-telemetry-leak.txt.
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
#!/bin/sh
|
||||
# Копирует TLS-материал в принадлежащий postgres каталог: PostgreSQL требует
|
||||
# key 0600 и владельца-пользователя БД. Исходники смонтированы read-only.
|
||||
set -eu
|
||||
mkdir -p /var/lib/postgresql/pgcerts
|
||||
cp /certs/postgres.crt /var/lib/postgresql/pgcerts/server.crt
|
||||
cp /certs/postgres.key /var/lib/postgresql/pgcerts/server.key
|
||||
cp /certs/ca.crt /var/lib/postgresql/pgcerts/ca.crt
|
||||
chown -R postgres:postgres /var/lib/postgresql/pgcerts
|
||||
chmod 600 /var/lib/postgresql/pgcerts/server.key
|
||||
exec docker-entrypoint.sh postgres \
|
||||
-c ssl=on \
|
||||
-c ssl_cert_file=/var/lib/postgresql/pgcerts/server.crt \
|
||||
-c ssl_key_file=/var/lib/postgresql/pgcerts/server.key \
|
||||
-c ssl_ca_file=/var/lib/postgresql/pgcerts/ca.crt \
|
||||
-c ssl_min_protocol_version=TLSv1.2 \
|
||||
-c hba_file=/etc/postgresql/pg_hba.conf
|
||||
@@ -0,0 +1,5 @@
|
||||
# Только TLS для сетевых подключений. Plaintext host-соединение отклоняется,
|
||||
# local socket нужен healthcheck-у и операторским psql внутри контейнера.
|
||||
local all all trust
|
||||
hostssl all all all scram-sha-256
|
||||
hostnossl all all all reject
|
||||
@@ -0,0 +1,13 @@
|
||||
# AMQP только через TLS 5671; plaintext listener 5672 отключён.
|
||||
# RabbitMQ проверяет клиентский сертификат (его предъявляет mTLS-шлюз) по
|
||||
# внутреннему CA. Учётные данные пользователей дополнительно ограничены
|
||||
# регулярными выражениями permissions (см. scripts/bootstrap-rabbit.sh).
|
||||
listeners.tcp = none
|
||||
listeners.ssl.default = 5671
|
||||
ssl_options.cacertfile = /certs/ca.crt
|
||||
ssl_options.certfile = /certs/rabbitmq.crt
|
||||
ssl_options.keyfile = /certs/rabbitmq.key
|
||||
ssl_options.verify = verify_peer
|
||||
ssl_options.fail_if_no_peer_cert = true
|
||||
|
||||
loopback_users = none
|
||||
@@ -0,0 +1,22 @@
|
||||
# Динамическая конфигурация Traefik: публичный сертификат и mTLS transport
|
||||
# к API-репликам. insecureSkipVerify выключен; LB предъявляет lb-client cert,
|
||||
# а API проверяет SAN lb.messenger.internal.
|
||||
http:
|
||||
serversTransports:
|
||||
api-mtls:
|
||||
serverName: api.messenger.internal
|
||||
rootCAs:
|
||||
- /certs/ca.crt
|
||||
certificates:
|
||||
- certFile: /certs/lb-client.crt
|
||||
keyFile: /certs/lb-client.key
|
||||
insecureSkipVerify: false
|
||||
tls:
|
||||
certificates:
|
||||
- certFile: /certs/public.crt
|
||||
keyFile: /certs/public.key
|
||||
stores:
|
||||
default:
|
||||
defaultCertificate:
|
||||
certFile: /certs/public.crt
|
||||
keyFile: /certs/public.key
|
||||
Reference in New Issue
Block a user