Showing posts with label CD. Show all posts
Showing posts with label CD. Show all posts

Wednesday, June 1, 2022

Spring Boot, Jenkins, Docker, Kubernetes on AWS EKS

Here we will

  1. Simple Spring Webflux based API
  2. Containerize the application using Docker
  3. Create CI Jenkins Pipeline 
    1. Build
    2. Run Unit Tests
    3. Run Jacoco Reports
    4. Create Docker Image and Push to DockerHub
  4. Create CD Pipeline
    1. Login to AWS
    2. Pull Docker Image from Docker Hub and create container
    3. Deploy in AWS EKS
  5. Configure CI pipeline to be triggered only when code checked-in to any feature/* branches
  6. Configure CI pipeline to be triggered only when PR raised
  7. Configure CD pipeline to be triggered only when PR merged

1. Simple Spring Webflux based API

For Sample API, please checkout the code from 

  1. Please check the README.md for how to build locally
  2. Beer-Service.postman_collection.json for testing the application using postman. 

2. Containerize the application using Docker

    Add a file name "Dockerfile" into the application folder location. 
    Add below configuration 


FROM adoptopenjdk/openjdk11 COPY build/libs/*SNAPSHOT.jar beerOrderService.jar EXPOSE 8080 CMD ["java", "-jar", "beerOrderService.jar" ]

    

 Here in above file we use the image adoptopenjdk/openjdk11
We copy the built jar file as beerOrderService.jar
We expose the post it need to be executed. 
The execution command to run application once container started 


3. Create CI Jenkins Pipeline 

  1. Build
  2. Run Unit Tests
  3. Run Jacoco Reports
  4. Create Docker Image and Push to DockerHub

Create Jenkins 


Create CD Pipeline
  1. Login to AWS
  2. Pull Docker Image from Docker Hub and create container
  3. Deploy in AWS EKS
Configure CI pipeline to be triggered only when code checked-in to any feature/* branches
Configure CI pipeline to be triggered only when PR raised
Configure CD pipeline to be triggered only when PR merged