From faf51c8b249549b7dea6b05d06283559086769ed Mon Sep 17 00:00:00 2001 From: Lukas Magauer <42647570+lumarel@users.noreply.github.com> Date: Wed, 12 Apr 2023 20:29:21 +0200 Subject: [PATCH] Add websocket configuration for contour ingress (#1320) Co-authored-by: lumarel --- README.md | 17 +++++++++++++++++ config/crd/bases/awx.ansible.com_awxs.yaml | 3 +++ .../awx-operator.clusterserviceversion.yaml | 6 ++++++ roles/installer/defaults/main.yml | 4 ++++ .../templates/networking/ingress.yaml.j2 | 17 ++++++++++++++++- 5 files changed, 46 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index cbcb0cfd..213075d1 100644 --- a/README.md +++ b/README.md @@ -477,6 +477,23 @@ spec: environment: testing ``` +##### Specialized Ingress Controller configuration + +Some Ingress Controllers need a special configuration to fully support AWX, add the following value with the `ingress_controller` variable, if you are using one of these: + +| Ingress Controller name | value | +| ------------------------------------- | ------- | +| [Contour](https://projectcontour.io/) | contour | + +```yaml +--- +spec: + ... + ingress_type: ingress + hostname: awx-demo.example.com + ingress_controller: contour +``` + * Route The following variables are customizable when `ingress_type=route` diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 3e0fef0f..4f4bda76 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -121,6 +121,9 @@ spec: ingress_class_name: description: The name of ingress class to use instead of the cluster default. type: string + ingress_controller: + description: Special configuration for specific Ingress Controllers + 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 656a07be..2afad2ca 100644 --- a/config/manifests/bases/awx-operator.clusterserviceversion.yaml +++ b/config/manifests/bases/awx-operator.clusterserviceversion.yaml @@ -251,6 +251,12 @@ spec: - urn:alm:descriptor:com.tectonic.ui:advanced - urn:alm:descriptor:io.kubernetes:Secret - urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress + - displayName: Ingress Controller + path: ingress_controller + x-descriptors: + - urn:alm:descriptor:com.tectonic.ui:advanced + - urn:alm:descriptor:com.tectonic.ui:text + - urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress - displayName: LoadBalancer Annotations path: service_annotations x-descriptors: diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 52713f6b..8c97fcff 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -36,6 +36,10 @@ ingress_annotations: '' # certificate and key. ingress_tls_secret: '' +# Special configuration for specific Ingress Controllers. E.g.: +# ingress_controller: contour +ingress_controller: '' + loadbalancer_protocol: 'http' loadbalancer_port: '80' service_annotations: '' diff --git a/roles/installer/templates/networking/ingress.yaml.j2 b/roles/installer/templates/networking/ingress.yaml.j2 index cd4356b5..cf3ec787 100644 --- a/roles/installer/templates/networking/ingress.yaml.j2 +++ b/roles/installer/templates/networking/ingress.yaml.j2 @@ -9,10 +9,16 @@ metadata: namespace: '{{ ansible_operator_meta.namespace }}' labels: {{ lookup("template", "../common/templates/labels/common.yaml.j2") | indent(width=4) | trim }} -{% if ingress_annotations %} +{% if ingress_annotations or ingress_controller|lower == "contour" %} annotations: +{% if ingress_annotations %} {{ ingress_annotations | indent(width=4) }} {% endif %} +{% if ingress_controller|lower == "contour" %} + projectcontour.io/websocket-routes: "/websocket" + kubernetes.io/ingress.class: contour +{% endif %} +{% endif %} spec: {% if ingress_class_name %} ingressClassName: '{{ ingress_class_name }}' @@ -27,6 +33,15 @@ spec: name: '{{ ansible_operator_meta.name }}-service' port: number: 80 +{% if ingress_controller|lower == "contour" %} + - path: '{{ ingress_path }}/websocket' + pathType: '{{ ingress_path_type }}' + backend: + service: + name: '{{ ansible_operator_meta.name }}-service' + port: + number: 80 +{% endif %} {% if hostname %} host: {{ hostname }} {% endif %}