Skip to content

Commit 6610e0d

Browse files
davividaljbaz
andauthored
SONAR-24842 Add the possibility to save data with hostpath in the Helm Charts
Co-authored-by: jbaz <[email protected]>
1 parent 0d33a45 commit 6610e0d

File tree

13 files changed

+1791
-23
lines changed

13 files changed

+1791
-23
lines changed

charts/sonarqube-dce/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ helm upgrade --install -n sonarqube-dce sonarqube sonarqube/sonarqube-dce --set
4343
The above command deploys SonarQube on the Kubernetes cluster in the default configuration in the sonarqube namespace.
4444
If you are interested in deploying SonarQube on Openshift, please check the [dedicated section](#openshift).
4545

46-
The [configuration](#configuration) section lists the parameters that can be configured during installation.
46+
The [configuration](#configuration) section lists the parameters that can be configured during installation.
4747

4848
The default login is admin/admin.
4949

@@ -150,7 +150,7 @@ Nonetheless, if you intend to run a production-grade SonarQube please follow the
150150

151151
Prior to SonarQube Server Datacenter 10.8, we used a different naming conventions for `searchNodes` and `ApplicationNodes`. Specifically, we used the [Camel Case](https://en.wikipedia.org/wiki/Camel_case) notation in the former and not in the latter. While this can be viewed as a minor difference, we promote [Clean Code](https://www.sonarsource.com/solutions/clean-code/) at Sonar and this is a clear maintanability (and inconsistency) issue.
152152

153-
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)).
153+
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

155155
Please report any encountered bugs to https://community.sonarsource.com/.
156156

@@ -244,7 +244,7 @@ If you want to make your application publicly visible with Routes, you can set `
244244

245245
The SonarQube applications nodes can be set to automatically scale up and down based on their average CPU utilization. This is particularly useful when scanning new projects or evaluating Pull Requests with SonarQube. In order to enable the autoscaling, you can rely on the `applicationNodes.hpa` parameters.
246246

247-
Please ensure the [Metrics Server](https://github.com/kubernetes-sigs/metrics-server) is installed in your cluster to provide resource usage metrics. You can deploy it using:
247+
Please ensure the [Metrics Server](https://github.com/kubernetes-sigs/metrics-server) is installed in your cluster to provide resource usage metrics. You can deploy it using:
248248

249249
```
250250
kubectl apply -f https://github.com/kubernetes-sigs/metrics-server/releases/latest/download/components.yaml

charts/sonarqube/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 SonarQube Community Build to 25.6.0.109173
77
* Upgrade nginx subchart to 4.12.2
88
* Support Kubernetes v1.32
9+
* Add the possibility of to save the data with hostpath
910

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

charts/sonarqube/Chart.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ annotations:
3838
description: "Upgrade nginx subchart to 4.12.2"
3939
- kind: changed
4040
description: "Support Kubernetes v1.33"
41+
- kind: changed
42+
description: "Add the possibility of to save the data with hostpath"
4143
artifacthub.io/containsSecurityUpdates: "false"
4244
artifacthub.io/images: |
4345
- name: sonarqube-community

charts/sonarqube/README.md

Lines changed: 26 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -488,19 +488,32 @@ The following table lists the configurable parameters of the SonarQube chart and
488488

489489
### Persistence
490490

491-
| Parameter | Description | Default |
492-
| --------------------------- | ------------------------------------------------- | --------------- |
493-
| `persistence.enabled` | Flag for enabling persistent storage | `false` |
494-
| `persistence.annotations` | Kubernetes pvc annotations | `{}` |
495-
| `persistence.existingClaim` | Do not create a new PVC but use this one | `None` |
496-
| `persistence.storageClass` | Storage class to be used | `""` |
497-
| `persistence.accessMode` | Volumes access mode to be set | `ReadWriteOnce` |
498-
| `persistence.size` | Size of the volume | `5Gi` |
499-
| `persistence.volumes` | (DEPRECATED) Please use extraVolumes instead | `[]` |
500-
| `persistence.mounts` | (DEPRECATED) Please use extraVolumeMounts instead | `[]` |
501-
| `persistence.uid` | UID used for init-fs container | `1000` |
502-
| `persistence.guid` | GUID used for init-fs container | `0` |
503-
| `emptyDir` | Configuration of resources for `emptyDir` | `{}` |
491+
| Parameter | Description | Default |
492+
| --------------------------- | -------------------------------------------------- | --------------- |
493+
| `persistence.enabled` | Flag for enabling persistent storage | `false` |
494+
| `persistence.annotations` | Kubernetes pvc annotations | `{}` |
495+
| `persistence.existingClaim` | Do not create a new PVC but use this one | `None` |
496+
| `persistence.storageClass` | Storage class to be used | `""` |
497+
| `persistence.accessMode` | Volumes access mode to be set | `ReadWriteOnce` |
498+
| `persistence.size` | Size of the volume | `5Gi` |
499+
| `persistence.volumes` | (DEPRECATED) Please use extraVolumes instead | `[]` |
500+
| `persistence.mounts` | (DEPRECATED) Please use extraVolumeMounts instead | `[]` |
501+
| `persistence.uid` | UID used for init-fs container | `1000` |
502+
| `persistence.guid` | GUID used for init-fs container | `0` |
503+
| `emptyDir` | Configuration of resources for `emptyDir` | `{}` |
504+
| `persistence.hostPath.path` | Path where the data will be stored with `hostPath` | `""` |
505+
| `persistence.hostPath.type` | `hostPath` volume types | `""` |
506+
507+
When using hostPath persistence, ensure that you are aware of the implications
508+
of using hostPath volumes in Kubernetes, as they can lead to data loss if the
509+
node is deleted or if the pod is rescheduled to a different node, as well as
510+
potential security risks if not properly managed. It is generally recommended
511+
to use a more robust storage solution for production deployments. Please refer
512+
to the [Kubernetes documentation](https://kubernetes.io/docs/concepts/storage/volumes/#hostpath)
513+
for more information on hostPath volumes.
514+
515+
In order to use hostPath persistence, you need to enable `persistence.enabled`
516+
and set `persistence.hostPath.path` and `persistence.hostPath.type`.
504517

505518
### JDBC Overwrite
506519

charts/sonarqube/templates/_pod.tpl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -234,14 +234,14 @@ spec:
234234
volumeMounts:
235235
- mountPath: {{ .Values.sonarqubeFolder }}/extensions/jdbc-driver/oracle
236236
name: sonarqube
237-
subPath: extensions/jdbc-driver/oracle
237+
subPath: extensions/jdbc-driver/oracle
238238
- name: install-oracle-jdbc-driver
239239
mountPath: /tmp/scripts/
240240
{{- if .Values.jdbcOverwrite.oracleJdbcDriver.netrcCreds }}
241241
- name: oracle-jdbc-driver-netrc-file
242242
mountPath: /root
243243
{{- end }}
244-
{{- if .Values.caCerts.enabled }}
244+
{{- if .Values.caCerts.enabled }}
245245
- mountPath: /tmp/secrets/ca-certs
246246
name: ca-certs
247247
{{- end }}
@@ -471,12 +471,16 @@ spec:
471471
path: prometheus-ce-config.yaml
472472
{{- end }}
473473
- name: sonarqube
474-
{{- if .Values.persistence.enabled }}
474+
{{- if and .Values.persistence.enabled (not .Values.persistence.hostPath) }}
475475
persistentVolumeClaim:
476476
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ include "sonarqube.fullname" . }}{{- end }}
477+
{{- else if and .Values.persistence.enabled .Values.persistence.hostPath }}
478+
hostPath:
479+
path: {{ .Values.persistence.hostPath.path }}
480+
type: {{ .Values.persistence.hostPath.type }}
477481
{{- else }}
478482
emptyDir: {{- toYaml .Values.emptyDir | nindent 8 }}
479-
{{- end }}
483+
{{- end }}
480484
- name : tmp-dir
481485
emptyDir: {{- toYaml .Values.emptyDir | nindent 8 }}
482486
{{- if or .Values.sonarProperties .Values.sonarSecretProperties .Values.sonarSecretKey ( not .Values.elasticsearch.bootstrapChecks) }}

charts/sonarqube/values.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -489,6 +489,13 @@ persistence:
489489
## Specify extra mounts. Refer to ".spec.containers.volumeMounts" specification : https://kubernetes.io/fr/docs/concepts/storage/volumes/
490490
mounts: []
491491

492+
# In case you want to specify hostPath for to storage into the host.
493+
# hostPath:
494+
# # Path where the data will be stored.
495+
# path: /data/sonarqube/
496+
# # Type of volume. Must be one of: DirectoryOrCreate, Directory, FileOrCreate, File, Socket, CharDevice, BlockDevice.
497+
# type: DirectoryOrCreate
498+
492499
# In case you want to specify different resources for emptyDir than {}
493500
emptyDir: {}
494501
# Example of resouces that might be used:
@@ -672,7 +679,6 @@ extraConfig:
672679
# image:
673680
# annotations: {}
674681

675-
676682
# (DEPRECATED) please use setAdminPassword instead
677683
# account:
678684
# The values can be set to define the current and the (new) custom admin passwords at the startup (the username will remain "admin")

0 commit comments

Comments
 (0)