From 81153a309c1eeaf4f768a8a458c8c8b159041255 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=A9my=20Cotineau?= Date: Fri, 15 Nov 2024 09:30:28 +0100 Subject: [PATCH] sonar 23603 trigger 570 http route using gateway from other namespace * feat(httproute): support gateway in different namespace * SONAR-23603 trigger 570 http route using gateway from other namespace --------- Co-authored-by: Alyson Ferreira --- charts/sonarqube-dce/CHANGELOG.md | 1 + charts/sonarqube-dce/Chart.yaml | 2 ++ charts/sonarqube-dce/README.md | 15 ++++++++------- charts/sonarqube-dce/templates/http-route.yml | 5 ++++- charts/sonarqube-dce/values.yaml | 1 + charts/sonarqube/CHANGELOG.md | 1 + charts/sonarqube/Chart.yaml | 2 ++ charts/sonarqube/README.md | 15 ++++++++------- charts/sonarqube/templates/http-route.yaml | 5 ++++- charts/sonarqube/values.yaml | 1 + .../sonarqube-dce/http-routes-values.yaml | 1 + .../fixtures/sonarqube/http-routes-values.yaml | 1 + .../sonarqube-dce/http-routes-values.yaml | 3 ++- .../sonarqube/http-routes-values.yaml | 3 ++- 14 files changed, 38 insertions(+), 18 deletions(-) diff --git a/charts/sonarqube-dce/CHANGELOG.md b/charts/sonarqube-dce/CHANGELOG.md index 11b7c9cf5..6eaefff82 100644 --- a/charts/sonarqube-dce/CHANGELOG.md +++ b/charts/sonarqube-dce/CHANGELOG.md @@ -7,6 +7,7 @@ All changes to this chart will be documented in this file. * Support Kubernetes v1.31 * Update the Chart's icon with the SonarQube Server logo * Fix ENV variables not fetched when using extraConfig.configmaps +* Support Gateway on different namespace in HTTPRoute ## [10.7.0] * Update Chart's version to 10.7.0 diff --git a/charts/sonarqube-dce/Chart.yaml b/charts/sonarqube-dce/Chart.yaml index 026d495d1..8c9605008 100644 --- a/charts/sonarqube-dce/Chart.yaml +++ b/charts/sonarqube-dce/Chart.yaml @@ -37,6 +37,8 @@ annotations: description: "Update the Chart's icon with the SonarQube Server logo" - kind: fixed description: "Fix ENV variables not fetched when using extraConfig.configmaps" + - kind: added + description: "Support Gateway on different namespace in HTTPRoute" artifacthub.io/links: | - name: support url: https://community.sonarsource.com/ diff --git a/charts/sonarqube-dce/README.md b/charts/sonarqube-dce/README.md index 015bafe05..65acfa064 100644 --- a/charts/sonarqube-dce/README.md +++ b/charts/sonarqube-dce/README.md @@ -443,13 +443,14 @@ The following table lists the configurable parameters of the SonarQube chart and ### HttpRoute -| Parameter | Description | Default | -| --------------------- | ------------------------------------------------------------------------------------------------------------- | ------- | -| `httproute.enabled` | Flag to enable GatewayAPI HttpRoute | `False` | -| `httproute.gateway` | Name of the gateway located in the same namespace | `None` | -| `httproute.hostnames` | List of hostnames to match the HttpRoute against | `None` | -| `httproute.labels` | (Optional) List of extra labels to add to the HttpRoute | `None` | -| `httproute.rules` | (Optional) Extra Rules block of the HttpRoute. A default one is created with SonarWebContext and service port | `None` | +| Parameter | Description | Default | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------- | ------- | +| `httproute.enabled` | Flag to enable GatewayAPI HttpRoute | `False` | +| `httproute.gateway` | Name of the gateway | `None` | +| `httproute.gatewayNamespace` | (Optional) Name of the gateway namespace when located in a different namespace | `None` | +| `httproute.hostnames` | List of hostnames to match the HttpRoute against | `None` | +| `httproute.labels` | (Optional) List of extra labels to add to the HttpRoute | `None` | +| `httproute.rules` | (Optional) Extra Rules block of the HttpRoute. A default one is created with SonarWebContext and service port | `None` | ### Elasticsearch diff --git a/charts/sonarqube-dce/templates/http-route.yml b/charts/sonarqube-dce/templates/http-route.yml index d58a5580e..d0cf51740 100644 --- a/charts/sonarqube-dce/templates/http-route.yml +++ b/charts/sonarqube-dce/templates/http-route.yml @@ -14,6 +14,9 @@ metadata: spec: parentRefs: - name: {{ .Values.httproute.gateway }} + {{- if .Values.httproute.gatewayNamespace }} + namespace: {{ .Values.httproute.gatewayNamespace }} + {{- end }} hostnames: {{- with .Values.httproute.hostnames }} {{ toYaml . }} @@ -32,4 +35,4 @@ spec: - name: {{ include "sonarqube.fullname" . }} port: {{ .Values.service.externalPort }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/sonarqube-dce/values.yaml b/charts/sonarqube-dce/values.yaml index dde816f9c..354b1a7d2 100644 --- a/charts/sonarqube-dce/values.yaml +++ b/charts/sonarqube-dce/values.yaml @@ -460,6 +460,7 @@ ingress-nginx: httproute: enabled: false # gateway: my-gateway + # gatewayNamespace: my-gateway-namespace # optional # labels: # somelabel: somevalue # hostnames: diff --git a/charts/sonarqube/CHANGELOG.md b/charts/sonarqube/CHANGELOG.md index ef334f236..3c7d98469 100644 --- a/charts/sonarqube/CHANGELOG.md +++ b/charts/sonarqube/CHANGELOG.md @@ -10,6 +10,7 @@ All changes to this chart will be documented in this file. * Deprecate the default value of `image.tag` in favor of an empty string * Update the Chart's icon with the SonarQube Server logo * Set `app.kubernetes.io/name` and `app.kubernetes.io/version` as selector labels +* Support Gateway on different namespace in HTTPRoute ## [10.7.0] * Update Chart's version to 10.7.0 diff --git a/charts/sonarqube/Chart.yaml b/charts/sonarqube/Chart.yaml index 44df076ab..86c8d56b1 100644 --- a/charts/sonarqube/Chart.yaml +++ b/charts/sonarqube/Chart.yaml @@ -48,6 +48,8 @@ annotations: description: "Update the Chart's icon with the SonarQube Server logo" - kind: fixed description: "Set 'app.kubernetes.io/name' and 'app.kubernetes.io/version' as selector labels" + - kind: added + description: "Support Gateway on different namespace in HTTPRoute" artifacthub.io/containsSecurityUpdates: "false" artifacthub.io/images: | - name: sonarqube diff --git a/charts/sonarqube/README.md b/charts/sonarqube/README.md index 02e27542d..1cac58ac6 100644 --- a/charts/sonarqube/README.md +++ b/charts/sonarqube/README.md @@ -333,13 +333,14 @@ The following table lists the configurable parameters of the SonarQube chart and ### HttpRoute -| Parameter | Description | Default | -| --------------------- | ------------------------------------------------------------------------------------------------------------- | ------- | -| `httproute.enabled` | Flag to enable GatewayAPI HttpRoute | `False` | -| `httproute.gateway` | Name of the gateway located in the same namespace | `None` | -| `httproute.hostnames` | List of hostnames to match the HttpRoute against | `None` | -| `httproute.labels` | (Optional) List of extra labels to add to the HttpRoute | `None` | -| `httproute.rules` | (Optional) Extra Rules block of the HttpRoute. A default one is created with SonarWebContext and service port | `None` | +| Parameter | Description | Default | +| ---------------------------- | ------------------------------------------------------------------------------------------------------------- | ------- | +| `httproute.enabled` | Flag to enable GatewayAPI HttpRoute | `False` | +| `httproute.gateway` | Name of the gateway | `None` | +| `httproute.gatewayNamespace` | (Optional) Name of the gateway namespace when located in a different namespace | `None` | +| `httproute.hostnames` | List of hostnames to match the HttpRoute against | `None` | +| `httproute.labels` | (Optional) List of extra labels to add to the HttpRoute | `None` | +| `httproute.rules` | (Optional) Extra Rules block of the HttpRoute. A default one is created with SonarWebContext and service port | `None` | ### Probes diff --git a/charts/sonarqube/templates/http-route.yaml b/charts/sonarqube/templates/http-route.yaml index dc3945c64..4bc12ad3a 100644 --- a/charts/sonarqube/templates/http-route.yaml +++ b/charts/sonarqube/templates/http-route.yaml @@ -11,6 +11,9 @@ metadata: spec: parentRefs: - name: {{ .Values.httproute.gateway }} + {{- if .Values.httproute.gatewayNamespace }} + namespace: {{ .Values.httproute.gatewayNamespace }} + {{- end }} hostnames: {{- with .Values.httproute.hostnames }} {{ toYaml . }} @@ -29,4 +32,4 @@ spec: - name: {{ include "sonarqube.fullname" . }} port: {{ .Values.service.externalPort }} {{- end }} -{{- end }} \ No newline at end of file +{{- end }} diff --git a/charts/sonarqube/values.yaml b/charts/sonarqube/values.yaml index 3b3fcba98..0890ff82c 100644 --- a/charts/sonarqube/values.yaml +++ b/charts/sonarqube/values.yaml @@ -142,6 +142,7 @@ ingress-nginx: httproute: enabled: false # gateway: my-gateway + # gatewayNamespace: my-gateway-namespace # optional # labels: # somelabel: somevalue # hostnames: diff --git a/tests/unit-compatibility-test/fixtures/sonarqube-dce/http-routes-values.yaml b/tests/unit-compatibility-test/fixtures/sonarqube-dce/http-routes-values.yaml index 8a213e035..74748f409 100644 --- a/tests/unit-compatibility-test/fixtures/sonarqube-dce/http-routes-values.yaml +++ b/tests/unit-compatibility-test/fixtures/sonarqube-dce/http-routes-values.yaml @@ -955,6 +955,7 @@ metadata: spec: parentRefs: - name: my-gateway + namespace: my-gateway-namespace hostnames: - sonarqube.your-org.com rules: diff --git a/tests/unit-compatibility-test/fixtures/sonarqube/http-routes-values.yaml b/tests/unit-compatibility-test/fixtures/sonarqube/http-routes-values.yaml index 41c5d4a4f..38f0f87c5 100644 --- a/tests/unit-compatibility-test/fixtures/sonarqube/http-routes-values.yaml +++ b/tests/unit-compatibility-test/fixtures/sonarqube/http-routes-values.yaml @@ -577,6 +577,7 @@ metadata: spec: parentRefs: - name: my-gateway + namespace: my-gateway-namespace hostnames: - sonarqube.your-org.com rules: diff --git a/tests/unit-compatibility-test/sonarqube-dce/http-routes-values.yaml b/tests/unit-compatibility-test/sonarqube-dce/http-routes-values.yaml index ee3d320ea..c014b1b8f 100644 --- a/tests/unit-compatibility-test/sonarqube-dce/http-routes-values.yaml +++ b/tests/unit-compatibility-test/sonarqube-dce/http-routes-values.yaml @@ -1,6 +1,7 @@ httproute: enabled: true gateway: my-gateway + gatewayNamespace: my-gateway-namespace hostnames: - sonarqube.your-org.com rules: @@ -10,4 +11,4 @@ httproute: value: / backendRefs: - name: http-routes-default-values.yaml-sonarqube - port: 9000 \ No newline at end of file + port: 9000 diff --git a/tests/unit-compatibility-test/sonarqube/http-routes-values.yaml b/tests/unit-compatibility-test/sonarqube/http-routes-values.yaml index ee3d320ea..c014b1b8f 100644 --- a/tests/unit-compatibility-test/sonarqube/http-routes-values.yaml +++ b/tests/unit-compatibility-test/sonarqube/http-routes-values.yaml @@ -1,6 +1,7 @@ httproute: enabled: true gateway: my-gateway + gatewayNamespace: my-gateway-namespace hostnames: - sonarqube.your-org.com rules: @@ -10,4 +11,4 @@ httproute: value: / backendRefs: - name: http-routes-default-values.yaml-sonarqube - port: 9000 \ No newline at end of file + port: 9000