mediamark: deploy the media marking app #441
Reference in New Issue
Block a user
Delete Branch "benvin/deploy-mediamark"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Why
mediamark needs a home in the cluster: it marks/organises media on the shared mediastore tree and drives the adult-tier sonarr/radarr through arrproxy's hash routes. This adds the full app to the
mediaproject, mirroring the watchstate two-host oauth2-proxy pattern and the arrstack static-CephFS + projected-API-keys patterns.How
apps/base/mediamark/: namespace, VaultAuth (k8s/au/syd1, roledefault), three VaultStaticSecrets, static mediastore PV/PVC, the app Deployment, oauth2-proxy ConfigMap/Deployment, two Services, and internal + external Gateway/HTTPRoute pairs.mediamark-mediastore, ownvolumeHandle,claimRef-pinned) to the same CephFS mediastore subvolume arrstack/fafflix/cheeztv use, RWX 10Ti Retain, mounted at/media./livez+/readyzprobes./etc/mediamark/keys, mirroring arrproxy's keys projection, with reloader annotations on both secrets.mediamark.unkin.net(traefik-external, reflected Let's Encrypt wildcard, no cert-manager annotations) andmediamark.k8s.syd1.au.unkin.net(traefik-internal, vault-issuer) with a single oauth2-proxy using a relative/oauth2/callbackredirect; gated onakP-mediamark-userand passing identity to the app asX-Forwarded-GroupsviaPASS_USER_HEADERS.mediamarkto thewildcard-unkin-netCertificate's two reflector namespace lists, and registers the app inargocd/applicationsets/media.yaml+argocd/projects/media.yamlwith a passthroughapps/overlays/au-syd1/mediamarkoverlay.Prerequisite seeds (Ben, before pods go Ready)
These KV paths must exist under
kv/kubernetes/namespace/mediamark/default/— themediamark/defaulttemplated policy already grants read, so no terraform-vault change is needed:oauth-credentials— needsclient_idandcookie_secretadded alongside the existingclient_secret(Authentik mediamark provider; both absolute callback URIs registered there).sonarr— keyapitoken.radarr— keyapitoken.Validation
kustomize build --enable-helm apps/overlays/au-syd1/mediamark(18 resources) and.../cert-managerboth build.pre-commit run --all-filespasses.The static sonarr/radarr API keys were copies of the real per-app keys, seeded by hand into kv and never rotated. The arrstack secrets engine can mint short-lived machine tokens instead, so mediamark leases one rather than holding a copy of the real thing. Drop the sonarr-apikey and radarr-apikey VaultStaticSecrets. Add an arrstack-creds VaultAuth bound to the new `mediamark` k8s role. Add an arrstack-virtual-key VaultDynamicSecret reading arrstack/creds/mediamark. Project the leased token to both /etc/mediamark/keys/{sonarr,radarr}. Point MEDIAMARK_{SONARR,RADARR}_URL at arrproxy-api, which is the only thing that honours a virtual key. Reload on arrstack-virtual-key instead of the removed secrets.Updated: ephemeral virtual keys instead of copied static keys (
fbe7348)Pushed an additive commit that swaps the hand-seeded sonarr/radarr API keys for short-lived credentials leased from the arrstack secrets engine.
Removed
VaultStaticSecret/sonarr-apikey(kvkubernetes/namespace/mediamark/default/sonarr)VaultStaticSecret/radarr-apikey(kvkubernetes/namespace/mediamark/default/radarr)Added
VaultAuth/arrstack-creds— mountk8s/au/syd1, rolemediamark, SAdefault, audiencevault, TTL 600. Separate from thedefaultVaultAuth because only themediamarkrole's policy grants the creds path.VaultDynamicSecret/arrstack-virtual-key— mountarrstack, pathcreds/mediamark,vaultAuthRef: arrstack-creds, destination secretarrstack-virtual-key(create: true),revoke: true,allowStaticCreds: false, defaultrenewalPercent: 67. Role ttl is 60s so VSO renews the lease continuously.Rewired
tokenkey to both/etc/mediamark/keys/sonarrand/etc/mediamark/keys/radarr— one machine token covers both apps, and mediamark re-reads the file per request, so renewal rotates in place.MEDIAMARK_SONARR_URL/MEDIAMARK_RADARR_URLnow point athttp://arrproxy-api.arrstack.svc.cluster.local:8080/3aa168/{sonarr,radarr}. This is required, not cosmetic: a virtual key is only meaningful to arrproxy, which validates the machine token and injects the real per-app key upstream. Thesonarr-adult/radarr-adultServices would reject it. The3aa168prefix matches the fafflix tier inapps/base/arrstack/arrproxy/tiers-configmap.yaml.arrstack-virtual-key.Prerequisites (revised)
The sonarr/radarr KV seeds are no longer needed — drop them from the checklist. What remains before pods can get credentials:
oauth-credentialsKV patch — Ben, unchanged from before.arrstack/creds/mediamarkrole and themediamarkk8s auth role exist, the VaultDynamicSecret will fail to sync and the keys volume will have no secret to project, so mediamark pods will not become ready. Merge order: #141 applied first, then this.Note on blast radius
The engine cannot method-restrict machine tokens, so the minted virtual key is full-method (it would permit writes through arrproxy if something used it that way). mediamark itself only issues GETs. Worth knowing that the restriction is behavioural rather than enforced at the token; if that becomes a concern the fix belongs in the engine, not here.
Validation
kustomize build apps/overlays/au-syd1/mediamark— cleankubeconformwith the repo'sci/validate-apps.shargs — 18/18 valid,VaultDynamicSecret arrstack-virtual-key is valid(the v1beta1 schema is already committed underschemas/secrets.hashicorp.com/, no skip needed)pre-commit run --all-files— all passed