Spring Petclinic is a Spring Boot application built using Maven or Gradle. You can build a jar file and run it from the command line (it should work just as well with Java 17 or newer):
git clone https://github.com/spring-projects/spring-petclinic.git
cd spring-petclinic
./mvnw package
java -jar target/*.jarYou can then access the Petclinic at http://localhost:8080/.
Or you can run it from Maven directly using the Spring Boot Maven plugin. If you do this, it will pick up changes that you make in the project immediately (changes to Java source files require a compile as well - most people use an IDE for this):
./mvnw spring-boot:runNOTE: If you prefer to use Gradle, you can build the app using
./gradlew buildand look for the jar file inbuild/libs.
- Prerequisites
- 1. Repository Setup
- 2. EKS Cluster Setup
- 3. Jenkins Installation
- 4. AWS Credentials Configuration
- 5. SonarQube Server Installation
- 6. Tools and Plugins Configuration
- 7. Kubernetes Configuration
- 8. Helm Charts
- 9. CI/CD Pipeline
- 10. Post-deployment Verification
- 11. Troubleshooting Guide
- AWS Account with appropriate permissions
- AWS CLI installed and configured
- kubectl installed
- Helm installed
- Git installed
# Clone the repository
git clone https://github.com/SubbuTechOps/spring-petclinic.git
cd spring-petclinic
# Verify the contents
ls -laThis document provides access to the comprehensive guide for setting up an Amazon EKS (Elastic Kubernetes Service) cluster.
This guide includes:
- EKS cluster creation steps
- Networking configuration
- Security group setup
- Node group management
- Access control configuration
- Best practices and recommendations
📚 Download Jenkins Installation Script
This shell script automates the installation and configuration of Jenkins server and required tools.
chmod +x install-jenkins.sh
sudo ./install-jenkins.sh- Essential system utilities (wget, curl, unzip, etc.)
- Jenkins server
- Docker
- kubectl
- AWS CLI
- Trivy scanner
- Helm
- Required permissions and configurations
- URL: http://YOUR_SERVER_IP:8080
- Default Port: 8080
- Initial Admin Password: Found in script output or at
/var/lib/jenkins/secrets/initialAdminPassword
- Log in to AWS Management Console
- Navigate to IAM (Identity and Access Management)
- Select your IAM user
- Go to "Security credentials" tab
- Click "Create access key"
- Download and securely store the credentials file
# Configure AWS CLI with your credentials
aws configure
AWS Access Key ID [None]: <Your-Access-Key>
AWS Secret Access Key [None]: <Your-Secret-Key>
Default region name [None]: ap-south-1
Default output format [None]: table
# Verify AWS CLI configuration
aws sts get-caller-identity# List available EKS clusters
aws eks list-clusters
# Update kubeconfig for your EKS cluster
aws eks update-kubeconfig --name <your-cluster-name> --region <your-cluster-region>
# Verify kubeconfig
cat ~/.kube/config
# Test kubectl configuration
kubectl get nodes
kubectl get ns📚 Download SonarQube Installation Script
This shell script automates the installation and configuration of SonarQube server.
chmod +x install-sonarqube.sh
sudo ./install-sonarqube.sh- SonarQube server (Latest LTS version)
- Dedicated sonar user
- Systemd service for automatic startup
- System limits and requirements
- Firewall rules
- URL: http://YOUR_SERVER_IP:9000
- Default credentials: admin/admin
- Default port: 9000
# Check service status
sudo systemctl status sonarqube
# View logs
sudo tail -f /opt/sonarqube/logs/sonar.log
# Check if port is listening
sudo netstat -tlpn | grep 9000# Stop SonarQube
sudo systemctl stop sonarqube
# Start SonarQube
sudo systemctl start sonarqube
# Restart SonarQube
sudo systemctl restart sonarqube
# Check logs
sudo journalctl -u sonarqube -f- Login to SonarQube (http://YOUR_SERVER_IP:9000)
- Navigate to "Projects" → "Create Project"
- Select "Manual" setup
- Fill in project details:
- Project key:
PetClinic - Display name:
PetClinic - Main branch name:
main
- Project key:
- Go to User → My Account → Security
- Generate a new token:
- Token name:
jenkins-integration - Expiration: Choose appropriate expiration (e.g., 30 days)
- Token name:
- Copy and securely store the generated token
- Go to Administration → Security → Users
- Click on your user
- Under "Permissions", ensure the following are enabled:
- Execute Analysis
- Create Projects
- Create Applications
- Create Portfolios
- Navigate to Jenkins → Manage Jenkins → Credentials → System
- Click on "Global credentials" → "Add Credentials"
- Configure the credentials:
Kind: Secret text Scope: Global Secret: <Your-SonarQube-Token> ID: sonar-credentials Description: SonarQube Authentication Token
- Navigate to Jenkins Dashboard → Manage Jenkins → System
- Scroll down to the "SonarQube servers" section
- Configure the following settings:
- Check "Environment variables" if you want administrators to inject SonarQube configuration as environment variables
- Under "SonarQube installations":
- Name:
SonarQube - Server URL:
http://3.92.82.78:9000(replace with your SonarQube server IP) - Server authentication token:
- Click "Add" → Select "Jenkins"
- Kind: Secret text
- Secret: Paste your SonarQube authentication token
- ID:
sonar-credentials - Description: "SonarQube Authentication Token"
- Click "Add"
- Select the created credential from the dropdown
- Name:
- Click "Advanced" if you need to configure additional settings
- Click "Save" or "Apply" to preserve the configuration
- After saving the configuration, return to the Jenkins dashboard
- Create a test pipeline job
- Add the following environment variables in your Jenkinsfile:
environment {
SONARQUBE_HOST_URL = 'http://<sonar-ip>:9000'
SONARQUBE_PROJECT_KEY = 'PetClinic'
SONARQUBE_TOKEN = credentials('sonar-credentials')
}# Check SonarQube logs
sudo tail -f /opt/sonarqube/logs/sonar.log
# Verify SonarQube service status
sudo systemctl status sonarqube
# Check Jenkins logs for integration issues
sudo tail -f /var/log/jenkins/jenkins.log
# Test SonarQube connectivity from Jenkins
curl -v http://<sonar-ip>:9000-
Pipeline and SCM
- Pipeline
- Git
- GitHub Integration
-
Build Tools
- Maven Integration
- JDK Tool
-
Docker & Kubernetes
- Docker
- Docker Pipeline
- Kubernetes
- Kubernetes CLI
-
SonarQube
- SonarQube Scanner
- Quality Gates
-
Credentials
- Credentials Binding
- Credentials
- Go to Jenkins Dashboard → Manage Jenkins → Plugins → Available plugins
- Search and install the above plugins
- Select "Install without restart"
- Restart Jenkins after installation completes
After restart, verify in Manage Jenkins → Plugins → Installed plugins that all required plugins are active.
- Navigate to Jenkins > Manage Jenkins > Manage Credentials
- Add the following credentials:
- GitHub credentials
- Docker Hub credentials
- AWS credentials
- SonarQube Token
- Kubernetes configuration
# app-config.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: app-config
namespace: petclinic-dev
data:
MYSQL_DATABASE: petclinic
MYSQL_URL: jdbc:mysql://mysql-service:3306/petclinic# db-secrets.yaml
apiVersion: v1
kind: Secret
metadata:
name: db-secrets
namespace: petclinic-dev
type: Opaque
data:
MYSQL_USER: cGV0Y2xpbmlj # Base64 encoded value for 'petclinic'
MYSQL_PASSWORD: cGV0Y2xpbmlj # Base64 encoded value for 'petclinic'
MYSQL_ROOT_PASSWORD: cm9vdA== # Base64 encoded value for 'root'# mysql-pv.yaml
apiVersion: v1
kind: PersistentVolume
metadata:
name: mysql-pv
spec:
capacity:
storage: 8Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: manual
awsElasticBlockStore:
volumeID: vol-00ad22c086bb5817f
fsType: ext4Note:
petclinic-chart/
├── templates/
│ ├── deployment-app.yaml
│ ├── deployment-db.yaml
│ ├── pvc.yaml
│ ├── service-app.yaml
│ └── service-db.yaml
├── Chart.yaml
└── values.yaml
- 🗂️ Petclinic Chart Directory - Contains main chart configuration and values
- 📑 Templates Directory - Contains Kubernetes manifests and service definitions
🔄 Jenkins Pipeline - Contains CICD pipeline configuration and build steps:
📋 Deployment Resources: 📚 Project Demo Steps
- 🔍 Post-deployment Verification - Complete verification steps and checks after deployment
# Check deployment status
kubectl get deployments -n petclinic-dev
# Check pods
kubectl get pods -n petclinic-dev
# Check services
kubectl get svc -n petclinic-dev
# View logs
kubectl logs -f deployment/petclinic -n petclinic-dev
# Test the application
curl http://$(kubectl get svc petclinic -n petclinic-dev -o jsonpath='{.status.loadBalancer.ingress[0].hostname}'):8080-
Jenkins Pipeline Failures
- Issue: Maven build fails
- Solution: Check Java version compatibility and Maven settings
-
Docker Issues
- Issue: Permission denied
- Solution: Ensure Jenkins user is in docker group
sudo usermod -aG docker jenkins sudo service jenkins restart
-
Kubernetes Deployment Issues
- 🛠️ Kubernetes Troubleshooting Guide - Common issues and solutions for Kubernetes deployments
-
Database Connection Issues
- Issue: Application can't connect to MySQL
- Solution: Verify MySQL service and credentials
kubectl exec -it <mysql-pod> -- mysql -u root -p
# Check node status
kubectl get nodes
# Check pod health
kubectl get pods -n petclinic-dev -o wide
# Check logs
kubectl logs -f deployment/petclinic -n petclinic-dev
# Check service endpoints
kubectl get endpoints -n petclinic-devRemember to replace placeholder values such as your-region, your-docker-hub-username, and adjust resource limits based on your requirements.
For additional support or specific error resolution, consult the project's GitHub issues or create a new issue with detailed information about the problem encountered.
