Code Monkey home page Code Monkey logo

rak_eks_pipeline_project's Introduction

Readme GitHub Actions - Pipeline

This document is intended to explain how to automate the Build and Deployment of a Java applications using GitHub actions.

Execution Methodology

  1. Create the Application and copy to GitHub

    • Login to the website https://start.spring.io/ and create an application with the below parameters.

              Project		:	Maven
      	language	:	Java
      	Springboot	:	3.2.2
      	Metadata		:	rak.example.com
      	Packaging	:	jar
      	Java			:	17
      
    • Unzip the package and copy the files to the GitHub repository.

  2. Write the Dockerfile to containarize the application.

    • Use multi stage Docker file to reduce the image size and improve the security

      	# Stage I
      	FROM maven:3.8.5-openjdk-17-slim AS BUILD
      	COPY pom.xml /tmp/
      	COPY src /tmp/src/
      	WORKDIR /tmp/
      	RUN mvn package
      	
      	# Stage II
      	FROM eclipse-temurin:17
      	COPY --from=BUILD /tmp/target/rak-0.0.1-SNAPSHOT.jar /data/rak-0.0.1-SNAPSHOT.jar
      	CMD ["java", "-jar", "/data/rak-0.0.1-SNAPSHOT.jar"]
      	EXPOSE 8080
      
    • Maven will build and package the application as executable (.jar) file using the provided application files in the stage I. The application will be listening on port 8080.

  3. Configure GitHub actions for continuos integration

    • To automate the build process and deployment configure gitHub Actions.

    • Create a file .github/workflows/actions in the repository and declare the Buils and Deployment steps

    • Declare the insensitive data as variables as below, Also do modification if necessary

       	env:
       		CONTAINER_REGISTRY: docker.io
       		CONTAINER_IMAGE: samplerak
       		REPOSITORY_NAME: sharon111edapal
       		IMAGE_TAG: ${{ github.run_number }}
       		AWS_REGION: ap-south-1
      

      Configure the sensitive data and AWS credetials as secrets under the project.

           Repository --> Secrets & Variables --> Actions --> Repository Secrets
      
    • Finally deploy the application into EKS with the below configuration

      	   name: Deploy
      			run: |
      			aws eks update-kubeconfig --name rak-eks-cluster
      			sed -i "s/latest/${{ env.IMAGE_TAG }}/" deployment.yaml
      			kubectl apply -f deployment.yaml
      
    • The deployment file will be creating the below resiurces

              *	A new Aamespace - rak
      	*	A Deployment with 1 replicaset 
      	*	A NodePort service to expose the application (8080 --> 30000)
      
    • Naviagate to Actions --> Docker Build --> RUn workflow to create a new run and validate the result.

  4. Configure sonarqube for Code Analysis.

    • Configure Sonarqube for codeanalysis on each pull request.
    • Navigaet to https://sonarcloud.io/ website and create an Organization and Project.
    • Integrate SonarCloud with Git repo and update pom.xml with sonar property.
    • Create sonar.yml file under .github/workflows directory and paste the auto generated content from the sonarCloud.
    • After each pull reguest check the workflow runs under Actions --> SonalCloud
  5. Access the application.

    • Get the public IP of the Node and access the Application via NodePort (eg : 10.0.1.34:30000)

rak_eks_pipeline_project's People

Contributors

sharon111edapal avatar sao047 avatar

Watchers

 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.