ADR-0131: Keycloak grant broker and schema v39 account identities
Foundation / checks (checks) (push) Successful in 42m13s
Foundation / checks (deploy) (push) Successful in 4m5s
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (network) (push) Successful in 19m18s
Foundation / checks (postgres) (push) Successful in 44m19s
Foundation / checks (tsan) (push) Successful in 9m48s
Foundation / checks (client) (push) Failing after 12m6s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
Foundation / checks (checks) (push) Successful in 42m13s
Foundation / checks (deploy) (push) Successful in 4m5s
Foundation / checks (ecs) (push) Successful in 2m25s
Foundation / checks (network) (push) Successful in 19m18s
Foundation / checks (postgres) (push) Successful in 44m19s
Foundation / checks (tsan) (push) Successful in 9m48s
Foundation / checks (client) (push) Failing after 12m6s
Foundation / postgres-tools (push) Skipped
Foundation / server-image (push) Skipped
Foundation / image (push) Skipped
evo-grant-broker verifies realm aeternalis access tokens offline (RS256 against the pinned JWKS; audience aevolution-grants, client aevolution-game, verified email) and issues 10-minute session grants: - POST /grant routes to the region holding the account's life, or the default. - POST /logout makes every issued grant stale and expires current control. - GET /healthz. Schema v39 maps (issuer, subject) to stable accounts with strictly increasing serials. The binary ships in the server image. The DEV manifests are in deploy/kubernetes/grant-broker-dev and are not yet enabled in region/dev; that waits for the image promotion and the out-of-band Secrets and Ingress. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
# ADR-0131 grant broker. One replica: serials are ordered by the database, but the
|
||||
# per-account rate limit lives in the process. The realm's public signing key is
|
||||
# pinned below (BROKER_JWKS); a Keycloak key rotation needs a Git update here.
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: evo-grant-broker
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-wave: "2" # After migration (schema v39).
|
||||
labels:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
app.kubernetes.io/component: grant-broker
|
||||
spec:
|
||||
replicas: 1
|
||||
revisionHistoryLimit: 3
|
||||
progressDeadlineSeconds: 180
|
||||
selector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
app.kubernetes.io/component: grant-broker
|
||||
app.kubernetes.io/part-of: aevolution
|
||||
spec:
|
||||
serviceAccountName: aevolution-grant-broker
|
||||
automountServiceAccountToken: false
|
||||
terminationGracePeriodSeconds: 10
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 10001
|
||||
runAsGroup: 10001
|
||||
fsGroup: 10001
|
||||
seccompProfile: {type: RuntimeDefault}
|
||||
containers:
|
||||
- name: evo-grant-broker
|
||||
image: aevolution-server
|
||||
command: ["/bin/bash", "-c"]
|
||||
args:
|
||||
- |
|
||||
set -eu
|
||||
routes=()
|
||||
for route in $BROKER_ROUTES; do routes+=(--route "$route"); done
|
||||
exec /usr/local/bin/evo-grant-broker --listen 0.0.0.0:8080 --world "$BROKER_WORLD" --frame "$BROKER_FRAME" --default-region "$BROKER_DEFAULT_REGION" "${routes[@]}" --issuer-key /run/grant-issuer/issuer.key --jwks "$BROKER_JWKS" --oidc-issuer "$BROKER_OIDC_ISSUER" --audience aevolution-grants --client aevolution-game --grant-lifetime "$BROKER_GRANT_LIFETIME" --pg-service /run/postgres/pg_service.conf --pg-passfile /run/postgres/pgpass
|
||||
env:
|
||||
- {name: BROKER_WORLD, value: "100"}
|
||||
- {name: BROKER_FRAME, value: "9"}
|
||||
# New accounts start here; an account with a live life goes to its region.
|
||||
- {name: BROKER_DEFAULT_REGION, value: "4"}
|
||||
# Space-separated REGION=HOST:PORT=TLS_NAME, every region a grant may name.
|
||||
- {name: BROKER_ROUTES, value: "4=void.aeternalisgames.com:7400=void.aeternalisgames.com"}
|
||||
# Must not exceed the region's REGION_M10_MAX_GRANT_LIFETIME.
|
||||
- {name: BROKER_GRANT_LIFETIME, value: "600"}
|
||||
- {name: BROKER_OIDC_ISSUER, value: "https://auth.aeternalisgames.com/realms/aeternalis"}
|
||||
# Public RS256 signing key(s) of realm aeternalis, from its JWKS endpoint.
|
||||
- name: BROKER_JWKS
|
||||
value: '{"keys":[{"alg":"RS256","e":"AQAB","kid":"NGQG4QzQuBCIHVEomUPy-OoWOTVQIuyf3RXqeNbP8JI","kty":"RSA","n":"vvOpu1xxdyH_mB8LkJG6cwc6UVmmAj6mwQi1oEwrpJDLerBI2OZr2kpgMAUJ3-hMIkz5tRtSjHieMFteVrpDDQaCViIPCIvJTL3T7ujTGFNReSE6ho7h0DB_kybFeEWVpLqm6SSXWFYls5TKo6_t8Hw4G3njiRW9pX_NxyaBHqLkrCi63EyIGHOkdgUczg2d4pM4JTt-q25bcFSlYz8bhD3WEORQmbp-bU7aPPluCqCEAZRrbzf8Iy7svNemP5daDdlWQ3LaNy-ixC2HRjiPZdqK5BgAE800BigI-l1dkyJ4X172TLIPVPLW1WKlvdm3kHOpBXwACYiy8boSNDW7gQ","use":"sig"}]}'
|
||||
ports:
|
||||
- {name: http, containerPort: 8080, protocol: TCP}
|
||||
readinessProbe:
|
||||
httpGet: {path: /healthz, port: http}
|
||||
periodSeconds: 5
|
||||
timeoutSeconds: 1
|
||||
livenessProbe:
|
||||
httpGet: {path: /healthz, port: http}
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 10
|
||||
timeoutSeconds: 2
|
||||
failureThreshold: 3
|
||||
resources:
|
||||
requests: {cpu: 10m, memory: 16Mi}
|
||||
limits: {memory: 64Mi}
|
||||
securityContext:
|
||||
allowPrivilegeEscalation: false
|
||||
readOnlyRootFilesystem: true
|
||||
capabilities: {drop: [ALL]}
|
||||
volumeMounts:
|
||||
- {name: connection, mountPath: /run/postgres, readOnly: true}
|
||||
- {name: issuer, mountPath: /run/grant-issuer, readOnly: true}
|
||||
volumes:
|
||||
- name: connection
|
||||
secret:
|
||||
secretName: aevolution-grant-broker-pg
|
||||
defaultMode: 0440
|
||||
items:
|
||||
- {key: pg_service.conf, path: pg_service.conf}
|
||||
- {key: pgpass, path: pgpass}
|
||||
- {key: ca.crt, path: ca.crt}
|
||||
- name: issuer
|
||||
secret:
|
||||
secretName: aevolution-grant-issuer
|
||||
defaultMode: 0440
|
||||
items:
|
||||
- {key: issuer.key, path: issuer.key}
|
||||
@@ -0,0 +1,14 @@
|
||||
# ADR-0131 grant broker for evolution-dev ONLY: verifies Keycloak access tokens
|
||||
# (realm aeternalis) and issues 10-minute session grants for world 100 frame 9.
|
||||
# Public route: https://grants.aeternalisgames.com -> Ingress (created out of band:
|
||||
# the aevolution-dev Argo project admits no Ingress) -> Service evo-grant-broker:8080.
|
||||
# Out-of-band Secrets in evolution-dev: aevolution-grant-issuer (issuer.key, the raw
|
||||
# 32-byte dev issuer scalar) and aevolution-grant-broker-pg (pg_service.conf, pgpass,
|
||||
# ca.crt for a login in the runtime group).
|
||||
apiVersion: kustomize.config.k8s.io/v1alpha1
|
||||
kind: Component
|
||||
resources:
|
||||
- serviceaccount.yaml
|
||||
- deployment.yaml
|
||||
- service.yaml
|
||||
- networkpolicy.yaml
|
||||
@@ -0,0 +1,32 @@
|
||||
# Broker traffic on top of the namespace default-deny: HTTP 8080 from the ingress
|
||||
# controller only (RKE2's bundled ingress-nginx in kube-system; it may run on the host
|
||||
# network, so the node subnet is admitted too), and PostgreSQL on pg-forge-01 only.
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: NetworkPolicy
|
||||
metadata:
|
||||
name: evo-grant-broker
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-wave: "-1"
|
||||
spec:
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
policyTypes: [Ingress, Egress]
|
||||
ingress:
|
||||
- from:
|
||||
- namespaceSelector:
|
||||
matchLabels:
|
||||
kubernetes.io/metadata.name: kube-system
|
||||
podSelector:
|
||||
matchLabels:
|
||||
app.kubernetes.io/name: rke2-ingress-nginx
|
||||
- ipBlock:
|
||||
cidr: 172.10.1.0/24
|
||||
ports:
|
||||
- {protocol: TCP, port: 8080}
|
||||
egress:
|
||||
- to:
|
||||
- ipBlock:
|
||||
cidr: 172.10.1.127/32
|
||||
ports:
|
||||
- {protocol: TCP, port: 5432}
|
||||
@@ -0,0 +1,16 @@
|
||||
# Cluster-internal; the Ingress for grants.aeternalisgames.com terminates TLS and
|
||||
# forwards here.
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: evo-grant-broker
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-wave: "2"
|
||||
labels:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app.kubernetes.io/name: evo-grant-broker
|
||||
ports:
|
||||
- {name: http, port: 8080, targetPort: http, protocol: TCP}
|
||||
@@ -0,0 +1,10 @@
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: aevolution-grant-broker
|
||||
annotations:
|
||||
argocd.argoproj.io/sync-wave: "-1"
|
||||
automountServiceAccountToken: false
|
||||
# Create this pull-only Secret separately in evolution-dev; never commit credentials.
|
||||
imagePullSecrets:
|
||||
- name: harbor-pull
|
||||
@@ -12,7 +12,7 @@ spec:
|
||||
env:
|
||||
- {name: REGION_SESSION, value: "dev"}
|
||||
- {name: REGION_SESSION_LISTEN, value: "0.0.0.0:7400"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261015T114156-9412:1792078916"}
|
||||
- {name: REGION_SESSION_WINDOW, value: "dev-20261015T142027-62240:1792084827"}
|
||||
- {name: REGION_M10_MAX_GRANT_LIFETIME, value: "14400"}
|
||||
ports:
|
||||
# QUIC (ADR-0090): UDP only; nothing listens on TCP 7400.
|
||||
|
||||
Reference in New Issue
Block a user