From edea140d6b10b6338140f95eb4bcc86e887b01bd Mon Sep 17 00:00:00 2001 From: Alex Moskalenko Date: Mon, 11 Nov 2019 13:17:41 +0200 Subject: [PATCH] [stable/sonarqube] add support of secret injection for sonar.properties (#18626) Signed-off-by: Alexander Moskalenko --- stable/sonarqube/Chart.yaml | 2 +- stable/sonarqube/README.md | 1 + stable/sonarqube/templates/deployment.yaml | 40 +++++++++++++++++++++- stable/sonarqube/values.yaml | 3 ++ 4 files changed, 44 insertions(+), 2 deletions(-) mode change 100755 => 100644 stable/sonarqube/values.yaml diff --git a/stable/sonarqube/Chart.yaml b/stable/sonarqube/Chart.yaml index d91fe6e8b7..da3381a6a4 100644 --- a/stable/sonarqube/Chart.yaml +++ b/stable/sonarqube/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 name: sonarqube description: Sonarqube is an open sourced code quality scanning tool -version: 3.2.2 +version: 3.2.3 appVersion: 7.9.1 keywords: - coverage diff --git a/stable/sonarqube/README.md b/stable/sonarqube/README.md index a564fb1ea2..b275e24cd5 100644 --- a/stable/sonarqube/README.md +++ b/stable/sonarqube/README.md @@ -70,6 +70,7 @@ The following table lists the configurable parameters of the Sonarqube chart and | `persistence.accessMode` | Volumes access mode to be set | `ReadWriteOnce` | | `persistence.size` | Size of the volume | None | | `sonarProperties` | Custom `sonar.properties` file | None | +| `sonarSecretProperties` | Additional `sonar.properties` file to load from a secret | None | | `customCerts.enabled` | Use `customCerts.secretName` | false | | `customCerts.secretName` | Name of the secret which conatins your `cacerts` | false | | `sonarSecretKey` | Name of existing secret used for settings encryption | None | diff --git a/stable/sonarqube/templates/deployment.yaml b/stable/sonarqube/templates/deployment.yaml index 0e38311d5f..9a0b967308 100644 --- a/stable/sonarqube/templates/deployment.yaml +++ b/stable/sonarqube/templates/deployment.yaml @@ -88,6 +88,29 @@ spec: {{ toYaml .Values.affinity | indent 8 }} {{- end }} {{- end }} + {{- if and .Values.sonarProperties .Values.sonarSecretProperties }} + - name: concat-properties + image: {{ default "alpine:3.10.3" .Values.plugins.initContainerImage }} + env: + {{- range $key, $value := .Values.extraEnv }} + - name: {{ $key }} + value: {{ $value }} + {{- end }} + command: ["sh", + "-c", + "awk 1 /tmp/props/sonar.properties /tmp/props/secret.properties > /tmp/result/sonar.properties + " + ] + volumeMounts: + - mountPath: /tmp/props/sonar.properties + name: config + subPath: sonar.properties + - mountPath: /tmp/props/secret.properties + name: secret-config + subPath: secret.properties + - mountPath: /tmp/result + name: concat-dir + {{- end }} {{- if .Values.image.pullSecret }} imagePullSecrets: - name: {{ .Values.image.pullSecret }} @@ -145,7 +168,10 @@ spec: periodSeconds: {{ .Values.readinessProbe.periodSeconds }} failureThreshold: {{ .Values.readinessProbe.failureThreshold }} volumeMounts: - {{- if or .Values.sonarProperties (not .Values.elasticsearch.bootstrapChecks) }} + {{- if and .Values.sonarProperties .Values.sonarSecretProperties }} + - mountPath: /opt/sonarqube/conf/ + name: concat-dir + {{- else if or .Values.sonarProperties (not .Values.elasticsearch.bootstrapChecks) }} - mountPath: /opt/sonarqube/conf/ name: config {{- end }} @@ -203,6 +229,14 @@ spec: - key: sonar.properties path: sonar.properties {{- end }} + {{- if .Values.sonarSecretProperties }} + - name: secret-config + secret: + secretName: {{ .Values.sonarSecretProperties }} + items: + - key: secret.properties + path: secret.properties + {{- end }} {{- if .Values.sonarSecretKey }} - name: secret secret: @@ -241,3 +275,7 @@ spec: {{- end }} - name : tmp-dir emptyDir: {} + {{- if .Values.sonarSecretProperties }} + - name : concat-dir + emptyDir: {} + {{- end }} diff --git a/stable/sonarqube/values.yaml b/stable/sonarqube/values.yaml old mode 100755 new mode 100644 index ca0ad2f451..527cf3a220 --- a/stable/sonarqube/values.yaml +++ b/stable/sonarqube/values.yaml @@ -152,6 +152,9 @@ plugins: # sonar.security.realm: LDAP # ldap.url: ldaps://organization.com +# Additional sonar properties to load from a secret with a key "secret.properties" (must be a string) +# sonarSecretProperties: + # Kubernetes secret that contains the encryption key for the sonarqube instance. # The secret must contain the key 'sonar-secret.txt'. # The 'sonar.secretKeyPath' property will be set automatically.