From b49d68ca928d4ee1fd0566dfb95e3281a11f5f23 Mon Sep 17 00:00:00 2001 From: jamesmarshall24 Date: Wed, 1 May 2024 15:47:23 -0400 Subject: [PATCH] Expose websockets on api prefix v2 (#1842) Expose websockets on controller v2 --- config/crd/bases/awx.ansible.com_awxs.yaml | 3 +++ .../bases/awx-operator.clusterserviceversion.yaml | 5 +++++ roles/installer/defaults/main.yml | 1 + roles/installer/templates/configmaps/config.yaml.j2 | 8 ++++++++ 4 files changed, 17 insertions(+) diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 34e441d13..cced65bc2 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -144,6 +144,9 @@ spec: ingress_controller: description: Special configuration for specific Ingress Controllers type: string + api_urlpattern_prefix: + description: An optional configuration to add a prefix in the API URL path + type: string loadbalancer_protocol: description: Protocol to use for the loadbalancer type: string diff --git a/config/manifests/bases/awx-operator.clusterserviceversion.yaml b/config/manifests/bases/awx-operator.clusterserviceversion.yaml index d7c9fa2de..f7af28f4e 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -58,6 +58,11 @@ spec: path: ingress_controller x-descriptors: - urn:alm:descriptor:com.tectonic.ui:text + - displayName: Optional API URLPATTERN Prefix + path: api_urlpattern_prefix + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:text - displayName: Image Pull Secrets path: image_pull_secrets x-descriptors: diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index db9d586f6..4e8a7c1f4 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -13,6 +13,7 @@ ingress_class_name: '' ingress_path: '/' ingress_path_type: 'Prefix' ingress_api_version: 'networking.k8s.io/v1' +api_urlpattern_prefix: '' # Add annotations to the service account. Specify as literal block. E.g.: # service_account_annotations: | # eks.amazonaws.com/role-arn: arn:aws:iam:::role/ diff --git a/roles/installer/templates/configmaps/config.yaml.j2 b/roles/installer/templates/configmaps/config.yaml.j2 index ae7a28673..17f556379 100644 --- a/roles/installer/templates/configmaps/config.yaml.j2 +++ b/roles/installer/templates/configmaps/config.yaml.j2 @@ -54,6 +54,10 @@ data: INTERNAL_API_URL = 'http://127.0.0.1:8052' +{% if api_urlpattern_prefix | length > 0 %} + OPTIONAL_API_URLPATTERN_PREFIX = '{{ api_urlpattern_prefix }}' +{% endif %} + # Container environments don't like chroots AWX_PROOT_ENABLED = False @@ -192,7 +196,11 @@ data: alias /var/lib/awx/public/static/media/favicon.ico; } +{% if api_urlpattern_prefix | length > 0 %} + location ~ ^({{ (ingress_path + '/websocket/').replace('//', '/') }}|{{ (ingress_path + '/api/websocket/').replace('//', '/') }}|{{ (ingress_path + '/api/' + api_urlpattern_prefix + '/v2/websocket/').replace('//', '/') }}) { +{% else %} location ~ ^({{ (ingress_path + '/websocket/').replace('//', '/') }}|{{ (ingress_path + '/api/websocket/').replace('//', '/') }}) { +{% endif %} # Pass request to the upstream alias proxy_pass http://daphne; # Require http version 1.1 to allow for upgrade requests