Deploy SonarQube
SonarQube is an open source code quality management tool that helps you find defects in your code.
Cautions
-
The SSO login depends on the built-in Dex authentication service of the platform. If the platform uses the https protocol for access and uses a self-signed certificate, this self-signed certificate needs to include a CA. Otherwise, the SSO function of the tool cannot be used.
-
The service access address is the default IPV4 address. If you need to use IPV6 and the cluster network card supports IPV6, please modify the IPV4 address to the IPV6 address.
Prerequisites
Storage
Please make sure that at least one of the following prerequisites is met. Each prerequisite corresponds to a different storage method .
-
Dynamically generated PVC: A storage class already exists in the cluster. The access mode defined by the storage class must be ReadWriteMany (RWX).
-
Use available PVC: A persistent volume claim (PVC) already exists in the cluster. The access mode selected in the PVC must be ReadWriteMany (RWX), and the volume mode must be File system.
-
Use node storage: There is sufficient storage resources in the cluster nodes.
Tip: After deleting the tool created by the
Network
-
If you want to access the tool through a domain name, please create a domain name in advance.
-
If you want to use the HTTPS protocol, you also need to prepare a certificate that matches the domain name. The certificate sources include
platform allocationandconfidential dictionary import.Certificate Source Description Platform administrator Certificates created in Networking > Certificates . The certificate needs to be assigned to the project where SonarQube will be deployed. Import ConfigSecret TLS type secret dictionary created in Container Platform. The secret dictionary needs to be in the same namespace as SonarQube.
On-premise deployment
-
Prepare a Postgresql database with a version between 11.x and 15.x. You can create this via the platform’s Data Service > Postgresql. Create a PostgreSQL instance
-
In the left navigation bar, click DevOps Toolchain > Instances.
-
Click Create Instance.
-
On the Deploy and Integrate page, select SonarQube.
-
In the Location section, select the Clusters and Namespaces where you want to deploy the tool.
-
In the Resources section, select a CPU and memory allocation method and complete the configuration.
Allocation Method Description Tool Allocates total resources for the tool to ensure overall availability. If you have no special requirements for individual components, the global allocation method is more convenient. Components Used to allocate resources for each component under the tool, to ensure the business performance related to specific components.
Note: It is recommended to maintain a resource ratio of3:7between the db component and the webservice component. -
In the storage area, select a type of storage method and complete the configuration.
Caution: Storage configuration cannot be modified after the instance is created.
Storage Method Description Dynamically created PVCs Prerequisites: Storage classes need to be prepared in advance.
After setting the required storage capacity for each SonarQube component, the platform will dynamically generate a PVC for each component and dynamically create a persistent volume for each component based on the storage class requested by the PVC.
If you need to expand storage, switch to Container Platform to expand the PVC.Available PVCs Prerequisites: PVCs need to be prepared in advance.
After specifying an available PVC for each SonarQube component, the platform will dynamically create a persistent volume for each component based on the storage class requested by the PVC to meet the different storage demands of each component (expansion, snapshots, etc.).
Supports direct storage expansion in Platform Management.Node storage Request storage resources on cluster nodes through the hostpath storage solution. NO StorageClasses is required.
Caution:- To avoid mounting failure, ensure that the path has not been used.
- When deploying the tool in a public cloud cluster, this solution is unavailable to avoid data loss because of node elasticty.
-
In the Database Secret section, configure the database connection secret. If you do not have a secret yet, click on “Create Secrets”, then fill out the secret form on the popup page. Choose the type as Opaque, and enter the following fields into the secret:
Field Description host The database connection address port The database connection port username The database account username password The database account password database The database name, the database should exists and be empty sslmode Is SSL enabled for the database connection? Enter enableto enable ordisableto disable, default is enabledThe Postgresql instances created through the Data Service have SSL connections enabled by default. If you use the Data Service Postgresql instance, set
sslmodetoenable. In other cases, check with your server’s configuration to confirm whether SSL connections are supported.After filling out and submitting the Secret creation, return to the SonarQube create page and use the Secret to continue the creation.
-
In the Networking section, configure the network requirements.
Caution:
-
After deployment, please be cautious when updating the service access address. If updated, external settings such as DNS resolution need to be configured for normal access. Moreover, this update only applies to the current network setting status. When the network setting changes again, the service access address will be automatically replaced with a restricted value.
-
If there are dual NIC nodes in the cluster where the deployment tool is located, check whether the default load balancer IP address or node IP address used for service access is available for external access. Otherwise, the tool cannot be accessed normally after deployment, and the error message “check xx alive failed” will appear.
-
Ingress method
Parameter Description Domain Select a domain name that already exists in the platform. Make sure the selected domain name has been assigned to the project that will use this tool. Scheme Supports selecting HTTP and HTTPS protocols. Certificate If using the HTTPS protocol, a certificate matching the domain name must also be configured. Service access address Will be automatically generated, with the rule of http://{Ingress name}orhttps://{Ingress name}. -
Nodeport method
Parameter Description HTTPS port The port used to access the tool. Service access address Will be generated automatically, following the format http://{cluster address}:{HTTP port}.
-
-
In the Accounts section, configure the account-related information.
Parameter Description Name Default value is admin and cannot be modified.
Note: Default password is admin.SSO login Single sign-on. If enabled, SonarQube can be authorized to log in with the platform account. -
In the Integration area, enter an integration name that will help the project members to identify and select this tool in DevOps.
-
After the configuration is complete, click Deploy and Integrate.
The instance integrates into the plaftform automatically.
Public cloud deployment
It is recommended to open a virtual machine and deploy a public cloud cluster before deploying DevOps tools, and use the same storage and network solution as the native cluster. In this way, the tools and capabilities supported for deployment are synchronized with the native cluster deployment tools.
Verification
During the creation process, click the
icon to view the instance creation status in real time. When you encounter the following error message, it means that there is an error in your Database Secret.
| Error Message | Description |
|---|---|
| required postgres database name, got empty dbname from provided secret | No database name was entered, the user needs to specify an existing empty database |
| Connection refused. Check your host and port in the given secret | Connection creation failed, check if the address and port are incorrect |
| Authentication failed. Check your username and password in the given secret | Server rejected the connection, check if the username or password is incorrect |
| SSL is not enabled on the server, please change ‘sslmode’ to ‘disable’ in secret if this server is the right one to connect | The server does not support SSL connections, set sslmode to disable |
| server asks for an SSL connection, please change ‘sslmode’ to ’enable’ in secret if this server is the right one to connect | The server requires an SSL connection, set sslmode to enable |
| get secret “ns/secret” failed, please check if it exists | Failed to get the secret, check if the secret have been created successfully |
Please check and correct the information within the corresponding secret based on the error message. After making corrections, the component will re-check the secret within one minute. If it is correct, the creation process will continue to finish.
Once the deployment status become Deployed, verify the tool’s accessibility by accessing the URL.
What’s next
Allocate tool resources to platform projects .