SonarQube Instance Deployment
This document describes the subscription of SonarQube Operator and the functionality for deploying SonarQube instances.
SonarQube does not support deployment in namespaces with SPA (Security Policy Admission) policy set to Restricted or Baseline due to the following reasons:
- Init Container Requires Root Privileges: SonarQube uses init containers to initialize PVC directory permissions, which requires root privileges that are not allowed under the
Restrictedpolicy. - InitSysctl Requires Privileged Permissions: By default, SonarQube uses initSysctl containers to configure sysctl parameters (such as
vm.max_map_countandfs.file-max) required by Elasticsearch. This requiresprivilegedpermissions to modify system-level kernel parameters.
Recommendation: Create a dedicated namespace for the SonarQube deployment and ensure that its security policy is set to privileged.
TOC
Prerequisites
-
This document applies to SonarQube 9.9.5 and above versions provided by the platform. It is decoupled from the platform using technologies such as Operator.
-
Please ensure that the SonarQube Operator has been deployed (subscribed) to the target cluster, meaning that creating instances from the SonarQube Operator is ready.
Deployment Planning
SonarQube supports various resource configurations to accommodate different customer scenarios. In different scenarios, the required resources, configurations, etc., will have significant differences. Therefore, this section introduces which aspects need to be considered in deployment planning before deploying a SonarQube instance, and what the impact of decision points is, to facilitate users in making subsequent specific instance deployments based on this information.
Basic Information
- The SonarQube Operator provided by the platform is based on the community's official SonarQube Chart, with enhanced enterprise capabilities such as IPv6 support and security vulnerability fixes. It is fully compatible with the community version in terms of functionality, and in terms of user experience, it enhances the convenience of SonarQube deployment through optional, customizable templates and other methods.
Pre-deployment Resource Planning
Pre-deployment resource planning involves making decisions before deployment that will take effect during the deployment process.
For more recommendations on environmental resources, please refer to the official documentation: https://docs.sonarsource.com/sonarqube-server/2025.1/setup-and-upgrade/installation-requirements/server-host/#hardware
Instance Deployment
Deploying from the Quickstart Template Template
This template is used to quickly create a lightweight SonarQube instance, suitable for development and testing scenarios, not recommended for production environments.
- Compute resources: 800m CPU, 4 Gi memory
- Storage: Use node local storage, configure the storage node IP and path
- Network access: Use NodePort to access the service, share the node IP with storage, and specify the port
Deploying from the Production Template Template
This template is used to quickly create a Production SonarQube instance, suitable for production scenarios, recommended for production environments.
- Compute resources: 8 CPU cores, 16 Gi memory
- Storage: Use PVC storage, configure the storage class
- Network access: Use Domain to access the service.
Deploying from YAML
Resource Configuration
SonarQube only needs to configure the overall resources, for example:
For more information, refer to Resource description in SonarQube Chart
Network Configuration
Network configurations are categorized into two types:
- Network configuration based on ingress
- Network configuration based on NodePort
Network configuration based on ingress supports both https and http protocols. An ingress controller needs to be deployed in the cluster in advance.
Network configuration based on NodePort:
Storage Configuration
Storage configurations are mainly divided into three categories:
- Storage configuration based on StorageClass
- Storage configuration based on PVC
- Storage configuration based on HostPath
Storage configuration based on StorageClass:
Storage configuration based on PVC:
Storage configuration based on HostPath:
PostgreSQL Access Credentials Configuration
A PostgreSQL instance needs to be created in advance on the platform, and a database needs to be created in PostgreSQL for use.
The supported PostgreSQL versions for SonarQube 25.1.0 are 13 to 17.
PostgreSQL access is accomplished by configuring a secret resource with specific format content. See Configuring PostgreSQL and Account Access Credentials for details.
Using a secret for the credentials to access PG in SonarQube yaml:
Admin Account Configuration
When initializing a SonarQube instance, you need to configure the admin account and its password. This is done by configuring a secret resource. See Configuring PostgreSQL, and Account Access Credentials for details.
Specify it to SonarQube through YAML:
Complete YAML Example
NodePort, PVC, PostgreSQL, Admin account
SSO Configuration
Configuring SSO involves the following steps:
Register an SSO authentication client in the global cluster
- Create the following OAuth2Client resource in the global cluster to register the SSO authentication client.
- Configure the SonarQube instance to use SSO authentication
Add the SSO configuration to the SonarQube instance:
Enabling SSO for Platforms Using Self-Signed Certificates
If the platform is accessed via https and uses a self-signed certificate, you need to mount the CA of the self-signed certificate to the SonarQube instance. The method is as follows:
In the cpaas-system namespace of the global cluster, find the secret named dex.tls, get the ca.crt and tls.crt content from the secret, save it as a new secret, and create it in the namespace of the SonarQube instance.
Edit the SonarQube instance to use this CA:
Using in Pure IPv6 Clusters
When deploying in a pure IPv6 cluster environment, you need to explicitly configure IPv6 protocol settings since Java supports dual-stack by default. Add the following configuration to ensure proper connectivity: