From 108addc06e244720ed895301e21f47d83ad89bfb Mon Sep 17 00:00:00 2001 From: Juan Ezquerro LLanes Date: Tue, 1 Feb 2022 20:49:37 +0100 Subject: [PATCH] Allow service annotations not only for LoadBalancer --- README.md | 6 ++++-- config/crd/bases/awx.ansible.com_awxs.yaml | 6 +++--- config/manifests/bases/olm-parameters.yaml | 2 +- roles/installer/defaults/main.yml | 2 +- roles/installer/templates/service.yaml.j2 | 4 ++-- 5 files changed, 11 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index f16bc7f8..a4ca1ea3 100644 --- a/README.md +++ b/README.md @@ -241,12 +241,15 @@ The following variables are customizable for any `service_type` | Name | Description | Default | | ------------------------------------- | --------------------------------------------- | --------------------------------- | | service_labels | Add custom labels | Empty string | +| service_annotations | Add service annotations | Empty string | ```yaml --- spec: ... service_type: ClusterIP + service_annotations: | + environment: testing service_labels: | environment: testing ``` @@ -257,7 +260,6 @@ The following variables are customizable only when `service_type=LoadBalancer` | Name | Description | Default | | ------------------------------ | ---------------------------------------- | ------------- | -| loadbalancer_annotations | LoadBalancer annotations | Empty string | | loadbalancer_protocol | Protocol to use for Loadbalancer ingress | http | | loadbalancer_port | Port used for Loadbalancer ingress | 80 | @@ -268,7 +270,7 @@ spec: service_type: LoadBalancer loadbalancer_protocol: https loadbalancer_port: 443 - loadbalancer_annotations: | + service_annotations: | environment: testing service_labels: | environment: testing diff --git a/config/crd/bases/awx.ansible.com_awxs.yaml b/config/crd/bases/awx.ansible.com_awxs.yaml index 2623b4ad..82ff8087 100644 --- a/config/crd/bases/awx.ansible.com_awxs.yaml +++ b/config/crd/bases/awx.ansible.com_awxs.yaml @@ -67,6 +67,9 @@ spec: extra_volumes: description: Specify extra volumes to add to the application pod type: string + service_annotations: + description: Annotations to add to the service + type: string service_type: description: The service type to be used on the deployed instance type: string @@ -98,9 +101,6 @@ spec: ingress_tls_secret: description: Secret where the Ingress TLS secret can be found type: string - loadbalancer_annotations: - description: Annotations to add to the loadbalancer - type: string loadbalancer_protocol: description: Protocol to use for the loadbalancer type: string diff --git a/config/manifests/bases/olm-parameters.yaml b/config/manifests/bases/olm-parameters.yaml index f0cca852..de7f842b 100644 --- a/config/manifests/bases/olm-parameters.yaml +++ b/config/manifests/bases/olm-parameters.yaml @@ -199,7 +199,7 @@ - urn:alm:descriptor:io.kubernetes:Secret - urn:alm:descriptor:com.tectonic.ui:fieldDependency:ingress_type:Ingress - displayName: Tower LoadBalancer Annotations - path: loadbalancer_annotations + path: service_annotations x-descriptors: - urn:alm:descriptor:com.tectonic.ui:advanced - urn:alm:descriptor:com.tectonic.ui:text diff --git a/roles/installer/defaults/main.yml b/roles/installer/defaults/main.yml index 78e9415d..a4bc8874 100644 --- a/roles/installer/defaults/main.yml +++ b/roles/installer/defaults/main.yml @@ -36,7 +36,7 @@ ingress_tls_secret: '' loadbalancer_protocol: 'http' loadbalancer_port: '80' -loadbalancer_annotations: '' +service_annotations: '' nodeport_port: '30080' # The TLS termination mechanism to use to access diff --git a/roles/installer/templates/service.yaml.j2 b/roles/installer/templates/service.yaml.j2 index 5eac078f..3c5cc268 100644 --- a/roles/installer/templates/service.yaml.j2 +++ b/roles/installer/templates/service.yaml.j2 @@ -11,9 +11,9 @@ metadata: app.kubernetes.io/component: '{{ deployment_type }}' app.kubernetes.io/operator-version: '{{ lookup("env", "OPERATOR_VERSION") }}' {{ service_labels | indent(width=4) }} -{% if service_type | lower == 'loadbalancer' and loadbalancer_annotations %} +{% if service_annotations %} annotations: - {{ loadbalancer_annotations | indent(width=4) }} + {{ service_annotations | indent(width=4) }} {% endif %} spec: ports: