Giter Site home page Giter Site logo

anusha1908 / java-app Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rohan1234/java-spring-boot-eks-deployment-with-jenkins

0.0 0.0 0.0 16 KB

Java Web Application Deployment on AWS EKS with Jenkins - A sample project demonstrating how to build and deploy a Java web application to AWS EKS using Jenkins pipeline.

Java 94.36% Dockerfile 5.64%

java-app's Introduction

java-spring-boot-eks-deployment

Java Web Application Deployment on AWS EKS with Jenkins - A sample project demonstrating how to build and deploy a Java web application to AWS EKS using Jenkins pipeline.

Java Web Application Deployment on AWS EKS with Jenkins

Build Restful CRUD API for a simple Note-Taking application using Spring Boot, Mysql. i am using this as a sample java application for demo purpose

Please find Requirements

  1. Java - 1.8.x

  2. Maven - 3.x.x

  3. Mysql - 5.x.x

Steps to Setup

1. Clone the application

git clone https://github.com/callicoder/spring-boot-mysql-rest-api-tutorial.git

2. Create Mysql database

Created A stateful set for mysql and expose as headless service

3. for connection mysql username and password as per our installation

  • open we have created notes.yaml deployment open the notes.yaml

  • change username and password and db_ip as per your mysql installation

4. Build and run the app using maven and then dockerize

mvn package
docker build -t your-image-name:your-image-tag .

5. Push the Docker image to ECR

aws ecr get-login-password --region your-aws-region | docker login --username AWS --password-stdin your-aws-account-id.dkr.ecr.your-aws-region.amazonaws.com
docker tag your-image-name:your-image-tag your-aws-account-id.dkr.ecr.your-aws-region.amazonaws.com/your-repository-name:your-image-tag
docker push your-aws-account-id.dkr.ecr.your-aws-region.amazonaws.com/your-repository-name:your-image-tag

6. Configure the Jenkins pipeline Create a new Jenkins pipeline and configure it to use the following stages:

  • open Checkout code from GitHub
  • open Build the application using Maven
  • open Dockerize the application
  • open Push the Docker image to ECR
  • open Deploy the application to EKS

Integration with AWS CodeCommit and Lambda Function

To automate the pipeline, I have integrated AWS CodeCommit with Jenkins using a Lambda function. Whenever a code change is made to the repository, the Lambda function triggers the Jenkins pipeline to build and deploy the new code changes.

This integration enables automatic build and deployment of new code changes, reducing the need for manual intervention, and increasing the efficiency of the development process. The app will start running at http://localhost:80.

Zero Downtime Deployment

To achieve zero downtime deployment, I use the latest build number generated by Jenkins as the image tag when pushing the Docker image to AWS ECR. Then, I update the deployment file with the new image tag and apply the changes to the Kubernetes cluster using kubectl apply.

By using this approach, we can ensure that the new version of the application is rolled out gradually, without any disruption to the users of the application.

Jenkins Pipeline

The Jenkins pipeline for this project consists of the following stages:

  1. Build: This stage clones the Git repository and builds the Java web application using Maven.

  2. Docker Build: This stage builds a Docker image of the application and tags it with the latest version.

  3. Logging into AWS ECR: This stage logs into the AWS ECR (Elastic Container Registry) using AWS CLI.

  4. Push to ECR: This stage pushes the Docker image to the AWS ECR.

  5. Deploy to EKS: This stage updates the deployment file with the new Docker image tag and deploys it to the AWS EKS cluster.

Explore Rest APIs

The app defines following CRUD APIs.

GET /api/notes

POST /api/notes

GET /api/notes/{noteId}

PUT /api/notes/{noteId}

DELETE /api/notes/{noteId}

java-app's People

Contributors

rohan1234 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.