Files
mtusi2026lab7/infra/README.md
T

90 lines
7.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Инфраструктура lab7
## Телеметрия и границы ролей
`telemetry-gateway/*.cfg` — штатные HAProxy 3.2 gateways в network namespace
соответствующего backend. Только gateway принимает соединения из Docker-сети;
native HTTP, admin, metrics, OTLP и вспомогательный gRPC/gossip bind — loopback.
Внутренние listeners требуют проверенный client certificate; роль определяется
точным **CN**, не URI SAN и не переданным HTTP header. Неизвестная CN, даже от
того же CA, и неразрешённые method/path получают отказ по умолчанию.
| TLS endpoint | Разрешённая роль и операция | Native loopback |
| --- | --- | --- |
| `otel-collector:4318` | `api`/`worker`/`relay`: POST `/v1/traces`, `/v1/metrics`, `/v1/logs` | `14318` |
| `otel-collector:8888`, `:8889` | `prometheus`/`operator`: GET `/metrics` | `18888`, `18889` |
| `otel-collector:13134` | `prometheus`/`operator`: GET `/` (health) | `13133` |
| `prometheus:9090` | `grafana`: query/labels/series/metadata; `prometheus`: GET metrics/health; `operator`: отдельный query/status allowlist | `19090` |
| `loki:3100` | `collector`: POST `/otlp/v1/logs` или `/loki/api/v1/push`; `grafana`: query/labels/series/Explore; `prometheus`: GET metrics/ready; `operator`: отдельный read allowlist | `13100` |
| `tempo:3200` | `grafana`: GET trace/search/tag/TraceQL-metrics/echo; `prometheus`: GET metrics/ready; `operator`: отдельный read allowlist | `13200` |
| `tempo:4437` | только `collector`: OTLP gRPC | `14317` |
| `grafana:3000` | browser HTTPS, без client certificate; штатная аутентификация Grafana | `13000` |
Полные allowlists — в gateway configs. Grafana не получает push/delete/admin,
Collector не получает query API, scrape identity не получает data queries.
Loki/Tempo gateway перезаписывает `X-Scope-OrgID` в `fake`: внешний tenant header
не является полномочием; существующий single-tenant store сохраняется.
Prometheus не включает lifecycle/admin API; даже `operator` не получает
reload/quit/remote-write через gateway. Prometheus buildinfo GET доступен Grafana
для проверки datasource/version; остальные status endpoints — только operator.
У каждого владельца монтируется только его identity readonly в `/run/identity`:
`current/tls.pem`, `tls.crt`, `tls.key`, `ca.crt`, `ca.crl`. Gateways используют
CA/CRL verification, TLS >=1.2, session tickets/cache выключены. Они загружают
сертификаты/CRLs при старте: atomic replacement `current` требует bounded
reload/restart gateway и закрытия старых соединений; обновление файлов само по
себе не доказывает применение CRL/CA rollover. Штатные Collector/Prometheus/
Grafana clients проверяют CA и hostname, отправляют только собственный leaf.
Их native TLS config не объявляется самостоятельной CRL проверкой; lifecycle
должен обновлять trust consumers и разрывать прежние соединения.
Go использует `TLS_VERSION_FILE=/run/identity/current-version`: один bounded
regular-file read выбирает immutable `versions/<name>` сразу для leaf/key/CA/CRL.
Это не native `current` symlink; unreadable/malformed selectors fail closed.
Publisher делает staging selector runtime-readable до atomic rename. `up`
пересоздаёт native gateways даже при reused owners; `revoke` reloads/drains
HAProxy CRL consumers. Offline root CRLs обновляются до последних24h validity.
## Native запуск и сохранённые pipelines
- Prometheus: `--web.listen-address=127.0.0.1:19090`, без
`--web.enable-lifecycle`/`--web.enable-admin-api`; прежние retention flags,
scrape-job names, recording rules и alert tests сохраняются. Все шесть
scrape targets HTTPS/mTLS с identity `prometheus`, broker теперь `:15693`.
- Grafana: `GF_SERVER_HTTP_ADDR=127.0.0.1`, `GF_SERVER_HTTP_PORT=13000`,
`GF_SERVER_PROTOCOL=http`, `GF_SERVER_ROOT_URL=https://localhost:3000/`;
anonymous/auth-proxy login выключены, admin password — только private runtime
file. Backend не публикуется, browser использует TLS gateway.
- Collector: все три OTLP pipelines сохранены; memory limiter 140 MiB, batch
5 с/1024, exporter queues 10 MiB с retry <=30 с. Loki export — HTTPS `/otlp`
(OTLP добавляет `/v1/logs`), Tempo — GRPCS `:4437`; native Collector gRPC OTLP
listener отсутствует. Loopback health не зависит от доступности gateway.
- Loki: filesystem/schema v13, retention 168h, index labels только
`service.name`/`deployment.environment.name`; internal gRPC `127.0.0.1:9096`.
- Tempo: local storage, retention 72h; internal gRPC `127.0.0.1:9095`, gossip
loopback, advertised self-dial addresses loopback. Grafana использует
synchronous trace/search APIs, без внешнего query-gRPC listener.
- Datasource UIDs, dashboards, trace-to-log/derived-field links сохранены.
Tracked `grafana/provisioning/datasources/datasources.yaml` — **template**:
`__LAB7_CA_CERT__`, `__LAB7_CLIENT_CERT__`, `__LAB7_CLIENT_KEY__` заменяются
operator bootstrap только на material роли `grafana`. PEM хранится в
`secureJsonData`, datasource `editable: false`. В Grafana монтируется
сгенерированный private file вне Git, не этот template и не общий directory
с чужими ключами. Для YAML block scalars каждая PEM строка получает тот же
отступ; JSON сериализация как YAML также допустима. Rotation/CA rollover
требует повторного render и restart/reprovision Grafana.
- cAdvisor/Docker socket не используются; CPU/RAM приложения — cgroup v2,
брокерные queue labels — `rabbitmq_prometheus`. Runbooks находятся в `runbooks/`.
Это описание configuration boundaries, не заявление о пройденной проверке.
Совместимость pinned images, все dashboards, wrong-CN/verb/path negatives,
fresh/resumed revocation и отсутствие plaintext bypass проверяются отдельно
интеграционным acceptance driver после сборки всего стенда.
Синтаксис и поля: [HAProxy](https://github.com/haproxy/haproxy/blob/v3.2.0/doc/configuration.txt),
[Collector TLS](https://github.com/open-telemetry/opentelemetry-collector/blob/v0.164.0/config/configtls/README.md),
[Prometheus TLS](https://prometheus.io/docs/prometheus/latest/configuration/#tls_config),
[Grafana provisioning](https://github.com/grafana/grafana/blob/v13.2.4/docs/sources/administration/provisioning/index.md),
[Loki](https://github.com/grafana/loki/blob/v3.6.7/docs/sources/shared/configuration.md),
[Tempo 2.9](https://github.com/grafana/tempo/blob/v2.9.0/docs/sources/tempo/configuration/_index.md).