From fd4e3b2d4c9962787c6777a0f17f2ea9a71162c5 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Wed, 10 Feb 2021 10:00:28 +0100 Subject: [PATCH] Allow greater flexibility to specify resource requests/limits --- deploy/crds/awx_v1beta1_cr.yaml | 7 ------- deploy/crds/awx_v1beta1_molecule.yaml | 13 ++++++++----- .../awx-operator.clusterserviceversion.yaml | 10 ++++++++++ .../manifests/awx.ansible.com_awxs_crd.yaml | 6 ++++++ roles/installer/defaults/main.yml | 16 +++++++++++----- roles/installer/templates/tower.yaml.j2 | 10 ++-------- roles/installer/templates/tower_postgres.yaml.j2 | 4 +--- 7 files changed, 38 insertions(+), 28 deletions(-) diff --git a/deploy/crds/awx_v1beta1_cr.yaml b/deploy/crds/awx_v1beta1_cr.yaml index 206ccf3e..c242695b 100644 --- a/deploy/crds/awx_v1beta1_cr.yaml +++ b/deploy/crds/awx_v1beta1_cr.yaml @@ -16,17 +16,10 @@ spec: tower_image: ansible/awx:15.0.0 - tower_task_mem_request: 1Gi - tower_task_cpu_request: 500m - - tower_web_mem_request: 2Gi - tower_web_cpu_request: 1000m - tower_create_preload_data: true tower_memcached_image: memcached:alpine tower_redis_image: redis:latest - tower_postgres_storage_request: 8Gi tower_postgres_storage_class: '' diff --git a/deploy/crds/awx_v1beta1_molecule.yaml b/deploy/crds/awx_v1beta1_molecule.yaml index b09a4f51..60cf6d1e 100644 --- a/deploy/crds/awx_v1beta1_molecule.yaml +++ b/deploy/crds/awx_v1beta1_molecule.yaml @@ -15,11 +15,15 @@ spec: tower_image: ansible/awx:15.0.0 - tower_task_mem_request: 128M - tower_task_cpu_request: 500m + tower_web_resource_requirements: + requests: + cpu: 500m + memory: 128M - tower_web_mem_request: 128M - tower_web_cpu_request: 500m + tower_task_resource_requirements: + requests: + cpu: 500m + memory: 128M tower_create_preload_data: true @@ -29,5 +33,4 @@ spec: tower_postgres_pass: awxpass tower_postgres_image: postgres:12 - tower_postgres_storage_request: 8Gi tower_postgres_storage_class: '' 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 e88e44e5..695cf835 100644 --- a/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml +++ b/deploy/olm-catalog/awx-operator/manifests/awx-operator.clusterserviceversion.yaml @@ -113,6 +113,16 @@ spec: x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced - urn:alm:descriptor:com.tectonic.ui:imagePullPolicy + - displayName: Web container resource requirements + path: tower_web_resource_requirements + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:resourceRequirements + - displayName: Task container resource requirements + path: tower_task_resource_requirements + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:resourceRequirements - displayName: Replicas path: tower_replicas 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 154c8890..541f4dbe 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 @@ -49,6 +49,12 @@ spec: - Always - Never - IfNotPresent + tower_task_resource_requirements: + description: Resource requirements for the task container + type: object + tower_web_resource_requirements: + description: Resource requirements for the web container + type: object tower_replicas: description: Number of instance replicas type: integer diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index f5ede761..38da6b8e 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -51,11 +51,15 @@ tower_task_command: [] tower_web_args: [] tower_web_command: [] -tower_task_mem_request: 1Gi -tower_task_cpu_request: 500m +tower_task_resource_requirements: + requests: + cpu: 500m + memory: 1Gi -tower_web_mem_request: 2Gi -tower_web_cpu_request: 1000m +tower_web_resource_requirements: + requests: + cpu: 1000m + memory: 2Gi # Add extra environment variables to the AWX task/web containers. Specify as # literal block. E.g.: @@ -78,7 +82,9 @@ tower_web_extra_volume_mounts: '' tower_redis_image: redis:latest tower_postgres_image: postgres:12 -tower_postgres_storage_request: 8Gi +tower_postgres_resource_requirements: + requests: + storage: 8Gi tower_postgres_storage_class: '' tower_postgres_data_path: '/var/lib/postgresql/data/pgdata' diff --git a/roles/installer/templates/tower.yaml.j2 b/roles/installer/templates/tower.yaml.j2 index bbc47300..ac3e6986 100644 --- a/roles/installer/templates/tower.yaml.j2 +++ b/roles/installer/templates/tower.yaml.j2 @@ -91,10 +91,7 @@ spec: {% if tower_task_extra_env %} {{ tower_web_extra_env | indent(width=12, indentfirst=True) }} {% endif %} - resources: - requests: - memory: '{{ tower_web_mem_request }}' - cpu: '{{ tower_web_cpu_request }}' + resources: {{ tower_web_resource_requirements }} - image: '{{ tower_image }}' name: '{{ meta.name }}-task' imagePullPolicy: '{{ tower_image_pull_policy }}' @@ -155,10 +152,7 @@ spec: {% if tower_task_extra_env -%} {{ tower_task_extra_env | indent(width=12, indentfirst=True) }} {% endif %} - resources: - requests: - memory: '{{ tower_task_mem_request }}' - cpu: '{{ tower_task_cpu_request }}' + resources: {{ tower_task_resource_requirements }} volumes: - name: "{{ meta.name }}-application-credentials" secret: diff --git a/roles/installer/templates/tower_postgres.yaml.j2 b/roles/installer/templates/tower_postgres.yaml.j2 index 824a9057..cdfc3d5e 100644 --- a/roles/installer/templates/tower_postgres.yaml.j2 +++ b/roles/installer/templates/tower_postgres.yaml.j2 @@ -57,9 +57,7 @@ spec: {% if tower_postgres_storage_class != '' %} storageClassName: '{{ tower_postgres_storage_class }}' {% endif %} - resources: - requests: - storage: '{{ tower_postgres_storage_request }}' + resources: {{ tower_postgres_resource_requirements }} # Postgres Service. ---