Pipeline to deploy sonarqube server to kubernetes. Currently it only supports updating sonarqube's image. Other configuration requires manual update via helm.
To simplify the deployment, we are using helm, the package manager for k8s, to bundle all we need for sonar and deploy them all at once. Example values.yaml
can be found under config-example
folder. The actual config files are stored somewhere else secretly.
-
Prerequisite:
- install helm client on your dev machine:
brew install kubernetes-helm
- init helm in k8s cluster: https://docs.helm.sh/using_helm
- install helm client on your dev machine:
-
Deployment:
- Switch to the desired context
kubectl config use-context desired-cluster-context
- Deploy beta sonar using sonarqube chart
helm install --name beta -f beta-values.yaml stable/sonarqube
- Deploy prod sonar using sonarqube chart
helm install --name prod -f values.yaml stable/sonarqube
After deployment, you should be able to see such a set of resources created for sonarqube, e.g. for beta:
==> v1/Service beta-postgresql beta-sonarqube ==> v1beta1/Deployment beta-postgresql beta-sonarqube ==> v1beta1/Ingress beta-sonarqube ==> v1/Pod(related) beta-postgresql beta-sonarqube ==> v1/Secret beta-postgresql ==> v1/ConfigMap beta-sonarqube-config beta-sonarqube-install-plugins beta-sonarqube-startup beta-sonarqube-tests ==> v1/PersistentVolumeClaim beta-postgresql beta-sonarqube
-
Manual update in sonar UI:
For the following config, it's not configurable during boot time. Need to do it after sonar is up and running.
- Go to ${your-sonar-host} and log in as
admin
. - Go to ${your-sonar-host}/account/security: change the default admin password
- Go to ${your-sonar-host}/admin/permissions: unselect
Execute Analysis
andCreate Projects
for groupAnyone
Notes: all these configurations will be persistent as long as the PVC(persistent volume claim) is not deleted.
- Go to ${your-sonar-host} and log in as
helm upgrade -f beta-values.yaml beta stable/sonarqube
helm upgrade -f values.yaml prod stable/sonarqube
helm list
Be careful about running this command, it will wipe out everything for sonar even the PVC.
helm del --purge beta
helm del --purge beta
Code licensed under the BSD 3-Clause license. See LICENSE file for terms.