无法将外部 PostgreSQL 连接到 Kubernetes 上的 Sonarqube

问题描述 投票:0回答:1

我正在尝试在 Kubernetes 上使用外部数据库部署 Sonarqube 但是没有错误,当我部署时它正在连接默认的

h2
数据库 我的数据库配置不影响部署 我哪里做错了?

有什么想法吗?有链接吗?

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
日志

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
postgresql kubernetes sonarqube
1个回答
0
投票

你从哪里得到的

deployment.yaml
?不确定
data
部分是关于什么的,但它不是那些环境变量的地方。它们应该在
sonarqube
容器规范中,例如:

---
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:
      ...
      containers:
      - name: sonarqube
        image: sonarqube:10.3.0-community
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9000
        envFrom:
        - configMapRef:
            name: sonar-config
        env:
        - name: SONARQUBE_JDBC_USERNAME
          value: sonar
        - name: SONARQUBE_JDBC_PASSWORD
          value: sonar
        - name: SONARQUBE_JDBC_URL
          value: jdbc:postgresql://10.145.165.23:5432/sonar_db
© www.soinside.com 2019 - 2024. All rights reserved.