prole/monitoring/kps-values-gke.yaml
chrisfu 00f0ebec07 Merge claude/crazy-bose-fec256 into main
Bringing the long-running session-feature branch back into main in one
deliberate sweep. The branch carried the cluster work that's been live for
weeks (cross-cluster CNPG metrics, Grafana w/ Google OAuth, supabase
oauth2-proxy, cluster recovery, pg.0.knoe.dev + per-engineer onboarding,
GCS-backed CNPG backups via Workload Identity, the env-contamination
guard, the Junie brief queue, the cnpg-grafana CSRF + memory-request
fixes from today), while main accumulated Junie's parallel knoe-auth
Phase 2 OIDC work (full provider surface: discovery, authorize, token,
userinfo, JWKS, RS256 signing, code exchange, session services).

Key decision: the two branches did COMPETING rebrands off the same
starting point (5ba9b63, 2026-04-27):

  - claude branch (commit b355855, earlier): org.prole.authority.* →
                                              dev.knoe.auth.*
                                              (artifact renamed to
                                              knoe-auth.jar)
  - main (commit 9daa94b, recent): org.prole.authority.* →
                                    dev.knoe.authority.*
                                    (kept "authority" artifact name)

dev.knoe.auth wins: cluster runs from this name, the Maven artifact is
already knoe-auth.jar, and the broader rename is the documented
namespace direction (per ~/.claude/projects/-Users-chrisfu-dev-knoe-db/
memory/MEMORY.md). All of main's recent Phase 2 OIDC content was ported
from authority/src/.../dev/knoe/authority/ into
authority/src/.../dev/knoe/auth/ with package declarations rewritten.

== File-level resolution summary ==

Textual conflicts (4):

  authority/pom.xml
    - Took our artifactId="auth"
    - Took our branch's removal of spring-security-kerberos-client
      (verified: Junie's Phase 2 OIDC code does not import it; the dep
      was already-dead config)

  docs/pipeline-phases.md
    - Took our branch's "Phase 1 not started" status. Main had a
      misplaced " Complete" with a knoe-auth-Phase-1 commit ref
      in the autobuild Phase 1 section — different domain.

  docs/plans/knoe-auth-round-1.md
    - Took our branch's dev.knoe.auth file table (vs main's
      dev.knoe.authority listing). Pure rename mismatch.

  supabase/helm/knoe-supabase/templates/kong/config.yaml
    - Took our branch's onboard route + plain dashboard wiring.
      Main had an oauth2proxy.enabled toggle that put oauth2-proxy as
      a Kong upstream — but the deployed architecture (commit 25f1b2e)
      has oauth2-proxy in FRONT of Kong, not behind. Main's wrapper
      reflected an architecture that was never deployed.
    - Took our branch's removal of basic-auth from dashboard route
      (queue #15 brief still tracks the matching values.yaml /
      kong/deployment.yaml cleanup).

Java tree reconciliation (44 file-pairs):

  20 dual-path source files + 2 dual-path tests
    Body-identical between main's authority/ and our branch's auth/
    after stripping package decls — main's commit 9daa94b was a pure
    rebrand. Took our branch's auth/ version for all 22.

  8 main-only source files (Phase 2 OIDC), ported into auth/:
    web/JwksController.java
    web/OidcAuthorizeController.java
    web/OidcDiscoveryController.java
    web/OidcTokenController.java
    web/OidcUserInfoController.java
    session/OidcCodeService.java
    session/OidcTokenService.java
    session/SessionService.java

  12 main-only test files, ported into auth/:
    HealthControllerTest.java
    enroll/EnrollValueTypesTest.java
    enroll/EnrollmentControllerTest.java
    enroll/TotpServiceTest.java
    kerberos/KadminClientTest.java
    kerberos/KerberosSpnegoResultTest.java
    web/LoginControllerTest.java
    admin/AdminControllerTest.java
    user/PrincipalNormalizerTest.java
    regression/IdentityRegressionTest.java
    session/OidcCodeServiceTest.java
    session/SessionServiceTest.java

  Port mechanics: read main:authority/...<file> via git show, then sed
  rewrite `package dev.knoe.authority` → `package dev.knoe.auth` and
  `import dev.knoe.authority` → `import dev.knoe.auth`. Body content
  unchanged.

  authority/src/main/java/dev/knoe/authority/ — DELETED (duplicate)
  authority/src/test/java/dev/knoe/authority/  — DELETED (duplicate)

== Verification ==

- grep -rln '<<<<<<<' across .java/.md/.yaml/.yml/.sh/.xml/.tpl: clean
- find authority/src -path '*/dev/knoe/authority*': empty (subtree gone)
- grep 'package dev.knoe.authority' across repo: clean
- bash -n install.sh deploy.sh etc/preflight_kubecontext.sh: clean
- git ls-files -u | wc -l: 0 unmerged paths
- helm lint supabase/helm/knoe-supabase: pre-existing failure on
  studioIngress.enabled undefined in values.yaml (introduced by Junie
  on main; unrelated to this merge — flagging as follow-up).

== Followups (carried into TODO ranked queue or noted here) ==

  - helm lint failure: studioIngress block in values.yaml is missing
    enable flag; templates/studio/{ingress,oauth2proxy-deployment,
    oauth2proxy-service}.yaml all reference studioIngress.enabled with
    no default. Pre-existing on main; not introduced by this merge.
  - The five Junie briefs filed on this branch are now reachable from
    main at docs/plans/junie/{02,06,07,13,15}-*.md. Junie can pick them
    up in any order.
  - knoe-auth Phase 2 OIDC source (now at dev.knoe.auth.*) is not yet
    deployed to the cluster. Deployment is its own task.
  - The branch claude/crazy-bose-fec256 stays in place (worktree at
    .claude/worktrees/crazy-bose-fec256 may have ongoing context for
    Claude Code sessions). Safe to delete once next session starts
    cleanly from main.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-01 16:39:10 -07:00

292 lines
10 KiB
YAML

# kube-prometheus-stack (kps) Helm values — GKE deploy mode.
#
# This file is the canonical source of the values applied to the `kps`
# release in namespace `monitoring` on knoe-dev-0. It captures the existing
# inline values that were `helm install`'d 2026-04-28 PLUS today's grafana
# subpath + Google OAuth additions.
#
# Apply with:
# helm upgrade kps prometheus-community/kube-prometheus-stack \
# --namespace monitoring \
# -f monitoring/kps-values-gke.yaml
#
# NOTE on prole.org/node-role nodeSelectors below: this is a legacy label
# from the prole-era cluster — knoe-dev-0 nodes still carry it for
# compatibility. Once the cluster is fully relabelled to knoe.dev/* a
# follow-up will rename these. Tracked in docs/TODO.md (Reality TODO list).
---
alertmanager:
alertmanagerSpec:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: prole.org/node-role
operator: In
values:
- general
nodeSelector:
prole.org/node-role: general
storage:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
storageClassName: standard-hdd
grafana:
enabled: true
# adminPassword is the local break-glass; primary auth is Google OAuth (below).
# Rotate this whenever a person who once knew it leaves the team. Stored in
# 1Password (admin scope, separate from per-engineer entries).
adminPassword: admin
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: prole.org/node-role
operator: In
values:
- general
nodeSelector:
prole.org/node-role: general
initChownData:
enabled: false
persistence:
accessModes:
- ReadWriteOnce
enabled: true
size: 10Gi
storageClassName: standard-hdd
type: sts
service:
port: 80
targetPort: 3000
sidecar:
dashboards:
enabled: true
label: grafana_dashboard
labelValue: "1"
datasources:
enabled: true
label: grafana_datasource
labelValue: "1"
# Mount Google OAuth client credentials from the grafana-google-oidc Secret.
# Created by etc/init_grafana_oauth.sh from etc/secrets/grafana-google-oidc-*.
# Provides GF_AUTH_GOOGLE_CLIENT_ID and GF_AUTH_GOOGLE_CLIENT_SECRET env vars.
envFromSecret: grafana-google-oidc
# Additional Prometheus datasource pointing at the DB-cluster (knoe-dev-cnpg-0)
# Prometheus install (monitoring/kps-cnpg-values.yaml). The cnpg-grafana
# dashboards' DS_PROMETHEUS template variable can switch to this datasource
# to render CNPG metrics — Kubernetes service discovery is cluster-local, so
# the local app-cluster Prometheus can't see CNPG pods on its own.
# Reachable across clusters via the internal-LB IP allocated to
# `prometheus-cnpg-ilb` in monitoring ns of the DB cluster (same VPC subnet).
additionalDataSources:
- name: cnpg-prometheus
# Stable UID so the cnpg-grafana dashboard's DS_PROMETHEUS current.value
# (set by the dashboard transform spec) can refer to this datasource by
# name instead of an auto-generated random UID. Also makes the datasource
# identity-preserving across kps re-installs (which would otherwise
# regenerate the auto UID and silently break the dashboard).
uid: cnpg-prometheus
type: prometheus
url: http://10.180.15.216:9090
access: proxy
isDefault: false
editable: false
jsonData:
timeInterval: 15s
manageAlerts: false
prometheusType: Prometheus
# grafana.ini — appended to the chart's defaults.
# Subpath: served at https://svc.knoe.dev/grafana via the knoe-svc-kong route.
# Auth: Google OAuth restricted to @knoey.com Workspace; chrisfu + ron mapped
# to Admin via JMESPath, everyone else in the Workspace gets Editor.
grafana.ini:
server:
domain: svc.knoe.dev
root_url: "https://svc.knoe.dev/grafana"
serve_from_sub_path: true
security:
# Behind Kong + GCE LB on HTTPS — issue cookies with the Secure flag set
# so browsers send them on every request. Without this, Grafana 13's
# session-token rotation logic fights with the proxy chain and every
# API call returns 401 with `[session.token.rotate] token needs to be
# rotated`, breaking panel data fetches in a loop.
cookie_secure: true
cookie_samesite: lax
# Grafana 10+ enforces a same-origin CSRF check on every state-changing
# method (POST/PUT/PATCH/DELETE), comparing Origin/Referer to root_url.
# Behind Kong → grafana the upstream Host header is the cluster-internal
# service name (kps-grafana.monitoring.svc.cluster.local), not
# svc.knoe.dev, so the CSRF middleware rejects POSTs from the public
# origin with 403. Symptoms: every /api/ds/query → 403 (panels render
# empty); Share → Copy Link → "origin not allowed" toast.
# Trust the public hostname explicitly. csrf_trusted_origins takes
# space-separated bare hostnames (no scheme); csrf_additional_headers
# tells Grafana to also accept X-Forwarded-Host (which Kong sets
# correctly) as a valid origin source — this is the documented pairing
# for proxied installs.
csrf_trusted_origins: svc.knoe.dev
csrf_additional_headers: X-Forwarded-Host
"live":
# WebSocket origin check (Grafana live streaming, dashboard refresh).
# The default rejects any Origin not exactly matching root_url, which
# surfaces in the UI as a "origin not allowed" toast popup. Allow the
# public hostname explicitly. Multiple origins comma-separated if needed.
allowed_origins: "https://svc.knoe.dev"
auth:
# Keep the local login form available as a break-glass for adminPassword.
disable_login_form: false
# Increase the session-token rotation interval so the rotation race
# condition is rare enough not to break panel queries. Default was
# 10 minutes; bumped to 24 hours. The "right" fix is figuring out why
# rotation fails through the Kong proxy at all (TODO follow-up); this
# is the pragmatic mitigation for tonight.
token_rotation_interval_minutes: 1440
"auth.google":
enabled: true
# client_id / client_secret arrive via env (GF_AUTH_GOOGLE_CLIENT_ID etc.)
# from the grafana-google-oidc Secret. Don't duplicate here.
allowed_domains: knoey.com
scopes: "openid email profile"
auth_url: https://accounts.google.com/o/oauth2/v2/auth
token_url: https://oauth2.googleapis.com/token
api_url: https://openidconnect.googleapis.com/v1/userinfo
# JMESPath: chrisfu + ron get Admin; every other knoey.com user gets Editor.
# auto_assign_org_role below is the fallback if role_attribute_path produces
# an empty result.
role_attribute_path: "contains(['chrisfu@knoey.com', 'ron@knoey.com'], email) && 'Admin' || 'Editor'"
# Re-evaluate role on each login so a dropped engineer immediately loses
# the elevated bit; if you want manual elevation in Studio to survive,
# set this to true.
skip_org_role_sync: false
users:
auto_assign_org_role: Editor
kube-state-metrics:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: prole.org/node-role
operator: In
values:
- general
nodeSelector:
prole.org/node-role: general
prometheus:
prometheusSpec:
additionalScrapeConfigs:
- job_name: kubernetes-pods
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: keep
regex: true
source_labels:
- __meta_kubernetes_pod_annotation_prometheus_io_scrape
- action: replace
regex: (.+)
source_labels:
- __meta_kubernetes_pod_annotation_prometheus_io_path
target_label: __metrics_path__
- action: replace
regex: (.*?):\d+;(\d+)
replacement: $1:$2
source_labels:
- __address__
- __meta_kubernetes_pod_annotation_prometheus_io_port
target_label: __address__
- job_name: cnpg-metrics
kubernetes_sd_configs:
- role: pod
relabel_configs:
- action: keep
regex: .+
source_labels:
- __meta_kubernetes_pod_label_cnpg_io_cluster
- action: keep
regex: Running
source_labels:
- __meta_kubernetes_pod_phase
- action: replace
replacement: $1:9187
source_labels:
- __meta_kubernetes_pod_ip
target_label: __address__
- action: replace
source_labels:
- __meta_kubernetes_namespace
target_label: namespace
- action: replace
source_labels:
- __meta_kubernetes_pod_name
target_label: pod
- action: replace
source_labels:
- __meta_kubernetes_pod_label_cnpg_io_cluster
target_label: cluster
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: prole.org/node-role
operator: In
values:
- general
nodeSelector:
prole.org/node-role: general
storageSpec:
volumeClaimTemplate:
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
storageClassName: standard-hdd
prometheus-node-exporter:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: kubernetes.io/hostname
operator: NotIn
values:
- pi.prole.org
nodeSelector:
prole.org/node-role: general
prometheusOperator:
affinity:
nodeAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
nodeSelectorTerms:
- matchExpressions:
- key: prole.org/node-role
operator: In
values:
- general
nodeSelector:
prole.org/node-role: general