Files
argocd-apps/apps/overlays/au-syd1/logging/values-nats.yaml
T
unkinben c39af2f9c3
ci/woodpecker/pr/vector-test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/kubeconform Pipeline was successful
Insert NATS JetStream log bus + S3 raw archive
Rework the logging pipeline around a durable message bus so logs survive a
ClickHouse outage, can be replayed after a bad transform, and fan out to
multiple independent consumers. Add long-term raw-log backup to S3.

Topology becomes edge -> JetStream -> consumers -> sinks:
- Dedicated JetStream NATS cluster (3 replicas, file storage) in the logging
  namespace. Deliberately separate from app messaging (streamstack) for
  blast-radius isolation. Stream LOGS (subjects logs.>, retention=limits, 40GiB
  / 72h) is the outage buffer; durable consumers give independent offsets.
- Edge publishers (thin): the k8s DaemonSet and a new VM-ingest Deployment
  (HTTP NDJSON front door behind the logs-ingest Gateway) publish into JetStream
  (logs.k8s.<ns>.<container> / logs.vm.<host>). No parsing on the edge.
- Transform tier (StatefulSet): pulls the whole stream via the durable
  `transform` consumer, routes by subject, shapes, and remains the sole
  ClickHouse writer. Its disk buffer shrinks (JetStream is the outage buffer).
- Archiver (Deployment): its OWN durable `archiver` consumer (independent
  offsets — archive lag never affects the ClickHouse path) writes RAW,
  pre-transform events to a Ceph RGW S3 bucket (cephrgw-operator ObjectStoreUser
  + Bucket + BucketAccess) as gzipped NDJSON keyed by raw/<subject>/YYYY/MM/DD/.
  Default subject filter is Vault audit (logs.k8s.vault.>), configurable.

Auth: distinct NATS users (producer publish-only, consumer pull+ack, admin for
the stream/consumer bootstrap Job) with passwords from Vault (nats-auth Secret);
S3 creds from the BucketAccess Secret. Streams/consumers are provisioned by an
idempotent PostSync bootstrap Job.

Add local kubeconform schemas for the ceph.unkin.net CRDs (datreeio lacks them)
and extend the vector-test CI to cover the agent, VM-ingest and archiver
configs. Verified end-to-end locally: NATS ACLs, vector JetStream publish, and
durable-consumer pull+ack (at-least-once) all work.

Claude-Session: https://claude.ai/code/session_015ur3i7D2azsMAWTSVABApv
2026-07-27 20:23:55 +10:00

84 lines
2.2 KiB
YAML

# Dedicated JetStream-enabled NATS cluster for the log bus. Deliberately NOT
# shared with app messaging (streamstack et al. run their own NATS in their own
# repo) — a separate cluster isolates logging blast-radius from app messaging
# and lets us size retention/storage purely for the log outage-buffer + replay
# use-case.
fullnameOverride: nats
config:
cluster:
enabled: true
replicas: 3
jetstream:
enabled: true
fileStore:
pvc:
size: 50Gi
storageClassName: cephrbd-fast-delete
# Per-user auth with publish/subscribe separation. Passwords are injected as
# env vars from the Vault-synced nats-auth Secret (NATS expands $VAR in config).
merge:
authorization:
users:
# Bootstrap Job (stream/consumer management) — full JetStream API.
- user: log-admin
password: $NATS_ADMIN_PASSWORD
# Edge publishers (k8s DaemonSet + VM ingest) — publish only.
- user: log-producer
password: $NATS_PRODUCER_PASSWORD
permissions:
publish:
allow:
- "logs.>"
subscribe:
allow:
- "_INBOX.>"
# Consumers (transform tier + archiver) — pull + ack only, no publish
# to log subjects.
- user: log-consumer
password: $NATS_CONSUMER_PASSWORD
permissions:
publish:
allow:
- "$JS.API.CONSUMER.>"
- "$JS.API.STREAM.INFO.>"
- "$JS.ACK.LOGS.>"
subscribe:
allow:
- "_INBOX.>"
container:
env:
NATS_ADMIN_PASSWORD:
valueFrom:
secretKeyRef:
name: nats-auth
key: admin_password
NATS_PRODUCER_PASSWORD:
valueFrom:
secretKeyRef:
name: nats-auth
key: producer_password
NATS_CONSUMER_PASSWORD:
valueFrom:
secretKeyRef:
name: nats-auth
key: consumer_password
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: "2"
memory: 4Gi
# Roll the StatefulSet when nats-auth changes.
podTemplate:
merge:
metadata:
annotations:
reloader.stakater.com/auto: "true"
natsBox:
enabled: false