Maher-RJ / RestAPI-K8s-Docker-Java

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Simple Student Management

Introduction

This web application was developed to enable the insertion of student data into a database and its retrieval through REST APIs. The application is cloud-native and can be easily deployed to any Kubernetes environment with no code changes required.

To develop this application, a range of technologies were used, including Java and Spring Boot for the web server, Hibernate/JPA for object-relational mapping, H2DB for data persistence, Github Actions for the CI pipeline, Docker for containerization, and Kubernetes service and deployment YAML files to expose the service to the internet and deploy it on Kubernetes, respectively.

Overall, this application aims to provide a robust and scalable platform for storing and accessing student data in a cloud environment.

Solution Architecture

studentmangement

This application was developed with a focus on design principles that aim to improve code quality and handle design complexity effectively. These principles include:

Single Responsibility Principle (SRP)
Open/Closed Principle (OCP)
Liskov Substitution Principle (LSP)
Interface Segregation Principle (ISP)
Dependency Inversion Principle (DIP)

The application contains two different REST endpoints, one for POST requests and one for GET requests. These endpoints are capable of persisting student data into the database and retrieving it, respectively. Both endpoints were designed with best practices and REST naming conventions in mind, ensuring their ease of use and maintainability.

Insert Student Data

test1

Retrieve Student Data

test2

As above screenshots depict, even though password was inserted, it was not returning with the GET request since password consider as sensitive field and ignored.

All the possible exceptions were handled with try catch statements which will help to keep the application up and running all the time even though exception occurred. It increases the stability and availability of the system.

Containerization

Application was containerized using Docker and could be deployed on any Kubernetes cluster without changing single line of code.

Containerize Architecture

docker

Dockerize commands

docker build -f Dockerfile -t student-management-service .
docker run --rm -p 8080:8080 student-management-service:latest

Deployment on Kubernetes

Application is cloud native and supports Kubernetes by nature since the containerization. Application is being deployed as pod inside the cluster and exposed it as Kubernetes service which allow outsiders to access the application endpoints. Pod will be replication which will provide high availability and ensure the reliability of the system. Kubernetes pod resource configuration were done to respond and replicate on demand in order to keep the availability and stability of the system.

Deployment Architecture

Design3

Deployment Commands

kubectl apply -f deployment.yaml
kubectl apply -f pod.yaml
kubectl apply -f service.yaml
kubectl apply -f ingress.yaml

Above command will deploy entire application on Kubernetes cluster

About


Languages

Language:Java 98.7%Language:Dockerfile 1.3%