Skip to content

Commit 7b0c1c7

Browse files
SONAR-25455 Integrate SonarQube Server with Istio
1 parent 8ce5861 commit 7b0c1c7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1227
-16
lines changed

.cirrus/tasks_templates.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ container_template: &STD_CONTAINER_TEMPLATE
3030

3131
vm_instance_template: &VM_TEMPLATE
3232
image: docker-builder-v*
33-
type: t2.xlarge
33+
type: c5.4xlarge
3434
region: eu-central-1
35-
cpu: 4
36-
memory: 16Gb
35+
cpu: 16
36+
memory: 32Gb
3737

3838
clone_script_template: &CLONE_SCRIPT_TEMPLATE
3939
clone_script: |

charts/sonarqube-dce/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ All changes to this chart will be documented in this file.
66
* Upgrade nginx subchart to 4.12.3
77
* Support Kubernetes v1.33
88
* Added validation to ensure that either the `applicationNodes.jwtSecret` or `applicationNodes.jwtExistingSecret` value is set
9+
* Support the deployment with Istio
910

1011
## [2025.3.0]
1112
* Update Chart's version to 2025.3.0

charts/sonarqube-dce/Chart.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@ annotations:
3333
description: "Support Kubernetes v1.33"
3434
- kind: added
3535
description: "Added validation to ensure that either the applicationNodes.jwtSecret or applicationNodes.jwtExistingSecret value is set"
36+
- kind: added
37+
description: "Support the deployment with Istio"
3638
artifacthub.io/links: |
3739
- name: support
3840
url: https://community.sonarsource.com/

charts/sonarqube-dce/README.md

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ Prior to SonarQube Server Datacenter 10.8, we used a different naming convention
152152

153153
Starting from 10.8, we advise users to rename your `ApplicationNodes` to `applicationNodes`. While this is a straightforward change for users, ensuring cross-compability between both usage is challenging (if you are interested in the technical implementation, please take a look at this [PR](https://github.com/SonarSource/helm-chart-sonarqube/pull/586)).
154154

155-
Please report any encountered bugs to https://community.sonarsource.com/.
155+
Please report any encountered bugs to <https://community.sonarsource.com/>.
156156

157157
#### Cpu and memory settings
158158

@@ -251,6 +251,25 @@ kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/late
251251
252252
```
253253

254+
## Working with Istio
255+
256+
When deploying SonarQube in an Istio service mesh environment, you need to configure fixed ports for Hazelcast communication between application nodes. This is required because Istio's sidecar proxy needs to know all ports in advance for traffic management, security policies, and observability.
257+
258+
By default, SonarQube's Hazelcast cluster uses dynamic port allocation, which conflicts with Istio's requirement for explicit port declarations in service definitions and network policies. To resolve this, you must set fixed ports for the following Hazelcast communication channels:
259+
260+
* `applicationNodes.webPort` - Used by the Web process for cluster communication
261+
* `applicationNodes.cePort` - Used by the Compute Engine process for cluster communication
262+
263+
**Example configuration:**
264+
265+
```yaml
266+
applicationNodes:
267+
webPort: 9001 # Web process communication
268+
cePort: 9002 # Compute Engine process communication
269+
```
270+
271+
This ensures that Istio can properly route traffic, apply security policies, and provide telemetry for all inter-node communication within the SonarQube cluster.
272+
254273
### Upgrading the Helm chart
255274

256275
When upgrading your SonarQube instance, due to high CPU usage, it is recommended to disable the autoscaling before the upgrade process, re-enabling it afterwards.
@@ -344,7 +363,6 @@ The following table lists the configurable parameters of the SonarQube chart and
344363
| `searchNodes.affinity` | Node / Pod affinities for searchNodes, global affinity takes precedence | `{}` |
345364
| `searchNodes.tolerations` | List of node taints to tolerate for searchNodes, global tolerations take precedence | `[]` |
346365
347-
348366
### App Nodes Configuration
349367
350368
| Parameter | Description | Default |
@@ -432,7 +450,9 @@ The following table lists the configurable parameters of the SonarQube chart and
432450
| `applicationNodes.nodeSelector` | Node labels for application nodes' pods assignment, global nodeSelector takes precedence | `{}` |
433451
| `applicationNodes.affinity` | Node / Pod affinities for applicationNodes, global affinity takes precedence | `{}` |
434452
| `applicationNodes.tolerations` | List of node taints to tolerate for applicationNodes, global tolerations take precedence | `[]` |
435-
453+
| `applicationNodes.port` | The Hazelcast port for communication with each application member of the cluster. | `9003` |
454+
| `applicationNodes.webPort` | The Hazelcast port for communication with the WebServer process. If not specified, a dynamic port will be chosen. | `` |
455+
| `applicationNodes.cePort` | The Hazelcast port for communication with the ComputeEngine process. If not specified, a dynamic port will be chosen | `` |
436456
437457
### Generic Configuration
438458
@@ -619,7 +639,6 @@ The bundled PostgreSQL Chart is deprecated. Please see <https://artifacthub.io/p
619639
| `extraConfig.secrets` | A list of `Secret`s (which must contain key/value pairs) | `[]` |
620640
| `extraConfig.configmaps` | A list of `ConfigMap`s (which must contain key/value pairs) | `[]` |
621641
622-
623642
### SetAdminPassword
624643
625644
| Parameter | Description | Default |
@@ -635,7 +654,6 @@ The bundled PostgreSQL Chart is deprecated. Please see <https://artifacthub.io/p
635654
| `setAdminPassword.image` | Curl container image | `"image.repository":"image.tag"` |
636655
| `setAdminPassword.annotations` | Custom annotations for admin hook Job | `{}` |
637656
638-
639657
### Advanced Options
640658
641659
| Parameter | Description | Default |

charts/sonarqube-dce/templates/_helpers.tpl

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -563,3 +563,41 @@ Remove incompatible user/group values that do not work in Openshift out of the b
563563
{{- end -}}
564564
{{- end -}}
565565
{{- end -}}
566+
567+
{{/*
568+
Generate required Hazelcast cluster properties when custom ports are configured.
569+
This helper automatically sets the sonar.cluster.node properties when any of the
570+
Hazelcast ports (port, webPort, cePort) are configured, ensuring proper cluster communication.
571+
*/}}
572+
{{- define "sonarqube.hazelcastProperties" -}}
573+
{{- $props := dict -}}
574+
{{- if .Values.ApplicationNodes.port -}}
575+
{{- $_ := set $props "sonar.cluster.node.port" (.Values.ApplicationNodes.port | toString) -}}
576+
{{- end -}}
577+
{{- if .Values.ApplicationNodes.webPort -}}
578+
{{- $_ := set $props "sonar.cluster.node.web.port" (.Values.ApplicationNodes.webPort | toString) -}}
579+
{{- end -}}
580+
{{- if .Values.ApplicationNodes.cePort -}}
581+
{{- $_ := set $props "sonar.cluster.node.ce.port" (.Values.ApplicationNodes.cePort | toString) -}}
582+
{{- end -}}
583+
{{- toYaml $props -}}
584+
{{- end -}}
585+
586+
{{/*
587+
Merge user-provided sonarProperties with automatically generated Hazelcast properties.
588+
User-provided properties take precedence over automatically generated ones.
589+
*/}}
590+
{{- define "sonarqube.mergedSonarProperties" -}}
591+
{{- $hazelcastProps := fromYaml (include "sonarqube.hazelcastProperties" .) | default dict -}}
592+
{{- $userProps := .Values.ApplicationNodes.sonarProperties | default dict -}}
593+
{{- $merged := dict -}}
594+
{{- /* Start with automatically generated properties */}}
595+
{{- range $key, $val := $hazelcastProps -}}
596+
{{- $_ := set $merged $key $val -}}
597+
{{- end -}}
598+
{{- /* User properties override automatic ones */}}
599+
{{- range $key, $val := $userProps -}}
600+
{{- $_ := set $merged $key $val -}}
601+
{{- end -}}
602+
{{- toYaml $merged -}}
603+
{{- end -}}

charts/sonarqube-dce/templates/change-admin-password-hook.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ spec:
3333
{{- range $key, $value := .Values.service.labels }}
3434
{{ $key }}: {{ $value | quote }}
3535
{{- end }}
36+
annotations:
37+
# Disable Istio sidecar injection for this hook pod
38+
"sidecar.istio.io/inject": "false"
3639
spec:
3740
restartPolicy: OnFailure
3841
{{- if or .Values.ApplicationNodes.image.pullSecrets .Values.ApplicationNodes.image.pullSecret }}

charts/sonarqube-dce/templates/config.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@ metadata:
1212
heritage: {{ .Release.Service }}
1313
data:
1414
sonar.properties: |
15-
{{- range $key, $val := .Values.ApplicationNodes.sonarProperties }}
15+
{{- $mergedProps := fromYaml (include "sonarqube.mergedSonarProperties" .) | default dict }}
16+
{{- range $key, $val := $mergedProps }}
1617
{{ $key }}={{ $val }}
1718
{{- end }}
1819
{{- if .Values.sonarSecretKey }}

charts/sonarqube-dce/templates/service.yaml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,10 +68,25 @@ spec:
6868
clusterIP: None
6969
publishNotReadyAddresses: true
7070
ports:
71-
- port: 9003
71+
- port: {{ .Values.ApplicationNodes.port | default 9003 }}
7272
targetPort: hazelcast
7373
protocol: TCP
74+
appProtocol: tcp
7475
name: hazelcast
76+
{{- if .Values.ApplicationNodes.webPort }}
77+
- port: {{ .Values.ApplicationNodes.webPort }}
78+
targetPort: hazelcast-web
79+
protocol: TCP
80+
appProtocol: tcp
81+
name: hazelcast-web
82+
{{- end }}
83+
{{- if .Values.ApplicationNodes.cePort }}
84+
- port: {{ .Values.ApplicationNodes.cePort }}
85+
targetPort: hazelcast-ce
86+
protocol: TCP
87+
appProtocol: tcp
88+
name: hazelcast-ce
89+
{{- end }}
7590
selector:
7691
app: {{ template "sonarqube.name" . }}
7792
release: {{ .Release.Name }}

charts/sonarqube-dce/templates/sonarqube-application.yaml

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,8 @@ spec:
102102
{{- . | toYaml | trim | nindent 12 }}
103103
{{- end }}
104104
{{- end }}
105-
{{- if or .Values.ApplicationNodes.sonarProperties .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
105+
{{- $hasMergedProps := or .Values.ApplicationNodes.sonarProperties .Values.ApplicationNodes.port .Values.ApplicationNodes.webPort .Values.ApplicationNodes.cePort }}
106+
{{- if or $hasMergedProps .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
106107
- name: concat-properties
107108
image: {{ default (include "sonarqube.image" .) .Values.initContainers.image }}
108109
imagePullPolicy: {{ .Values.ApplicationNodes.image.pullPolicy }}
@@ -121,7 +122,7 @@ spec:
121122
awk 1 /tmp/props/sonar.properties /tmp/props/secret.properties > /tmp/result/sonar.properties
122123
fi
123124
volumeMounts:
124-
{{- if or .Values.ApplicationNodes.sonarProperties .Values.sonarSecretKey }}
125+
{{- if or $hasMergedProps .Values.sonarSecretKey }}
125126
- mountPath: /tmp/props/sonar.properties
126127
name: config
127128
subPath: sonar.properties
@@ -248,8 +249,18 @@ spec:
248249
protocol: TCP
249250
{{- end }}
250251
- name: hazelcast
251-
containerPort: 9003
252+
containerPort: {{ .Values.ApplicationNodes.port | default 9003 }}
252253
protocol: TCP
254+
{{- if .Values.ApplicationNodes.webPort }}
255+
- name: hazelcast-web
256+
containerPort: {{ .Values.ApplicationNodes.webPort }}
257+
protocol: TCP
258+
{{- end }}
259+
{{- if .Values.ApplicationNodes.cePort }}
260+
- name: hazelcast-ce
261+
containerPort: {{ .Values.ApplicationNodes.cePort }}
262+
protocol: TCP
263+
{{- end }}
253264
resources:
254265
{{ toYaml (default .Values.ApplicationNodes.resources .Values.resource) | indent 12 }}
255266
env:
@@ -338,7 +349,7 @@ spec:
338349
securityContext: {{- . | nindent 12 }}
339350
{{- end }}
340351
volumeMounts:
341-
{{- if or .Values.ApplicationNodes.sonarProperties .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
352+
{{- if or $hasMergedProps .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
342353
- mountPath: {{ .Values.sonarqubeFolder }}/conf/sonar.properties
343354
subPath: sonar.properties
344355
name: concat-dir
@@ -415,7 +426,7 @@ spec:
415426
{{- end }}
416427
serviceAccountName: {{ template "sonarqube.serviceAccountName" . }}
417428
volumes:
418-
{{- if or .Values.ApplicationNodes.sonarProperties .Values.sonarSecretKey }}
429+
{{- if or $hasMergedProps .Values.sonarSecretKey }}
419430
- name: config
420431
configMap:
421432
name: {{ template "sonarqube.fullname" . }}-app-config
@@ -493,7 +504,7 @@ spec:
493504
emptyDir: {{- toYaml .Values.emptyDir | nindent 10 }}
494505
- name : tmp-dir
495506
emptyDir: {{- toYaml .Values.emptyDir | nindent 10 }}
496-
{{- if or .Values.ApplicationNodes.sonarProperties .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
507+
{{- if or $hasMergedProps .Values.ApplicationNodes.sonarSecretProperties .Values.sonarSecretKey }}
497508
- name : concat-dir
498509
emptyDir: {{- toYaml .Values.emptyDir | nindent 10 -}}
499510
{{- end }}

charts/sonarqube-dce/values.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -412,6 +412,15 @@ applicationNodes:
412412
# if the global .Values.tolerations is set, the following one will be ignored
413413
tolerations: []
414414

415+
## The following values are used to set the ports for the Hazelcast cluster communication
416+
# The port used by the application nodes to communicate with each other. (If unset, it will be assigned to 9003)
417+
# port: 9003
418+
# The port used by the web process to communicate with other application nodes (If unset, it will be dynamically allocated)
419+
# webPort: 4023
420+
# The port used by the compute engine process to communicate with other application nodes (If unset, it will be dynamically allocated)
421+
# cePort: 4024
422+
423+
415424
## This sets the TLS encryption between application and search nodes
416425
nodeEncryption:
417426
enabled: false

0 commit comments

Comments
 (0)