Skip to content

GadagojuShiva/employee-management-java-spring-boot

Repository files navigation

🎉 Employee Management System! 🎉

The Employee Management System is a lightweight, in-memory web application designed to simplify the handling of employee information. Developed using Spring Boot and Thymeleaf, this application enables users to effortlessly add, view, and delete employee records. The intuitive interface provides a smooth experience for managing your workforce without the need for external databases.

Key Features:

Add Employee

Seamlessly input new employee details through a user-friendly form.

Employee List

Access a comprehensive list of all employees, each with a unique identifier.

Delete Employee

Remove employees from the system with a simple click.

Technology Stack:

  • Backend: Crafted using Spring Boot, providing a robust and scalable foundation.
  • Frontend: Utilizes Thymeleaf for server-side rendering, ensuring dynamic and responsive user interfaces.
  • Storage: In-memory storage eliminates the need for an external database, making it a lightweight solution.

About the Developer:

@Gadagoju Shiva This Employee Management System was skillfully developed, and its efficiency was enhanced through the use of ChatGPT, a powerful language model developed by OpenAI. This collaboration enabled rapid development, contributing to the creation of a seamless and resource-efficient in-memory application.

Architechture

Architecture

Detailed Step-by-Step Process

Table of Contents

  1. Launch EC2 Instance with t2.large and Ubuntu using a Keypair
  2. Install Java and Jenkins on EC2 Instance
  3. Install SonarQube on EC2 Instance
  4. Configure Jenkins for SonarQube Integration
  5. Install Docker on EC2 Instance
  6. Install Argo CD on Kubernetes
  7. Final Steps

Launch EC2 Instance with t2.large and Ubuntu using a Keypair

EC2 Console

SSH To the EC2 instance:

ssh -i <keypair.pem> ubuntu@<ec2ip>

Install Java and Jenkins on EC2 Instance

Step 1: Update package list and install Java 11

sudo apt update
sudo apt install openjdk-11-jre

Step 2: Verify Java installation

java -version

Step 3: Install Jenkins

curl -fsSL https://pkg.jenkins.io/debian/jenkins.io-2023.key | sudo tee /usr/share/keyrings/jenkins-keyring.asc > /dev/null
echo deb [signed-by=/usr/share/keyrings/jenkins-keyring.asc] https://pkg.jenkins.io/debian binary/ | sudo tee /etc/apt/sources.list.d/jenkins.list > /dev/null
sudo apt-get update
sudo apt-get install jenkins

Step 4: Copy the Jenkins key generated during installation and paste it into Jenkins

The initial admin password for Jenkins is stored in:

sudo cat /var/lib/jenkins/secrets/initialAdminPassword

Step 5: Switch to the root user

sudo su -

install-sonarqube-on-ec2-instance

Step 6: Add a user named "sonarqube" and switch to that user

adduser sonarqube
sudo su - sonarqube

Step 7: Install SonarQube and generate a token

apt install unzip
wget https://binaries.sonarsource.com/Distribution/sonarqube/sonarqube-9.4.0.54424.zip
unzip *
chmod -R 755 /home/sonarqube/sonarqube-9.4.0.54424
chown -R sonarqube:sonarqube /home/sonarqube/sonarqube-9.4.0.54424
cd sonarqube-9.4.0.54424/bin/linux-x86-64/
./sonar.sh start

Access SonarQube in the browser and generate a token

password = admin
username = admin

Configure-jenkins-for-sonarqube-integration

EC2 Console

Step 8: Generate a GitHub token and add it to Jenkins

  • To Generate a GitHub token, go to GitHub settings → developers settings → tokens → generate classic token

    EC2 Console

  • To add GitHub token in Jenkins, go to Jenkins → manage Jenkins → credentials → global → add credentials

    Step 9: Install required plugins in Jenkins: Docker Pipeline, SonarQube Scanner

  • Go to manage Jenkins → plugins → available plugins → search for Docker Pipeline and SonarQube plugins and install them

    Step 10: Add Git and Docker credentials in Jenkins

  • To add Git and Docker in Jenkins credentials, go to Jenkins → manage Jenkins → credentials → global → add credentials

    install-docker-on-ec2-instance

    Step 11: Install Docker on the EC2 instance

    sudo apt update
    sudo apt install docker.io

    Step 12: Grant Jenkins and Ubuntu users permissions to Docker daemon

    sudo su -
    usermod -aG docker jenkins
    usermod -aG docker ubuntu
    systemctl restart docker

    Step 13: Launch the Minikube cluster in your local system, not in EC2

    For Windows:
        minikube start --memory=3000 --driver=hyperv
    For macOS:
        minikube start --memory=3000 --driver=hyperkit

    Install - Argo - Cd - On - Kubernetes

    EC2 Console

    Step 1: Install Operator Lifecycle Manager (OLM)

    curl -sL https://github.com/operator-framework/operator-lifecycle-manager/releases/download/v0.26.0/install.sh | bash -s v0.26.0

    Step 2: Install Argo CD Operator

    kubectl create -f https://operatorhub.io/install/argocd-operator.yaml

    Step 3: Create Argo CD cluster manifest (argocd-cluster.yaml)

    apiVersion: argoproj.io/v1alpha1
    kind: ArgoCD
    metadata:
      name: example-argocd
      labels:
        example: basic
    spec: {}

    Step 4: Apply the manifest

    kubectl apply -f argocd-cluster.yaml

    Step 5: Get the Argo CD service and change it from ClusterIP to NodePort

    kubectl get svc
    kubectl edit svc <argocd-service-name>
    # Change type: ClusterIP to type: NodePort

    Step 6: To get the admin password

    kubectl get secrets
    kubectl get secret <argocd-secret-name> -o=jsonpath='{.data.admin\.password}' | base64 -d

    Step 7: Access Argo CD web UI using the NodePort and login with admin credentials

    EC2 Console

    Final Steps:

  • Now create a new item in Jenkins using a pipeline
  • Change the Jenkins pipeline script
  • Add the SonarQube URL to the Jenkins script
  • Also, check that the credentials name in Jenkins should
  • match the credentials in the Jenkins script
  • Build the pipeline
  • Even if you get errors, it's totally fine; check the logs and solve the issues using ChatGPT or Google to help.

    Pipeline: EC2 Console

    Build sucessfully: EC2 Console Check Docker Hub: EC2 Console

    Now Create an application in Argo CD using the UI

  • Create application → name = "employee-management" → namespace = "default" → git repo = "https://github.com/gadagojushiva/employee-management-system" → path = "employee-management-manifest" → create

    EC2 Console

    Now check in Minikube

    kubectl get pods
    kubectl get svc

    Create a service for the application:

    vim employee-management-service.yml

    Add the following to the YAML file:

    apiVersion: v1
    kind: Service
    metadata:
      name: employee-management-system
    spec:
      type: NodePort
      ports:
      - name: http
        port: 80
        targetPort: 8080
        protocol: TCP
      selector:
        app: employee-management-system

    To Get the Services

    kubectl get svc

    EC2 Console

    minikube service list

    EC2 Console

    kubectl get pods

    EC2 Console

    Access the application at the provided URL.

    EC2 Console

    🎉 Congratulations! 🎉

    Extra Screenshots and CleanUp:

  • Delete Minikube
  • Terminate EC2 Instance
  • Don't Forget to delete the token that generated in the github
    minikube delete

    EC2 Console EC2 Console

    🎉 Successfully built an Employee Management System Spring Boot application using Maven and deployed it to Kubernetes using Argo CD! 🎉