Slide 1

Slide 1 text

@crichardson Service template and Microservice chassis Chris Richardson Founder of Eventuate.io Founder of the original CloudFoundry.com Author of POJOs in Action and Microservices Patterns @crichardson [email protected] adopt.microservices.io Copyright © 2022. Chris Richardson Consulting, Inc. All rights reserved

Slide 2

Slide 2 text

@crichardson Presentation goal What are the Service template and Microservice chassis patterns A walk through the Live Project series Demo the service template

Slide 3

Slide 3 text

@crichardson About Chris http://adopt.microservices.io

Slide 4

Slide 4 text

@crichardson Discounts 35% discount au35ric $110 discount coupon HZCINDYG until 3/23 http://adopt.microservices.io

Slide 5

Slide 5 text

@crichardson Agenda About the Service Template pattern About the Microservice Chassis pattern Live project series: developing a service template and chassis Demoing a service template

Slide 6

Slide 6 text

@crichardson $ mkdir my-new-service

Slide 7

Slide 7 text

@crichardson Configure build logic

Slide 8

Slide 8 text

@crichardson Configure dependencies

Slide 9

Slide 9 text

@crichardson Configure plumbing

Slide 10

Slide 10 text

@crichardson Configure deployment pipeline .github/workflows/build.yml

Slide 11

Slide 11 text

@crichardson Only now can you write your business logic!

Slide 12

Slide 12 text

@crichardson But what about start.spring.io? Convenient BUT Code generator = copy/paste programming Focussed on the Spring Boot ecosystem Simplistic, single Gradle project Generic and flexible - not tailored to your organization’s requirements or standards No sample business logic

Slide 13

Slide 13 text

@crichardson About the service template pattern

Slide 14

Slide 14 text

@crichardson Using a service template to create a new service $ gh clone —private —template myorg/service-template my-new-service $ cd my-new-service

Slide 15

Slide 15 text

@crichardson What you get: build logic Build logic Gradle dependencies { …. } Gradle Plugin configuration Other build logic: GitHub Actions, scripts, …

Slide 16

Slide 16 text

@crichardson What you get: cross cutting concerns Cross-cutting concerns Observability Security Persistence … Testing support

Slide 17

Slide 17 text

@crichardson What you get: sample code Sample application logic Domain logic: entities, repositories, services, …. Adapters: HTTP Controllers, … Tests

Slide 18

Slide 18 text

@crichardson Service template implements: Corporate policies/standards Industry “best practices”

Slide 19

Slide 19 text

@crichardson Agenda About the Service Template pattern About the Microservice Chassis pattern Live project series: developing a service template and chassis Demoing a service template

Slide 20

Slide 20 text

@crichardson A service template (or code generator) = copy/paste Changing requirements = update each service individually

Slide 21

Slide 21 text

@crichardson About the microservice chassis pattern Implements: Corporate policies/standards Industry “best practices”

Slide 22

Slide 22 text

@crichardson Eliminates majority of copy/ paste = small service template build.gradle.kts build.gradle.kts

Slide 23

Slide 23 text

@crichardson When requirements change For example: new version of log4j2 Update microservice chassis and publish a new version Update service template to use new version Update each service to use new version One line change

Slide 24

Slide 24 text

@crichardson Agenda About the Service Template pattern About the Microservice Chassis pattern Live project series: developing a service template and chassis Demoing a service template

Slide 25

Slide 25 text

@crichardson About the Live Project Series Service Template Service Chassis Skeleton application Implement security Package as Docker container Create a microservice chassis Configure observability Live project series

Slide 26

Slide 26 text

@crichardson Starting point = skeleton application Spring Boot Spring Data for JPA Example entity and repository Persistence tests use Testcontainers to run MySQL container …

Slide 27

Slide 27 text

Live project 1: configure observability Observability = key part of production readiness An observable service exposes its internal state to enable monitoring, and troubleshooting Milestones https://microservices.io/patterns/#observability

Slide 28

Slide 28 text

Live project 2: implement security Secure the service API with JSON Web Tokens (JWTs) Milestones https://microservices.io/patterns/#observability

Slide 29

Slide 29 text

Live project 3: Package as a Docker container Build, test and publish a Docker container image to Github container registry Milestones

Slide 30

Slide 30 text

Live project 4: Create a microservice chassis Extract the service chassis framework for the service template Milestones

Slide 31

Slide 31 text

End result: service template + chassis artifacts

Slide 32

Slide 32 text

@crichardson Agenda About the Service Template pattern About the Microservice Chassis pattern Live project series: developing a service template and chassis Demoing a service template

Slide 33

Slide 33 text

Summary: My new Live Project series teaches you how to develop a service template and chassis The service template pattern: Runnable source template for a service Accelerates the creation of a new service Implements plumbing, build logic, …. Built on a Microservice chassis The Microservice chassis pattern Contains the bulk of the plumbing, build logic, …. Minimizes copy/paste duplication in the service template Simplifies maintenance of services

Slide 34

Slide 34 text

@crichardson @crichardson [email protected] adopt.microservices.io Questions? 35% discount code au35ric