Kubernetes: Install Sonarqube on GKE with Google SQL

SonarQube is an open sourced code quality scanning tool.

You can use a helm chart, but at the time of writing this blog I didn’t see a Google SQL proxy option. I ended up using helm template to generate the majority of the yaml files and added the Google SQL proxy parts myself.


Create Database


I used PostgreSQL 12 and created a user account and a database called sonar.


Create namespace

kubectl create ns sonarqube

Create Google Service Account

Create secrets

Service Account

This secret enables authentication to Cloud SQL.

kubectl -n sonarqube create secret generic sonarqube-cloudsql-instance-credentials \

Database Username & Password

  • Update [PASSWORD]
kubectl -n sonarqube create secret generic sonarqube-cloudsql-db-credentials \
--from-literal=username=sonar \
--from-literal=password="[PASSWORD]" \


  • Download the yaml file
kubectl apply -f sonarqube-example.yaml


Create a port-forward connection.

kubectl port-forward deploy/sonarqube 9000:9000 -n sonarqube

Open in browser.

open http://localhost:9000

Login (default).

  • Username: admin
  • Password: admin