#!/usr/bin/env bash # Create the platform's secrets in the cluster. Idempotent: credentials are # generated once into k8s/.credentials (gitignored, mode 600) and reused on # every later run, so re-running only re-applies the same secrets. # # ./k8s/create-secrets.sh # # Creates, in namespace ledgerline-observability: # obs-basic-auth htpasswd for the Traefik basic-auth middleware # (Prometheus, Alertmanager, Loki, Tempo, Alloy UI, OTLP) # grafana-admin Grafana admin user/password # prometheus-scrape-auth # username/password Prometheus sends when scraping Ledgerline # and writes two gitignored files for czy; copy both to the server after every # regeneration (see k8s/README.md): # .env.observability for the Alloy log agent and the OTLP auth header of # instrumented services # observability/traefik/metrics-users # htpasswd for Traefik's basic auth on /metrics/ # # KUBECTL defaults to `kubectl`; e.g. KUBECTL="ssh falken kubectl" to run it on # the node when the API server isn't reachable from here. set -euo pipefail cd "$(dirname "$0")" KUBECTL="${KUBECTL:-kubectl}" NS=ledgerline-observability CREDS=.credentials if [ ! -f "$CREDS" ]; then umask 077 cat > "$CREDS" < %20), and # newlines stripped because GNU base64 wraps at 76 chars and this is ~80. OTLP_BASIC=$(printf '%s:%s' "$OBS_USER" "$OBS_PASSWORD" | base64 | tr -d '\n') ( umask 077 cat > ../.env.observability < ../observability/traefik/metrics-users ) echo "wrote $(cd .. && pwd)/observability/traefik/metrics-users"