PostgreSQL backup tool with Point-In-Time-Recovery and restore verification
TypeScript backupbackupsdatabasedatabase-backupdevopsdockergolangkubernetesmariadbmongodbmysqlpgpostgrespostgresqls3self-hostedsystem-administrationtoolsweb-ui
FEATURE (helm): Add ServiceAccount and extraVolumes support for Pod Security Standards (issue #614)
Rostislav Dugin899a4a4f770d
diff --git a/deploy/helm/README.md b/deploy/helm/README.mdindex d00554bc..5f07dab7 100644--- a/deploy/helm/README.md+++ b/deploy/helm/README.md@@ -277,6 +277,75 @@ helm install databasus oci://ghcr.io/databasus/charts/databasus \-f storage-values.yaml```+## Pod Security / Hardening++On a cluster that enforces the restricted Pod Security Standard (or runs scanners+like Kyverno, Kubescape or Polaris), tune the following values.++| Parameter | Description | Default Value |+| -------------------------------------------- | -------------------------------------------------------- | ------------- |+| `serviceAccount.create` | Provision a dedicated ServiceAccount | `false` |+| `serviceAccount.name` | Override the ServiceAccount name (else default/fullname) | `""` |+| `serviceAccount.annotations` | Annotations for the created ServiceAccount | `{}` |+| `serviceAccount.automountServiceAccountToken`| Mount the SA token into the pod | `false` |+| `podSecurityContext` | Pod-level security context | `{}` |+| `securityContext` | Container-level security context | `{}` |+| `podAnnotations` | Pod annotations (e.g. AppArmor profile) | `{}` |+| `extraVolumes` / `extraVolumeMounts` | Extra volumes/mounts (e.g. emptyDir for read-only rootfs)| `[]` |++The app does **not** automount the ServiceAccount token by default+(`automountServiceAccountToken: false`), which clears the common+`AutomountServiceAccountTokenTrueAndDefaultSA` finding even on the namespace+`default` ServiceAccount.++A restricted-PSS values example wiring seccomp, no privilege escalation, AppArmor,+a dedicated ServiceAccount and a read-only root filesystem:++```yaml+# hardened-values.yaml+serviceAccount:+ create: true++podAnnotations:+ container.apparmor.security.beta.kubernetes.io/databasus: runtime/default++podSecurityContext:+ fsGroup: 1000+ seccompProfile:+ type: RuntimeDefault++securityContext:+ allowPrivilegeEscalation: false+ readOnlyRootFilesystem: true+ seccompProfile:+ type: RuntimeDefault+ capabilities:+ drop:+ - ALL+ # gosu drops privileges from the root entrypoint; these are required.+ add:+ - SETUID+ - SETGID++# Writable paths required while the root filesystem is read-only.+extraVolumes:+ - name: tmp+ emptyDir: {}+ - name: var-run+ emptyDir: {}+extraVolumeMounts:+ - name: tmp+ mountPath: /tmp+ - name: var-run+ mountPath: /var/run+```++> **Not supported by design:** `runAsNonRoot: true` and dropping **all**+> capabilities. The entrypoint must start as root to handle PUID/PGID remapping,+> volume `chown` and PostgreSQL `initdb`, then drops to a non-root user with+> `gosu` (which requires `SETUID`/`SETGID`). See the note in `values.yaml`+> next to `podSecurityContext`.+## Upgrade```bashdiff --git a/deploy/helm/templates/serviceaccount.yaml b/deploy/helm/templates/serviceaccount.yamlnew file mode 100644index 00000000..df26c225--- /dev/null+++ b/deploy/helm/templates/serviceaccount.yaml@@ -0,0 +1,14 @@+{{- if .Values.serviceAccount.create }}+apiVersion: v1+kind: ServiceAccount+metadata:+ name: {{ include "databasus.serviceAccountName" . }}+ namespace: {{ include "databasus.namespace" . }}+ labels:+ {{- include "databasus.labels" . | nindent 4 }}+ {{- with .Values.serviceAccount.annotations }}+ annotations:+ {{- toYaml . | nindent 4 }}+ {{- end }}+automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}+{{- end }}diff --git a/deploy/helm/templates/statefulset.yaml b/deploy/helm/templates/statefulset.yamlindex e2750207..e5065c8e 100644--- a/deploy/helm/templates/statefulset.yaml+++ b/deploy/helm/templates/statefulset.yaml@@ -23,6 +23,8 @@ spec:{{- toYaml . | nindent 8 }}{{- end }}spec:+ serviceAccountName: {{ include "databasus.serviceAccountName" . }}+ automountServiceAccountToken: {{ .Values.serviceAccount.automountServiceAccountToken }}{{- with .Values.imagePullSecrets }}imagePullSecrets:{{- toYaml . | nindent 8 }}@@ -82,6 +84,9 @@ spec:subPath: ca.crtreadOnly: true{{- end }}+ {{- with .Values.extraVolumeMounts }}+ {{- toYaml . | nindent 12 }}+ {{- end }}resources:{{- toYaml .Values.resources | nindent 12 }}{{- if .Values.livenessProbe.enabled }}@@ -102,11 +107,16 @@ spec:timeoutSeconds: {{ .Values.readinessProbe.timeoutSeconds }}failureThreshold: {{ .Values.readinessProbe.failureThreshold }}{{- end }}- {{- if .Values.customRootCA }}+ {{- if or .Values.customRootCA .Values.extraVolumes }}volumes:+ {{- if .Values.customRootCA }}- name: custom-root-casecret:secretName: {{ .Values.customRootCA }}+ {{- end }}+ {{- with .Values.extraVolumes }}+ {{- toYaml . | nindent 8 }}+ {{- end }}{{- end }}{{- if .Values.persistence.enabled }}volumeClaimTemplates:diff --git a/deploy/helm/values.yaml b/deploy/helm/values.yamlindex 6db3953d..49d7609a 100644--- a/deploy/helm/values.yaml+++ b/deploy/helm/values.yaml@@ -38,6 +38,27 @@ extraEnvFrom: []# - configMapRef:# name: databasus-extras-cm+# Extra volumes and volume mounts for the databasus container.+# Use emptyDir mounts here to satisfy `securityContext.readOnlyRootFilesystem: true`+# -- PostgreSQL and Valkey need writable /tmp, sockets and runtime dirs.+extraVolumes: []+# - name: tmp+# emptyDir: {}+extraVolumeMounts: []+# - name: tmp+# mountPath: /tmp++# ServiceAccount for the pod.+# Defaults keep backward-compatible behavior (namespace `default` SA) while+# disabling token automounting -- on a hardened cluster this clears the+# AutomountServiceAccountTokenTrueAndDefaultSA finding. Set `create: true` to+# provision a dedicated ServiceAccount instead.+serviceAccount:+ create: false+ name: ""+ annotations: {}+ automountServiceAccountToken: false+# Service configurationservice:type: ClusterIP