Sonarqube config not saving on restart

Hey all,

I’m running sonarqube and postgres images in a kubernetes environment. Each of the 2 deployments have a volume attached to it. However, when if the deployment is deleted, all my sonarqube config is lost on restart. I’ve checked logs for both sonarqube and postgres, and the 2 of them just have INFO type logs and no errors. If the deployment doesn’t go down, sonarqube works as expected. But every time it does go down I have to configure SAML config and Quality Profiles all over again. Has anyone experienced this issue?

Deployment Image Version Info:

  • SonarQube: sonarqube:8.9.1-community
  • Postgres: bitnami/postgresql

PV & PVC Info:

  • Status: Bound
  • Reclaim Policy: Retain

Volume Config

      containers:
      - name: sonarqube
        image: sonarqube:8.9.1-community
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 9000
        envFrom:
        - configMapRef:
            name: sonar-config
        volumeMounts:
        - name: sonarqube-pv
          mountPath: "/opt/sonarqube/data/"
          subPath: data
        - name: sonarqube-pv
          mountPath: "/opt/sonarqube/extensions/"
          subPath: extensions
        resources:
          requests:
            memory: "1024Mi"
          limits:
            memory: "2048Mi"
      volumes:
      - name: sonarqube-pv
        persistentVolumeClaim:
          claimName: sonarqube-pvc

Hey, to anyone who might be facing this issue.

I managed to solve my problem.

First step was understanding that all data was saved into the psql db. So I didn’t have to mess around my sonarqube deployment.
There were a few issues. I use the busybox image to make sure that my psql image always starts before my sonarqube image. Over here, I had to adjust owner from 999 to 1001, and then I had to give it rwx permissions with 700.

    spec:
      initContainers:
      - name: chmod-er
        image: busybox:latest
        command:
        - sh
        - -c
        - |
          chown -R 1001:1001 /bitnami/postgresql &&
          chmod 700 /bitnami/postgresql
        volumeMounts:
        - name: postgresql-pv
          mountPath: /bitnami/postgresql 

After that I had missed the mount to my psql container. :sob: So I had to fix that by mounting the volume. I had no errors, because there was no mounted volume to psql image.
Also, previous I just had asked it to use the bitnami/postgresql image without defining a version. Then I got an error mentioning that the db was created using psql 15 and it cannot init on psql 16, so I had to set a version.

      containers:
      - name: postgress
        image: bitnami/postgresql:15.5.0
        imagePullPolicy: IfNotPresent
        ports:
        - containerPort: 5432
        envFrom:
        - configMapRef:
            name: postgres
        volumeMounts:
        - name: postgresql-pv
          mountPath: /bitnami/postgresql
      volumes:
      - name: postgresql-pv
        persistentVolumeClaim:
          claimName: postgresql-pvc

Hope this helps out someone. :upside_down_face:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.