Skip to content

AndriyKalashnykov/spring-microservices-k8s

Repository files navigation

GitHub CI Status Hits License: MIT

Java Microservices with Spring Boot and Spring Cloud Kubernetes

This is repository accompanies my article for the Tanzu Development Center - Microservices with Spring Cloud Kubernetes Reference Architecture

This Reference Architecture demonstrates design, development, and deployment of Spring Boot microservices on Kubernetes. Each section covers architectural recommendations and configuration for each concern when applicable.

High-level key recommendations:

  • Consider Best Practices in Cloud Native Applications and The 12 Factor App
  • Keep each microservice in a separate Maven or Gradle project
  • Prefer using dependencies when inheriting from parent project instead of using relative path
  • Use Spring Initializr a web application that can generate a Spring Boot project structure, fill in your project details, pick your options, and download a bundled up project

This architecture demonstrates a complex Cloud Native application that addresses following concerns:

  • Externalized configuration using ConfigMaps, Secrets, and PropertySource
  • Kubernetes API server access using ServiceAccounts, Roles, and RoleBindings
  • Health checks using Application Probes
    • readinessProbe
    • livenessProbe
    • startupProbe
  • Reporting application state using Spring Boot Actuators
  • Service discovery across namespaces using DiscoveryClient
  • Exposing API documentation using Swagger UI
  • Building a Docker image using best practices
  • Layering JARs using the Spring Boot plugin
  • Observing the application using Prometheus exporters

Pre-requisites

Clone repository

git clone git@github.com:AndriyKalashnykov/spring-microservices-k8s.git

Start Kubernetes cluster

cd ./spring-microservices-k8s/scripts/
./start-cluster.sh

Configure Kubernetes cluster

cd ./spring-microservices-k8s/scripts/
./setup-cluster.sh

Deploy application to Kubernetes cluster

cd ./spring-microservices-k8s/scripts/
./install-all.sh

Polulate test data

cd ./spring-microservices-k8s/scripts/
./populate-data.sh

Observe Employee service logs

cd ./spring-microservices-k8s/scripts/
./employee-log.sh

Open Swagger UI web interface

cd ./spring-microservices-k8s/scripts/
./gateway-open.sh

Undeploy application from Kubernetes cluster

cd ./spring-microservices-k8s/scripts/
./delete-all.sh

Delete Application specific Kubernetes cluster configuration (namespaces, clusterRole, etc.)

cd ./spring-microservices-k8s/scripts/
./destroy-cluster.sh

Stop Kubernetes cluster

cd ./spring-microservices-k8s/scripts/
./stop-cluster.sh

Stargazers over time

Stargazers over time