41 lines
1.1 KiB
YAML
41 lines
1.1 KiB
YAML
|
|
---
|
||
|
|
# Lets the nightly `forgejo/cluster-backup` CronJob take a `pg_dump` of this
|
||
|
|
# namespace's CloudNativePG cluster through the exec API (namespace `forgejo`
|
||
|
|
# cannot mount a Secret from here, and the dump runs as the in-pod `postgres`
|
||
|
|
# superuser over the local socket, so no database password exists in git).
|
||
|
|
#
|
||
|
|
# Least privilege: that ServiceAccount may look up the Cluster object and run
|
||
|
|
# one command inside this namespace's pods — nothing else.
|
||
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
||
|
|
kind: Role
|
||
|
|
metadata:
|
||
|
|
name: cluster-backup
|
||
|
|
namespace: sirius-growth
|
||
|
|
labels:
|
||
|
|
app: cluster-backup
|
||
|
|
rules:
|
||
|
|
- apiGroups: [""]
|
||
|
|
resources: ["pods"]
|
||
|
|
verbs: ["get", "list"]
|
||
|
|
- apiGroups: [""]
|
||
|
|
resources: ["pods/exec"]
|
||
|
|
verbs: ["create"]
|
||
|
|
- apiGroups: ["postgresql.cnpg.io"]
|
||
|
|
resources: ["clusters"]
|
||
|
|
verbs: ["get"]
|
||
|
|
---
|
||
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
||
|
|
kind: RoleBinding
|
||
|
|
metadata:
|
||
|
|
name: cluster-backup
|
||
|
|
namespace: sirius-growth
|
||
|
|
labels:
|
||
|
|
app: cluster-backup
|
||
|
|
roleRef:
|
||
|
|
apiGroup: rbac.authorization.k8s.io
|
||
|
|
kind: Role
|
||
|
|
name: cluster-backup
|
||
|
|
subjects:
|
||
|
|
- kind: ServiceAccount
|
||
|
|
name: cluster-backup
|
||
|
|
namespace: forgejo
|