Skip to content

aabarmin/epam-spring-cloud-kubernetes-2021

 
 

Repository files navigation

Spring Cloud goes Cloud

This repository contains examples for the talk "Spring Cloud goes Cloud". The main focus of the talk is on running the Spring Boot applications using Docker and Kubernetes.

Available modules

  • config-server - Spring Cloud Config Server
  • discovery-service - Service discovery with Eureka
  • examinator - entry point, transparently sends requests to subsequent challenge providers
  • history - provides challenges about history
  • mathematic - provides challenges about math

Requesting data

To request data you need to send POST request to the examinator's /exams/exam endpoint with the following payload:

{
  "MATH": 1,
  "HISTORY": 1
}

Internally, examinator application will request data from math and history providers.

Building apps

To build the apps you can use Apache Maven because all the apps are using it. However, the build-scripts directory contains a few more scripts which build app differently.

  • build-images-naive.sh - this script runs mvn clean package and next uses simple and naive Dockerfile to build Docker images.
  • build-images-oci.sh - this script builds Docker images with Spring Boot Maven plugin and buildpacks.
  • build-images-layered.sh - this script builds far-jar's and next unpacks them using Spring Boot layered jar. As soon as jar files are unpacked, they are next used to build layered Docker images manually via another Dockerfile.
  • build-images-kubernetes.sh - this script builds jar files with with-kubernetes profile active. This profile is important for the math provider - enables reload of configs from ConfigMaps.

Running apps

Built images can be used to run apps in different ways. See the build-scripts/compose and build-scripts/kubernetes folders.

  • compose/naive - running all the images built by build-images-naive.sh script, uses health checks to wait till containers are started.
  • compose/oci - runs all the containers based on images built by build-images-oci.sh script. As a result no way to check the health here.
  • componse/docker-only - runs all the containers but without service discovery because this functionality is provided by Docker out of the box.
  • kubernetes/config-server - a few scripts which run pods and services in Kubernetes.
  • kubernetes/config-maps - running apps generated by build-images-kubernetes.sh and so that reloading of ConfigMaps are available.
  • kubernetes/autoscaling - the same but with autoscaling based on the CPU usage.

Additional metrics

The examinator app exposes liveness and readiness probes as well as a custom PhaseOfTheMoonHealthIndicator. Additionally, mathematics exposes MetricsConfiguration and metrics internally.

Languages

  • Java 88.4%
  • Shell 10.5%
  • Dockerfile 1.1%