Skip to main content

Command Palette

Search for a command to run...

Deploy SonarQube on AWS EKS using Helm Charts

Updated
2 min read
Deploy SonarQube on AWS EKS using Helm Charts

I have already set up my aws eks cluster you can check my other post on hasnode on how to create the aws eks cluster.

What is SonarQube?

SonarQube is a platform for analyzing software for bugs, vulnerabilities, and code smells

Using kubectl Check the status of nodes and pods.

ubuntu@ip-172-31-42-203:~$ kubectl get nodes
NAME                                           STATUS   ROLES    AGE   VERSION
ip-172-31-15-129.ap-south-1.compute.internal   Ready    <none>   69s   v1.27.3-eks-a5565ad
ip-172-31-30-214.ap-south-1.compute.internal   Ready    <none>   67s   v1.27.3-eks-a5565ad

ubuntu@ip-172-31-42-203:~$ kubectl get pods
No resources found in default namespace.
ubuntu@ip-172-31-42-203:~$
Using helm add the repositories ..........

ubuntu@ip-172-31-42-203:~$ helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
"sonarqube" has been added to your repositories


ubuntu@ip-172-31-42-203:~$ helm repo update
Hang tight while we grab the latest from your chart repositories...
...Successfully got an update from the "sonarqube" chart repository
Update Complete. ⎈Happy Helming!⎈

In order to modify the values.yaml file i have untar the sonarqube .

ubuntu@ip-172-31-42-203:~$ helm pull sonarqube/sonarqube --untar
ubuntu@ip-172-31-42-203:~$ ls
snap  sonarqube

ubuntu@ip-172-31-42-203:~$ cd sonarqube/

ubuntu@ip-172-31-42-203:~/sonarqube$ ls
CHANGELOG.md  Chart.lock  Chart.yaml  README.md  charts  templates  values.schema.json  values.yaml

ubuntu@ip-172-31-42-203:~/sonarqube$ vi values.yaml
change the values.yaml entries  like below 
==================
persistence:
  enabled: true
=================
from ClusterIP to Loadbalancer change type
  type: LoadBalancer
====================
i have reduced the size of postgressql db from 20g to 10g
ubuntu@ip-172-31-42-203:~/sonarqube$ kubectl create namespace sonarqube
namespace/sonarqube created

ubuntu@ip-172-31-42-203:~$ helm install -n sonarqube sonarqube sonarqube/
NAME: sonarqube
LAST DEPLOYED: Sun Aug  6 16:20:55 2023
NAMESPACE: sonarqube
STATUS: deployed
REVISION: 1
NOTES:
1. Get the application URL by running these commands:
     NOTE: It may take a few minutes for the LoadBalancer IP to be available.
           You can watch the status of by running 'kubectl get svc -w sonarqube-sonarqube'
  export SERVICE_IP=$(kubectl get svc --namespace sonarqube sonarqube-sonarqube -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
  echo http://$SERVICE_IP:9000

ubuntu@ip-172-31-42-203:~$ kubectl get po,svc,pv -n sonarqube
NAME                         READY   STATUS    RESTARTS   AGE
pod/sonarqube-postgresql-0   1/1     Running   0          3m41s
pod/sonarqube-sonarqube-0    0/1     Running   0          3m41s

NAME                                    TYPE           CLUSTER-IP       EXTERNAL-IP                                                                PORT(S)          AGE
service/sonarqube-postgresql            ClusterIP      10.100.213.232   <none>                                                                     5432/TCP         3m41s
service/sonarqube-postgresql-headless   ClusterIP      None             <none>                                                                     5432/TCP         3m41s
service/sonarqube-sonarqube             LoadBalancer   10.100.96.236    a45f2de6acfe64baa9a2b1407125e899-2121860553.ap-south-1.elb.amazonaws.com   9000:30434/TCP   3m41s

NAME                                                        CAPACITY   ACCESS MODES   RECLAIM POLICY   STATUS   CLAIM                                   STORAGECLASS   REASON   AGE
persistentvolume/pvc-c8ed6dbe-6672-4daf-ba31-c0400048fe13   5Gi        RWO            Delete           Bound    sonarqube/sonarqube-sonarqube           aws-pg-sc               3m38s
persistentvolume/pvc-d82ea54e-8543-4d38-b140-126e952389f6   10Gi       RWO            Delete           Bound    sonarqube/data-sonarqube-postgresql-0   aws-pg-sc               3m38s
ubuntu@ip-172-31-42-203:~$

Using an external URL you can access SonarQube, above kubectl command output has an external URL and IP.