From 151ff117454f70eeeeae86063c534fe3b3171cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20P=C3=A9rez?= Date: Tue, 13 Apr 2021 13:50:14 +0200 Subject: [PATCH 1/5] Add nodeSelector and tolerations for Postgres pod --- ansible/templates/crd.yml.j2 | 6 ++++++ deploy/awx-operator.yaml | 6 ++++++ deploy/crds/awx_v1beta1_crd.yaml | 6 ++++++ .../awx-operator.clusterserviceversion.yaml | 10 ++++++++++ .../manifests/awx.ansible.com_awxs_crd.yaml | 6 ++++++ roles/installer/defaults/main.yml | 19 +++++++++++++++++++ .../templates/tower_postgres.yaml.j2 | 8 ++++++++ 7 files changed, 61 insertions(+) diff --git a/ansible/templates/crd.yml.j2 b/ansible/templates/crd.yml.j2 index beec0b25..f91d7e48 100644 --- a/ansible/templates/crd.yml.j2 +++ b/ansible/templates/crd.yml.j2 @@ -224,6 +224,12 @@ spec: tower_postgres_image: description: Registry path to the PostgreSQL container to use type: string + tower_postgres_selector: + description: nodeSelector for the Postgres pods + type: string + tower_postgres_tolerations: + description: node tolerations for the Postgres pods + type: string tower_postgres_resource_requirements: description: Resource requirements for the PostgreSQL container properties: diff --git a/deploy/awx-operator.yaml b/deploy/awx-operator.yaml index 60d4b34c..d3d1c250 100644 --- a/deploy/awx-operator.yaml +++ b/deploy/awx-operator.yaml @@ -226,6 +226,12 @@ spec: tower_postgres_image: description: Registry path to the PostgreSQL container to use type: string + tower_postgres_selector: + description: nodeSelector for the Postgres pods + type: string + tower_postgres_tolerations: + description: node tolerations for the Postgres pods + type: string tower_postgres_resource_requirements: description: Resource requirements for the PostgreSQL container properties: diff --git a/deploy/crds/awx_v1beta1_crd.yaml b/deploy/crds/awx_v1beta1_crd.yaml index beec0b25..f91d7e48 100644 --- a/deploy/crds/awx_v1beta1_crd.yaml +++ b/deploy/crds/awx_v1beta1_crd.yaml @@ -224,6 +224,12 @@ spec: tower_postgres_image: description: Registry path to the PostgreSQL container to use type: string + tower_postgres_selector: + description: nodeSelector for the Postgres pods + type: string + tower_postgres_tolerations: + description: node tolerations for the Postgres pods + type: string tower_postgres_resource_requirements: description: Resource requirements for the PostgreSQL container properties: diff --git a/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml b/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml index 5755c63e..1e2d12a9 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml @@ -214,6 +214,16 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced - urn:alm:descriptor:com.tectonic.ui:hidden + - displayName: Tower Postgres Selector + path: tower_postgres_selector + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden + - displayName: Tower Postgres Tolerations + path: tower_postgres_tolerations + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:hidden - displayName: Tower Postgres Storage Class path: tower_postgres_storage_class x-descriptors: diff --git a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml index 00bf9aed..d33dc3cf 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx.ansible.com_awxs_crd.yaml @@ -134,6 +134,12 @@ spec: tower_postgres_image: description: Registry path to the PostgreSQL container to use type: string + tower_postgres_selector: + description: nodeSelector for the Postgres pods + type: string + tower_postgres_tolerations: + description: node tolerations for the Postgres pods + type: string tower_postgres_resource_requirements: description: Resource requirements for the PostgreSQL container properties: diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 108bee84..151b6317 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -130,6 +130,25 @@ tower_web_extra_volume_mounts: '' tower_redis_image: redis:latest tower_postgres_image: postgres:12 + +# Add a nodeSelector for the Postgres pods. +# It must match a node's labels for the pod to be scheduled on that node. +# Specify as literal block. E.g.: +# tower_postgres_selector: | +# disktype: ssd +# kubernetes.io/arch: amd64 +# kubernetes.io/os: linux +tower_postgres_selector: '' + +# Add node tolerations for the Postgres pods. +#Specify as literal block. E.g.: +# tower_postgres_tolerations: | +# - key: "dedicated" +# operator: "Equal" +# value: "AWX" +# effect: "NoSchedule" +tower_postgres_tolerations: '' + tower_postgres_resource_requirements: requests: storage: 8Gi diff --git a/roles/installer/templates/tower_postgres.yaml.j2 b/roles/installer/templates/tower_postgres.yaml.j2 index 009f7b02..cf7fc232 100644 --- a/roles/installer/templates/tower_postgres.yaml.j2 +++ b/roles/installer/templates/tower_postgres.yaml.j2 @@ -60,6 +60,14 @@ spec: - name: postgres mountPath: '{{ tower_postgres_data_path | dirname }}' subPath: '{{ tower_postgres_data_path | dirname | basename }}' +{% if tower_node_selector %} + nodeSelector: + {{ tower_node_selector | indent(width=8) }} +{% endif %} +{% if tower_tolerations %} + tolerations: + {{ tower_tolerations | indent(width=8) }} +{% endif %} volumeClaimTemplates: - metadata: name: postgres From 30e4ad0d3d6f691f273231266c10e818b56e41fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20P=C3=A9rez?= Date: Tue, 13 Apr 2021 14:00:15 +0200 Subject: [PATCH 2/5] Postgres selector and tolerations description included in README.md --- README.md | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 1920685c..1be5b2e9 100644 --- a/README.md +++ b/README.md @@ -325,15 +325,17 @@ spec: #### Assigning AWX pods to specific nodes -You can constrain the AWX pods created by the operator to run on a certain subset of nodes. `tower_node_selector` constrains -the AWX pods to run only on the nodes that match all the specified key/value pairs. `tower_tolerations` allow the AWX +You can constrain the AWX pods created by the operator to run on a certain subset of nodes. `tower_node_selector` and `tower_postgres_selector` constrains +the AWX pods to run only on the nodes that match all the specified key/value pairs. `tower_tolerations` and `tower_postgres_tolerations` allow the AWX pods to be scheduled onto nodes with matching taints. -| Name | Description | Default | -| ------------------- | ---------------------- | ------- | -| tower_node_selector | AWX pods' nodeSelector | '' | -| tower_tolerations | AWX pods' tolerations | '' | +| Name | Description | Default | +| -------------------------- | --------------------------- | ------- | +| tower_node_selector | AWX pods' nodeSelector | '' | +| tower_tolerations | AWX pods' tolerations | '' | +| tower_postgres_selector | Postgres pods' nodeSelector | '' | +| tower_postgres_tolerations | Postgres pods' tolerations | '' | Example of customization could be: @@ -350,6 +352,15 @@ spec: operator: "Equal" value: "AWX" effect: "NoSchedule" + tower_postgres_selector: | + disktype: ssd + kubernetes.io/arch: amd64 + kubernetes.io/os: linux + tower_postgres_tolerations: | + - key: "dedicated" + operator: "Equal" + value: "AWX" + effect: "NoSchedule" ``` #### LDAP Certificate Authority From 0ab33a17df7416fb9d857e5ac21e62bdaf54d874 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20P=C3=A9rez?= Date: Tue, 13 Apr 2021 14:33:47 +0200 Subject: [PATCH 3/5] Fix yaml missing starting space in comment --- roles/installer/defaults/main.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 151b6317..1335a559 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -141,7 +141,7 @@ tower_postgres_image: postgres:12 tower_postgres_selector: '' # Add node tolerations for the Postgres pods. -#Specify as literal block. E.g.: +# Specify as literal block. E.g.: # tower_postgres_tolerations: | # - key: "dedicated" # operator: "Equal" From 1cc47f75703431f2b9fa456d56b19c4994b68d18 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20P=C3=A9rez?= Date: Wed, 14 Apr 2021 09:56:06 +0200 Subject: [PATCH 4/5] Correction, replace tower_node_selector by tower_postgres_selector --- roles/installer/templates/tower_postgres.yaml.j2 | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/roles/installer/templates/tower_postgres.yaml.j2 b/roles/installer/templates/tower_postgres.yaml.j2 index cf7fc232..02885b16 100644 --- a/roles/installer/templates/tower_postgres.yaml.j2 +++ b/roles/installer/templates/tower_postgres.yaml.j2 @@ -60,11 +60,11 @@ spec: - name: postgres mountPath: '{{ tower_postgres_data_path | dirname }}' subPath: '{{ tower_postgres_data_path | dirname | basename }}' -{% if tower_node_selector %} +{% if tower_postgres_selector %} nodeSelector: - {{ tower_node_selector | indent(width=8) }} + {{ tower_postgres_selector | indent(width=8) }} {% endif %} -{% if tower_tolerations %} +{% if tower_postgres_tolerations %} tolerations: {{ tower_tolerations | indent(width=8) }} {% endif %} From d4d9d2a982b2e37b0fda17fecce9f467b9c4093b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ernesto=20P=C3=A9rez?= Date: Wed, 14 Apr 2021 09:59:50 +0200 Subject: [PATCH 5/5] Correction, replace tower_tolerations by tower_postgres_tolerations --- roles/installer/templates/tower_postgres.yaml.j2 | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/roles/installer/templates/tower_postgres.yaml.j2 b/roles/installer/templates/tower_postgres.yaml.j2 index 02885b16..18d2ae96 100644 --- a/roles/installer/templates/tower_postgres.yaml.j2 +++ b/roles/installer/templates/tower_postgres.yaml.j2 @@ -66,8 +66,8 @@ spec: {% endif %} {% if tower_postgres_tolerations %} tolerations: - {{ tower_tolerations | indent(width=8) }} -{% endif %} + {{ tower_postgres_tolerations | indent(width=8) }} +{% endif %} volumeClaimTemplates: - metadata: name: postgres