--- # Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of the # plain (non-CNPG) Postgres Deployment `osint/osint-db` through the exec API. # # `osint-db` is a stock `postgres` Deployment, so there is no Cluster object and # no `status.currentPrimary` to look up; the dump is taken inside the pod over # the local socket and uses the pod's own `POSTGRES_USER`/`POSTGRES_DB`, so no # password is copied into `forgejo`, git or the Job. # # Least privilege: the ServiceAccount may run one command inside this # namespace's pods — nothing else. apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: name: cluster-backup namespace: osint labels: app: cluster-backup rules: - apiGroups: [""] resources: ["pods"] verbs: ["get", "list"] - apiGroups: [""] resources: ["pods/exec"] verbs: ["create"] # `kubectl exec deploy/osint-db` resolves the Deployment's ReplicaSet/pod, so # it needs read access to the deployment itself. - apiGroups: ["apps"] resources: ["deployments"] verbs: ["get"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: name: cluster-backup namespace: osint labels: app: cluster-backup roleRef: apiGroup: rbac.authorization.k8s.io kind: Role name: cluster-backup subjects: - kind: ServiceAccount name: cluster-backup namespace: forgejo