SonarQube Upgrade Guide from 9.9.5.1 to 2025.1.0 (Alauda Build of SonarQube Operator Version 2025.1.z)
TOC
Overview
This document describes how to upgrade SonarQube from version 9.9.5.1(9.9.6) to 2025.1.0. Since this upgrade involves changes in operator 4.0 version, existing SonarQube instances need to be migrated to the new version operator.
- Larger databases take longer to migrate.
- Storage performance also affects migration speed — using TopoLVM is recommended for better performance.
Example:
- SonarQube instance: 574 projects; PostgreSQL PVC usage 87 Gi; migration time ~1 hour
Prerequisites
- New version operator (sonarqube-ce-operator) has been installed in the cluster
- Ensure sufficient system resources are available for the upgrade
- Use product functionality to upgrade SonarQube to version 9.9.5.1
- Perform a complete data backup according to the backup documentation
Upgrade Steps
1. Stop the Old Version Instance Deployment
2. Configure the New Version Instance
2.1 Database Configuration
Note: SonarQube 9.9.5 supports PG versions 11-15, while SonarQube 2025.1.0 supports PG versions 13-17. For data migration to a new PG version, refer to the official PG documentation
The PG information used by the old SonarQube version is recorded in the spec.database.secretName of the SonarQube instance.
kubectl get sonarqube.operator.devops.alauda.io <old-sonarqube-name> -n <old-instance-namespace> -o jsonpath='{.spec.database.secretName}'
Use the above command to get the secretName, then use
kubectl get secret <secretName> -n <old-instance-namespace> -o yaml to get the secret information
The secret content is as follows:
-
Perform a complete data backup according to the backup documentation
-
Create a new PG database for the new SonarQube instance.
It is recommended to create a new database for deploying the new SonarQube version to avoid contaminating the old database and ensure the old SonarQube can still function normally
-
Migrate the data according to the backup documentation
-
Create a new database secret. The new version secret only needs to store the password:
-
Create a new SonarQube instance configuration with database connection information, connecting to the previous PG instance
2.2 Storage Configuration
Choose the corresponding configuration based on the storage type used by the old SonarQube instance:
Using StorageClass:
Deploy the new instance using the existing PVC
Using Existing PVC:
Use the command below to get the PVC name used by the old SonarQube version
kubectl get sonarqube.operator.devops.alauda.io <old-sonarqube-name> -n <old-instance-namespace> -o jsonpath='{.spec.persistence.pvc.webServiceExistingClaim}'
Using HostPath:
Note: The node for the HostPath of the new and old versions must remain consistent. The path should add a portal directory based on the old version path. For example, if the old version path is /sonarqube/, the new version path should be /sonarqube/portal/
2.3 Network Configuration
Since the old version instance has not been cleaned up, the new version network configuration cannot be the same as the old version (i.e., ingress cannot use the same domain name, nodePort cannot use the same port), otherwise it will cause conflicts. Temporarily use other addresses, and after the upgrade is complete, clean up the old version instance, then modify the access address.
Use the command below to get the network type used by the old SonarQube version
kubectl get sonarqube.operator.devops.alauda.io <old-sonarqube-name> -n <old-instance-namespace> -o jsonpath='{.spec.service.type}'
Ingress Configuration:
NodePort Configuration:
Configure spec.externalURL:
2.4 Other Configurations
- Retain Plugins: The new version needs to retain the old version plugins. Add configuration spec.helmValues.plugins.deleteDefaultPlugins as false
- SSO Configuration Migration: Reconfigure according to Deployment Document: SSO Configuration
- Resources Configuration Migration: Configure the new instance's spec.helmValues.resources based on the old instance's spec.resourceAssign
- helmValues Configuration Migration: Most of the data in the old instance's helmValues can be directly migrated to the new instance's helmValues. For example, spec.helmValues.jvmOpts can be directly migrated to the new instance's spec.helmValues.jvmOpts.
Complete YAML example for the new version:
3. Manually Perform Data Schema Migration
- Backup the old version data in advance.
- The instance will be ready only after completing the setup.
Access new-sonar-url/setup and follow the prompts
4. Verify Upgrade Results
Check the following to ensure the upgrade was successful:
- All project data is complete
- User accounts and permissions are correct
- Plugin status is normal (some plugins may need to be reinstalled)
- Historical analysis data is accessible
5. Cleanup Work
- After confirming the new instance is running stably, the old instance can be deleted
- Adjust the network configuration to be consistent with the original configuration