Files
argocd-apps/apps/base/ghp/migrate-job.yaml
T
unkin-agent 5faaff8d19
ci/woodpecker/pr/vector-test Pipeline was successful
ci/woodpecker/pr/pre-commit Pipeline was successful
ci/woodpecker/pr/kubeconform Pipeline was successful
ghp: use the estate templated default Vault convention
Drop the bespoke ghp SA/role/policy (terraform-vault#120 closed). The default
k8s auth role, bound to SA default in every namespace, already has a templated
read grant on kv/kubernetes/namespace/<ns>/default/*, so ghp needs zero
terraform-vault change.

- Remove the custom ServiceAccount; run as the namespace default SA.
- Deployment + migrate Job: serviceAccountName default.
- VaultAuth: role/serviceAccount default (mirrors artifactapi).
- VaultStaticSecrets: source paths move to the templated location
  kubernetes/namespace/ghp/default/{github-app,app}; Secret names unchanged.
2026-08-13 20:01:43 +10:00

79 lines
2.5 KiB
YAML

---
# Runs the schema migration once per sync, before the Deployment rolls, so the
# serve replicas never race migrations. Deleted before each re-create so a new
# image/version re-runs it.
#
# Sync-phase hook at wave 1 (NOT PreSync): the CNPG Cluster + generated
# postgres-app Secret apply at wave 0 and ArgoCD waits for the Cluster to be
# Healthy before starting wave 1, so on a fresh install Postgres exists before
# migrate connects. (A PreSync hook would run before the Sync phase that creates
# the DB, deadlocking the first install.)
apiVersion: batch/v1
kind: Job
metadata:
name: ghp-migrate
namespace: ghp
annotations:
argocd.argoproj.io/hook: Sync
argocd.argoproj.io/hook-delete-policy: BeforeHookCreation
argocd.argoproj.io/sync-wave: "1"
spec:
backoffLimit: 6
ttlSecondsAfterFinished: 600
template:
metadata:
labels:
app: ghp-migrate
spec:
serviceAccountName: default
automountServiceAccountToken: true
restartPolicy: Never
securityContext:
runAsNonRoot: true
runAsUser: 65532
runAsGroup: 65532
fsGroup: 65532
seccompProfile:
type: RuntimeDefault
containers:
- name: migrate
image: artifactapi.k8s.syd1.au.unkin.net/ghcr/goodtune/ghp:0.20.0
imagePullPolicy: IfNotPresent
command: ["/ghp", "migrate"]
env:
- name: GHP_DATABASE_DRIVER
value: postgres
- name: GHP_DB_USER
valueFrom:
secretKeyRef:
name: postgres-app
key: username
- name: GHP_DB_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-app
key: password
- name: GHP_DATABASE_DSN
value: "postgres://$(GHP_DB_USER):$(GHP_DB_PASSWORD)@postgres-rw.ghp.svc:5432/ghp?sslmode=require"
volumeMounts:
- name: tmp
mountPath: /tmp
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
capabilities:
drop:
- ALL
resources:
limits:
cpu: "1"
memory: 512Mi
requests:
cpu: 250m
memory: 256Mi
volumes:
# Writable scratch: root FS is read-only, so give the migrator a /tmp.
- name: tmp
emptyDir:
sizeLimit: 256Mi