Revolutionize Your DevOps: Deploying SonarQube on Amazon EKS Cluster Using Helm Chart
Overview :-
SonarQube is a popular tool for continuous code quality inspection. It helps developers find and fix bugs, vulnerabilities, and code smells in their projects. Deploying SonarQube on an Amazon EKS (Elastic Kubernetes Service) cluster using Helm charts can improve your DevOps workflow by making it easier to manage and scale your code analysis infrastructure.
In this blog post, we’ll walk through the process of setting up SonarQube on an Amazon EKS cluster using Helm charts. This approach offers several benefits, including simplified deployment, easier updates, and better resource management.
Prerequisites :-
Before we begin, make sure you have the following tools and resources ready:
1. An active Amazon Web Services (AWS) account
2. AWS CLI installed and configured
3. kubectl installed and configured to work with your EKS cluster
4. Helm 3 installed on your local machine
5. An existing Amazon EKS cluster
If you’re new to any of these tools, I recommend taking some time to familiarize yourself with them before proceeding. When I first started working with EKS and Helm, I found the learning curve a bit steep, but the effort was worth it in the long run.
Procedure :-
Let’s break down the process into manageable steps:
Step 1: Create a namespace for SonarQube
It’s a good practice to deploy SonarQube in its own namespace. Create a new namespace called ‘sonarqube’:
kubectl create namespace sonarqube
Step 2: Create an Elastic File System and Mount target on your aws account
Login to your aws account and navigate to efs service.
Click on create file system and give a name to the file system and select the vpc.
Mount the efs target on your specified subnets.
Step 3: Create storage class
create a yaml file named storageclass.yaml and copy the below code into your yaml. Replace YOUR EFS_FILE_SYSTEM_ID with your efs id.
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: sonarqube-sgc
provisioner: efs.csi.aws.com
parameters:
provisioningMode: efs-ap
fileSystemId: <YOUR EFS_ID> # your Elastic file system-id.
directoryPerms: "755"
kubectl apply -f storageclass.yaml
Step 3: Create Persistent Volume claim
Create a PVC and attach to the storage class
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: sonarqube-pvc
namespace: sonarqube
spec:
accessModes:
- ReadWriteMany
resources:
requests:
storage: 5Gi
storageClassName: sonarqube-sgc
Next, create a Persistant Volume claim (PVC) on your
Step 2: Add the SonarQube Helm repository
helm repo add sonarqube https://SonarSource.github.io/helm-chart-sonarqube
helm repo update
Step 3: Install SonarQube using Helm
Now, we can install SonarQube using the Helm chart:
helm upgrade --install -n sonarqube sonarqube sonarqube/sonarqube
This command will deploy SonarQube with default settings. If you need to customize the deployment, you can create a values.yaml file and use the -f flag to specify it during installation.
Step 4: Wait for the deployment to complete
It may take a few minutes for all the resources to be created and for SonarQube to start up. You can check the status of the pods using:
kubectl get pods -n sonarqube
Wait until all pods are in the ‘Running’ state.
Step 5: Access SonarQube
By default, the SonarQube service is exposed as a ClusterIP. To access it, you can either set up an Ingress or use port-forwarding for testing purposes. For port-forwarding, run:
kubectl port-forward svc/sonarqube-sonarqube 9000:9000 -n sonarqube
Now you can access SonarQube by opening a web browser and navigating to http://localhost:9000.
Step 6: Initial setup
When you first access SonarQube, you’ll need to log in with the default credentials (admin/admin) and set a new password. After that, you can start setting up your projects and configuring your analysis settings.
Conclusion :-
Deploying SonarQube on an Amazon EKS cluster using Helm charts is an efficient way to integrate continuous code quality inspection into your DevOps pipeline. This approach offers flexibility, scalability, and ease of management. By embracing Sonarqube on your EKS cluster, you’ve not only elevated your code quality management but also streamlined the process of continuous inspection. Helm charts have proven to be instrumental in simplifying complex deployments, making the integration of Sonarqube into your Kubernetes environment a seamless experience. As your team continues to iterate and innovate, the insights provided by Sonarqube will serve as a compass, guiding you towards cleaner, more maintainable code. Happy coding! 🚀🔍 #DevOps #CodeQuality #Sonarqube #EKS #Helm #ContinuousInspection