I'm trying to Deploy Sonarqube with external database on Kubernetes
But there is no error, when I deploy it is connecting default h2
database
my database configs not affecting to deployment
Where I'm doing wrong?
Any idea?
deployment.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: sonar-config
namespace: sonarqube
labels:
app: sonar
data:
SONARQUBE_JDBC_URL: "jdbc:postgresql://10.145.165.23:5432/sonar_db"
SONARQUBE_JDBC_USERNAME: "postgres"
SONARQUBE_JDBC_PASSWORD: "passwds"
JAVA_OPTS: "-Duser.timezone=Asia/Jakarta -Xmx2048m"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: sonar
namespace: sonarqube
labels:
app: sonar
spec:
replicas: 1
strategy:
type: Recreate
selector:
matchLabels:
app: sonar
template:
metadata:
labels:
app: sonar
spec:
initContainers:
- name: init
image: busybox
command:
- sysctl
- -w
- vm.max_map_count=262144
imagePullPolicy: IfNotPresent
securityContext:
privileged: true
containers:
- name: sonarqube
image: sonarqube:10.3.0-community
imagePullPolicy: IfNotPresent
ports:
- containerPort: 9000
envFrom:
- configMapRef:
name: sonar-config
volumeMounts:
- name: app-pvc
mountPath: "/opt/sonarqube/data/"
subPath: data
- name: app-pvc
mountPath: "/opt/sonarqube/extensions/"
subPath: extensions
resources:
requests:
memory: "1024Mi"
limits:
memory: "2048Mi"
volumes:
- name: app-pvc
persistentVolumeClaim:
claimName: sonar-pvc
---
apiVersion: v1
kind: Service
metadata:
name: sonar-svc
namespace: sonarqube
labels:
app: sonar
spec:
ports:
- port: 9000
name: sonar
selector:
app: sonar
---
pod
logs
023.12.21 06:19:22 INFO web[][o.s.s.p.Platform] Web Server is operational
WARNING: A terminally deprecated method in java.lang.System has been called
WARNING: System::setSecurityManager has been called by org.sonar.process.PluginSecurityManager (file:/opt/sonarqube/lib/sonar-application-10.3.0.82913.jar)
WARNING: Please consider reporting this to the maintainers of org.sonar.process.PluginSecurityManager
WARNING: System::setSecurityManager will be removed in a future release
2023.12.21 06:19:22 INFO ce[][o.s.p.ProcessEntryPoint] Starting Compute Engine
2023.12.21 06:19:22 INFO ce[][o.s.ce.app.CeServer] Compute Engine starting up...
2023.12.21 06:19:23 INFO ce[][o.s.d.DefaultDatabase] Create JDBC data source for jdbc:h2:tcp://127.0.0.1:9092/sonar;NON_KEYWORDS=VALUE
2023.12.21 06:19:23 INFO ce[][c.z.h.HikariDataSource] HikariPool-1 - Starting...
2023.12.21 06:19:23 INFO ce[][c.z.h.p.HikariPool] HikariPool-1 - Added connection conn0: url=jdbc:h2:tcp://127.0.0.1:9092/sonar user=
2023.12.21 06:19:23 INFO ce[][c.z.h.HikariDataSource] HikariPool-1 - Start completed.
2023.12.21 06:19:23 WARN ce[][o.s.db.dialect.H2] H2 database should be used for evaluation purpose only.
2023.12.21 06:19:24 INFO ce[][o.s.s.p.ServerFileSystemImpl] SonarQube home: /opt/sonarqube
2023.12.21 06:19:24 INFO ce[][o.s.c.c.CePluginRepository] Load plugins
2023.12.21 06:19:26 INFO ce[][o.s.c.c.ComputeEngineContainerImpl] Running Community edition
2023.12.21 06:19:26 INFO ce[][o.s.ce.app.CeServer] Compute Engine is started
2023.12.21 06:19:26 INFO app[][o.s.a.SchedulerImpl] Process[ce] is up
2023.12.21 06:19:26 INFO app[][o.s.a.SchedulerImpl] SonarQube is operational
After digging 8 hours I deployed Sonarqube with external Postgresql database via Helm chart
here is values.yaml
edit last line (1083) with your PostgresQL credentials
helm repo add bitnami https://charts.bitnami.com/bitnami
helm install sonarqube -f values.yaml oci://registry-1.docker.io/bitnamicharts/sonarqube -n sonarqube