Posts

Dockerization of Spring Boot application

  Dockerization of spring Boot The post explains you how to conatainerize the previously created Resource server and the Auth Server using Docker. The post assumes that the following pre-requisites are completed: Docker is setup on your machine https://docs.docker.com/get-started/ You have an account setup with docker hub.( This enables us to store our docker images in docker hub) You have created a public repository in docker hub. Docker file creation The first step is to create a docker file for all the microservice applications: Employee Microservice - Docker File FROM openjdk:8-jdk-alpine MAINTAINER PRASHANT LABEL description="Employee Microservice" ADD ./target/employee-0.0.1-SNAPSHOT.jar /app/service.jar EXPOSE 7003 CMD ["java", "-Xmx1024m", "-jar", "/app/service.jar"] Similarly create for the other microservic...

Microservices with Spring Boot, OAuth2, Docker and Kubernetes

Image
Microservices Architecture The aim is to create a use-case to demonstrate the use of a secured microservices and then containerize it with docker and deploy it with a container orchestration tool like Kubernetes. The entire use-case is sub-divided into various sub-tasks where we try to achieve our goal in a step-by-step manner. At a high level, the sub-tasks include: Create an employee microservice which can act as a Resource server. Create an Authorization server which generates Oauth2 access tokens. Containerize the applications with Docker Deploy application with Kubernetes Swagger setup The source code can be found on GitHub .

Oauth2 Authorization Server

Image
Oauth2 Server The Oauth2 server will be responsible to issue access and refresh tokens based on the following parameters: Client Id Client Secret Username Password The client id- client secret is a unique combination assigned for each resource server that needs to be registered with the oauth2 server. Based on the username and password, the users will be authenticated and a token will be assigned to the user which will also contain the list of roles for a given user. Generate a spring boot project using spring initializer: https://start.spring.io/ with the following dependencies: Spring Data JPA spring-boot-starter-security Spring Web   Add Additional Dependencies:    spring-security-oauth2 spring-security-jwt Final dependency list: < dependency > < groupId > org.springframework.boot </ groupId > < artifactId > spring-boot-starter-da...