From 7251961bccf82bbc4ce977ed1da8b1c29d431aa7 Mon Sep 17 00:00:00 2001 From: Christian Adams Date: Wed, 8 Nov 2023 15:44:30 -0500 Subject: [PATCH] Add ability to mount custom volumes in the postgres pod (#1626) * Add ability to mount custom volumes in the postgres pod * Fix indentation for postgres_extra_volumes Signed-off-by: Christian M. Adams Co-authored-by: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> --- config/crd/bases/awx.ansible.com_awxs.yaml | 6 ++++++ .../bases/awx-operator.clusterserviceversion.yaml | 12 ++++++++++++ roles/installer/defaults/main.yml | 9 ++++++++- .../templates/statefulsets/postgres.yaml.j2 | 7 +++++++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 683552fc..1fb2d61e 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -1608,6 +1608,9 @@ spec: web_extra_volume_mounts: description: Specify volume mounts to be added to the Web container type: string + postgres_extra_volume_mounts: + description: Specify volume mounts to be added to Postgres container + type: string uwsgi_processes: description: Set the number of uwsgi processes to run in a web container type: integer @@ -1715,6 +1718,9 @@ spec: type: array items: type: string + postgres_extra_volumes: + description: Specify extra volumes to add to the application pod + type: string postgres_keepalives: description: Controls whether client-side TCP keepalives are used for Postgres connections. default: true diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index 2dd82780..260f3f82 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -583,6 +583,18 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced - urn:alm:descriptor:com.tectonic.ui:hidden + - displayName: Postgres Extra Volumes + description: Specify extra volumes to add to the postgres pod + path: postgres_extra_volumes + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden + - description: Specify volume mounts to be added to Postgres container + displayName: Postgres Extra Volume Mounts + path: postgres_extra_volume_mounts + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden - displayName: Enable Postgres Keepalives path: postgres_keepalives x-descriptors: diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 266203bd..bd5d4039 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -233,6 +233,12 @@ ee_pull_credentials_secret: '' # emptyDir: {} extra_volumes: '' +# Add extra volumes to the Postgres pod. Specify as literal block. E.g.: +# postgres_extra_volumes: | +# - name: my-volume +# emptyDir: {} +postgres_extra_volumes: '' + # Use these image versions for Ansible AWX. _image: quay.io/ansible/awx @@ -340,13 +346,14 @@ ee_extra_env: '' # Mount extra volumes on the AWX task/web containers. Specify as literal block. # E.g.: -# task_extra_volume_mounts: '' +# task_extra_volume_mounts: | # - name: my-volume # mountPath: /some/path task_extra_volume_mounts: '' web_extra_volume_mounts: '' rsyslog_extra_volume_mounts: '' ee_extra_volume_mounts: '' +postgres_extra_volume_mounts: '' # Add a nodeSelector for the Postgres pods. # It must match a node's labels for the pod to be scheduled on that node. diff --git a/roles/installer/templates/statefulsets/postgres.yaml.j2 b/roles/installer/templates/statefulsets/postgres.yaml.j2 index 2b99eefc..0e60fb4f 100644 --- a/roles/installer/templates/statefulsets/postgres.yaml.j2 +++ b/roles/installer/templates/statefulsets/postgres.yaml.j2 @@ -112,6 +112,9 @@ spec: - name: postgres-{{ supported_pg_version }} mountPath: '{{ postgres_data_path | dirname }}' subPath: '{{ postgres_data_path | dirname | basename }}' +{% if postgres_extra_volume_mounts -%} + {{ postgres_extra_volume_mounts | indent(width=12, first=True) }} +{% endif %} resources: {{ postgres_resource_requirements }} {% if postgres_selector %} nodeSelector: @@ -120,6 +123,10 @@ spec: {% if postgres_tolerations %} tolerations: {{ postgres_tolerations | indent(width=8) }} +{% endif %} +{% if postgres_extra_volumes %} + volumes: + {{ postgres_extra_volumes | indent(width=8, first=False) }} {% endif %} volumeClaimTemplates: - metadata: