Skip to content

Commit

Permalink
Fix backup for non Openshift cluster
Browse files Browse the repository at this point in the history
  • Loading branch information
EliasBoulharts committed Dec 10, 2024
1 parent 5d0f91e commit c709be5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
10 changes: 10 additions & 0 deletions roles/backup/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,16 @@ To customize the pg_dump command that will be executed on a backup use the `pg_d
pg_dump_suffix: "--exclude-table-data 'main_jobevent*' --exclude-table-data 'main_job'"
```
When using a hostPath backed PVC and some other storage classes like longhorn storage, the postgres data directory needs to be accessible by the user in the postgres pod (UID 26).
To initialize this directory with the correct permissions, configure the following setting, which will use an init container to set the permissions in the postgres volume.
```
init_container_commands: |
chown 26:0 /backups
chmod 700 /backups
```
Testing
----------------
Expand Down
14 changes: 14 additions & 0 deletions roles/backup/templates/management-pod.yml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,20 @@ metadata:
labels:
{{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }}
spec:
{% if init_container_commands %}
initContainers:
- name: init
image: '{{ _postgres_image }}'
command:
- "/bin/sh"
- "-c"
- |
{{ init_container_commands | indent(width=14) }}
volumeMounts:
- name: {{ ansible_operator_meta.name }}-backup
mountPath: /backups
readOnly: false
{% endif %}
containers:
- name: {{ ansible_operator_meta.name }}-db-management
image: "{{ _postgres_image }}"
Expand Down

0 comments on commit c709be5

Please sign in to comment.