From fcc09673cc1f56d29bbe04d4c12ef08bf15455ef Mon Sep 17 00:00:00 2001 From: rakesh561 Date: Wed, 21 Jun 2023 10:46:29 -0400 Subject: [PATCH] Add db_management_pod_node_selector for specifying nodeSelect for backup/restore mgmt pod (#1434) Co-authored-by: Hao Liu <44379968+TheRealHaoLiu@users.noreply.github.com> Co-authored-by: Jesse Wattenbarger --- config/crd/bases/awx.ansible.com_awxbackups.yaml | 3 +++ config/crd/bases/awx.ansible.com_awxrestores.yaml | 3 +++ roles/backup/defaults/main.yml | 8 ++++++++ roles/backup/templates/management-pod.yml.j2 | 4 ++++ roles/restore/defaults/main.yml | 8 ++++++++ roles/restore/templates/management-pod.yml.j2 | 4 ++++ 6 files changed, 30 insertions(+) diff --git a/config/crd/bases/awx.ansible.com_awxbackups.yaml b/config/crd/bases/awx.ansible.com_awxbackups.yaml index 6d132d10..0b67bea6 100644 --- a/config/crd/bases/awx.ansible.com_awxbackups.yaml +++ b/config/crd/bases/awx.ansible.com_awxbackups.yaml @@ -90,6 +90,9 @@ spec: postgres_image_version: description: PostgreSQL container image version to use type: string + db_management_pod_node_selector: + description: nodeSelector for the Postgres pods to backup + type: string no_log: description: Configure no_log for no_log tasks type: boolean diff --git a/config/crd/bases/awx.ansible.com_awxrestores.yaml b/config/crd/bases/awx.ansible.com_awxrestores.yaml index 8e2bb11b..03f12913 100644 --- a/config/crd/bases/awx.ansible.com_awxrestores.yaml +++ b/config/crd/bases/awx.ansible.com_awxrestores.yaml @@ -94,6 +94,9 @@ spec: postgres_image_version: description: PostgreSQL container image version to use type: string + db_management_pod_node_selector: + description: nodeSelector for the Postgres pods to backup + type: string no_log: description: Configure no_log for no_log tasks type: boolean diff --git a/roles/backup/defaults/main.yml b/roles/backup/defaults/main.yml index ee801377..437e60a1 100644 --- a/roles/backup/defaults/main.yml +++ b/roles/backup/defaults/main.yml @@ -17,6 +17,14 @@ no_log: true # Variable to set when you want backups to be cleaned up when the CRD object is deleted clean_backup_on_delete: false + +# Add a nodeSelector for the Postgres pods to backup. +# Specify as literal block. E.g.: +# db_management_pod_node_selector: | +# kubernetes.io/arch: amd64 +# kubernetes.io/os: linux +db_management_pod_node_selector: '' + # Variable to signal that this role is being run as a finalizer finalizer_run: false diff --git a/roles/backup/templates/management-pod.yml.j2 b/roles/backup/templates/management-pod.yml.j2 index 1a6c3100..ce2166c6 100644 --- a/roles/backup/templates/management-pod.yml.j2 +++ b/roles/backup/templates/management-pod.yml.j2 @@ -20,6 +20,10 @@ spec: resources: {{ backup_resource_requirements | to_nice_yaml(indent=2) | indent(width=6, first=False) }} {%- endif %} +{% if db_management_pod_node_selector %} + nodeSelector: + {{ db_management_pod_node_selector | indent(width=8) }} +{% endif %} volumes: - name: {{ ansible_operator_meta.name }}-backup persistentVolumeClaim: diff --git a/roles/restore/defaults/main.yml b/roles/restore/defaults/main.yml index 09430f10..5eaf29b4 100644 --- a/roles/restore/defaults/main.yml +++ b/roles/restore/defaults/main.yml @@ -17,6 +17,14 @@ cluster_name: 'cluster.local' # Set no_log settings on certain tasks no_log: true +# Add a nodeSelector for the Postgres pods to backup. +# Specify as literal block. E.g.: +# db_management_pod_node_selector: | +# kubernetes.io/arch: amd64 +# kubernetes.io/os: linux +db_management_pod_node_selector: '' + + # Default resource requirements restore_resource_requirements: limits: diff --git a/roles/restore/templates/management-pod.yml.j2 b/roles/restore/templates/management-pod.yml.j2 index 6cec51b2..084c5e28 100644 --- a/roles/restore/templates/management-pod.yml.j2 +++ b/roles/restore/templates/management-pod.yml.j2 @@ -20,6 +20,10 @@ spec: resources: {{ restore_resource_requirements | to_nice_yaml(indent=2) | indent(width=6, first=False) }} {%- endif %} +{% if db_management_pod_node_selector %} + nodeSelector: + {{ db_management_pod_node_selector | indent(width=8) }} +{% endif %} volumes: - name: {{ ansible_operator_meta.name }}-backup persistentVolumeClaim: