Skip to content

Students-api is a micro service project build using Spring Boot and Open API Spec 3.0.0 with API First Design approach. The service uses mongo-db as storage and can be deployed using Docker, Kubernetes or Helm chart.

Notifications You must be signed in to change notification settings

sainik73/students-api

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Welcome to students-api

students-api Maven Build

This repository shows the working example of how to design and build an API using the API First Design approach. The Design First approach advocates for designing the API's contract first before writing any implementation/code.

Summary

Open API spec File 'students-api.yaml' [located under 'src/main/resources']

Any modification to students-api.yaml file, necessitates the build of the project as per below instructions to regenerate the API and Model classes. This is done using the swagger-codegen-maven-plugin. REST Controller 'StudentsApiController' consumes these generated classes.

Version

v1.0: The repository now supports Mongo DB as storage. students-api repository connects to Mongo DB, which is run as a Docker container. Java Logs (students-api-logger.log) are created under project root/logs directory.

v2.0: The repository now supports spring boot application and MongoDB deployment to Kubernetes local cluster. MongoDB credentials are stored in a secret file.

v2.1: The repository now supports application builds using helm charts.

Instructions

v1.0 Build Instructions:

  1. Clone this repository:

git clone https://github.com/sainik73/students-api

  1. Checkout branch v1.0
  2. Run Mongo docker instance by following instructions in mongo-data\RunMongo.txt file
  3. Build the project with Maven:
> cd students-api/
> mvn clean install
  1. Run the spring boot application 'StudentsApplication'
  2. Test the application using postman Run in Postman

v2.0 Build Instructions:

  1. Clone this repository:

git clone https://github.com/sainik73/students-api

  1. Checkout branch v2.0
  2. Build the project with Maven:
> cd students-api/
> mvn clean install

The build will output a docker image.

  1. Add image to minikube

4.1 Delete any existing image from minikube cache

> minikube cache delete <image-name>

4.2 Enter interactive terminal to minikube and remove image from docker in minikube

> docker exec minikube bash
> docker image rm <image-name>
> exit

4.3 Add image to minikube cache

> minikube cache add <image-name>
  1. Setup Kubernetes resources (deployment, services etc)

5.1 Change directory to "k8s" in terminal [Its located under /src/main/resources]

> kubectl apply -f .
  1. Start service on windows host [It will expose port on host to access service]
> minikube service students-api
  1. Test application

7.1 Modify the postman environment for exposed port

7.2 Run postman collection Run in Postman

v2.1 Build Instructions:

  1. Clone this repository:

git clone https://github.com/sainik73/students-api

  1. Checkout branch v2.1
  2. Build the project with Maven:
> cd students-api/
> mvn clean install

The build will output a docker image.

  1. Install helm repo
> helm repo add bitnami https://charts.bitnami.com/bitnami
  1. Update helm chart dependencies and Install helm chart [Its located under /src/main/resources]
> cd students-api/src/main/resources/helm
> helm dependency update students-api
> helm install students-api students-api
  1. Start service on windows host [It will expose port on host to access service]
> minikube service students-api
  1. Test application

7.1 Modify the postman environment for exposed port

7.2 Run postman collection Run in Postman

Known Issues

Version v2.0:

  1. Constraints defined in yaml are not validated for request payload because of open issue (#7058) in swagger code gen plugin v 3.0.24

About

Students-api is a micro service project build using Spring Boot and Open API Spec 3.0.0 with API First Design approach. The service uses mongo-db as storage and can be deployed using Docker, Kubernetes or Helm chart.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published