From 918e4874221380074cb0c0e066804f1d271e3297 Mon Sep 17 00:00:00 2001 From: Hao Liu Date: Wed, 8 Feb 2023 12:56:41 -0500 Subject: [PATCH] Add web and task replicas to the CRD (#1227) add web_replicas and task_replicas Co-Authored-By: Jake Jackson <24478650+thedoubl3j@users.noreply.github.com> --- config/crd/bases/awx.ansible.com_awxs.yaml | 7 +++++-- roles/installer/defaults/main.yml | 5 +++-- roles/installer/templates/deployments/task.yaml.j2 | 5 +++++ roles/installer/templates/deployments/web.yaml.j2 | 12 ++++++++---- 4 files changed, 21 insertions(+), 8 deletions(-) diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 8a30f9b0..97ca3196 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -1436,15 +1436,18 @@ spec: service_account_annotations: description: ServiceAccount annotations type: string + replicas: + description: Number of instance replicas + type: integer + default: 1 + format: int32 web_replicas: description: Number of web instance replicas type: integer - default: 1 format: int32 task_replicas: description: Number of task instance replicas type: integer - default: 1 format: int32 garbage_collect_secrets: description: Whether or not to remove secrets upon instance removal diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 63f2765b..e5a3ff12 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -238,8 +238,9 @@ _init_projects_container_image: quay.io/centos/centos:stream9 create_preload_data: true -web_replicas: "1" -task_replicas: "1" +replicas: "1" +web_replicas: '' +task_replicas: '' task_args: - /usr/bin/launch_awx_task.sh diff --git a/roles/installer/templates/deployments/task.yaml.j2 b/roles/installer/templates/deployments/task.yaml.j2 index fa5f96bc..d0be1739 100644 --- a/roles/installer/templates/deployments/task.yaml.j2 +++ b/roles/installer/templates/deployments/task.yaml.j2 @@ -8,7 +8,11 @@ metadata: {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} {{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=4) | trim }} spec: +{% if task_replicas %} replicas: {{ task_replicas }} +{% elif replicas %} + replicas: {{ replicas }} +{% endif %} selector: matchLabels: app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-task' @@ -17,6 +21,7 @@ spec: template: metadata: labels: + app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-task' {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=8) | trim }} {{ lookup("template", "../common/templates/labels/version.yaml.j2") | indent(width=8) | trim }} annotations: diff --git a/roles/installer/templates/deployments/web.yaml.j2 b/roles/installer/templates/deployments/web.yaml.j2 index 2d05552b..855861cd 100644 --- a/roles/installer/templates/deployments/web.yaml.j2 +++ b/roles/installer/templates/deployments/web.yaml.j2 @@ -6,10 +6,14 @@ metadata: namespace: '{{ ansible_operator_meta.namespace }}' labels: app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-web' - {{ lookup("template", "labels/common.yaml.j2") | indent(width=4) | trim }} - {{ lookup("template", "labels/version.yaml.j2") | indent(width=4) | trim }} + {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} + {{ lookup("template", "../common/templates/labels//version.yaml.j2") | indent(width=4) | trim }} spec: +{% if web_replicas %} replicas: {{ web_replicas }} +{% elif replicas %} + replicas: {{ replicas }} +{% endif %} selector: matchLabels: app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-web' @@ -19,8 +23,8 @@ spec: metadata: labels: app.kubernetes.io/name: '{{ ansible_operator_meta.name }}-web' - {{ lookup("template", "labels/common.yaml.j2") | indent(width=8) | trim }} - {{ lookup("template", "labels/version.yaml.j2") | indent(width=8) | trim }} + {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=8) | trim }} + {{ lookup("template", "../common/templates/labels//version.yaml.j2") | indent(width=8) | trim }} {% if annotations %} annotations: {{ annotations | indent(width=8) }}