Integration of HTTPRoute Support in SonarQube Helm Chart

Hello,

I’ve been working with the SonarQube Helm chart and identified an opportunity to enhance its networking capabilities within Kubernetes environments. Given the emergence of the Kubernetes Gateway API, I propose integrating HTTPRoute support into the chart. This feature enables more sophisticated HTTP routing configurations, facilitating advanced traffic management directly from the Helm deployment.

Benefits:

  • Aligns SonarQube with Kubernetes’ latest features.
  • Simplifies the user experience for complex routing requirements.
  • Provides out-of-the-box advanced routing capabilities with minimal setup.

Proposed Changes:

  • A new section in the values.yaml to configure HTTPRoute.
  • Conditional templates within the chart to create HTTPRoute resources when enabled.

Here’s a brief example of how users could define HTTPRoute settings in values.yaml:

httproute:
  enabled: true
  hosts:
    - name: sonarqube.your-org.com
      paths:
        - path: /
          pathType: Prefix
  gw: gateway-name
  namespace: defualy

Here’s a brief example of how the HTTPRoute yaml will looks like:

{{- if .Values.httproute.enabled -}}
{{- $serviceName := include "sonarqube.fullname" . -}}
{{- $servicePort := .Values.service.externalPort -}}
apiVersion: gateway.networking.k8s.io/v1beta1
kind: HTTPRoute
metadata:
  name: {{ template "sonarqube.fullname" . }}
  labels:
    app: {{ template "sonarqube.name" . }}
    chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
    release: {{ .Release.Name }}
    heritage: {{ .Release.Service }}
{{- if .Values.httproute.labels }}
{{ toYaml .Values.httproute.labels | indent 4 }}
{{- end }}
  annotations:
    external-dns.alpha.kubernetes.io/hostname: "{{- $hosts := list -}}{{- range .Values.httproute.hosts }}{{- $hosts = append $hosts (printf "%s" .name) -}}{{- end }}{{ join ", " $hosts }}"
spec:
  hostnames:
  {{- range .Values.httproute.hosts }}
  - {{ printf "%s" .name }}
  {{- end }}
  parentRefs:
  - name: {{ .Values.httproute.gw }}
    namespace: {{ .Values.httproute.namespace }}
  rules:
  {{- range .Values.httproute.hosts }}
  - backendRefs:
    - name: {{ $serviceName }}
      port: {{ $servicePort }}
    matches:
    {{- range .paths }}
    - path:
        type: {{ .pathType }}
        value: {{ .path }}
    {{- end }}
  {{- end }}
{{- end }}

I have local repo with my changes.
Looking forward to your feedback on this proposal. If there is interest, I am prepared to contribute the necessary code changes.

Best regards,
Roey.

1 Like

Dear @Roey_Hadad,

Thanks for posting in our community and for proposing this feature.

We think it will bring value to our Helm users and I’ve just defined an improvement ticket for it SONAR-22097.

Given that you have a code change ready to be reviewed, why don’t you open a PR on GitHub - SonarSource/helm-chart-sonarqube? :slight_smile: We’ll be very happy to accept your contribution there!

1 Like