This project demonstrates the integration and usage of Kubernetes, Jenkins, and SonarQube. The goal is to analyze code using SonarQube, build and tag a Docker image, push it to Docker Hub, and deploy a sample web application on a Kubernetes cluster created using Rancher Desktop on a personal computer.
- Jenkins installed on your personal computer
- SonarQube connected to Jenkins
- Rancher Desktop installed
- GitHub repository containing the pipeline script, Dockerfile, and all necessary files
- Docker Hub account for storing Docker images
-
Install Jenkins
- Install Jenkins on your personal laptop.
- Configure Jenkins with necessary plugins (e.g., Docker, Kubernetes, SonarQube Scanner).
-
Install SonarQube
- Install SonarQube and connect it to Jenkins.
- Configure the SonarQube server details in Jenkins global tool configuration.
-
Configure Docker Hub
- Add Docker Hub credentials to Jenkins for storing Docker images.
-
Pipeline and Docker Setup
- Create a Jenkins Pipeline script and Dockerfile.
- Store these files in your GitHub repository.
- Add your GitHub repository credentials to Jenkins.
-
Install Rancher Desktop
- Install Rancher Desktop to manage Kubernetes on your personal computer.
-
Install Terraform
- It is used to create k8s cluster in digitalocean.
-
Create Deployment
- Use the Docker image to create a deployment in the Rancher Kubernetes cluster or Digital ocean cluster.
This pipeline ensures continuous integration and continuous deployment (CI/CD) by automating the entire process from code checkout to deployment in a Docker container, making the development workflow efficient and reliable.
We are Storing the image we created during Jenkins pipeline here in the docker hub.
To create k8s infra in digital ocean create an api token in digital ocean and run the below command.
export DO_PAT=<api token>Then run the below commands to create the digital ocean cluster
terraform apply -var "do_token=${DO_PAT}"We can deploy k8s application using this below
kubectl apply -f app-deployment.yaml,app-service.yamlUsed to deploy the images we created and stored in Docker hub. It will pull the image and create the deployment. Using the service it will make it visible on port 3000 of the pod.
After This for Rancher port forwarding to forward the port 3000 from pod to port in my computer.
Kustomize will help to create a package of k8s deployment. We can easily deploy the k8s resources using that. Run the below commands to kustomize
kubectl kustomize Kustomized-K8s/base #it will kustomize the deployment and everything
kubectl apply -k kustomize Kustomized-K8s/base
Kustomization for development environment.
kubectl apply -k Kustomized-K8s/overlays/devAlso for Production deployment just change dev to prod
Follow Installation documentation to install Argo CD in your cluster.
Argo CD will help to continuously deploy changes pushed into github in the Kuberentes cluster. After installing it Specify the github repo and it's path(In our case Kustomized-K8s). It will take the code from repo and deploy it in our cluster.
Also there is another way to do using argocd cli.
It's very basic webpage. Since My focus was to use these tools and learn it's working.










