Vous êtes sur la page 1sur 58

How to develop your first

cloud-native Applications
with Java—

Niklas Heidloff
Developer Advocate, IBM
@nheidloff
“Microservices are a software
development technique [...]
that structures an application
as a collection of loosely
coupled services.”
Wikipedia

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


What are cloud-native Applications?

Elasticity Continuous delivery


→ App stays responsive → DevOps

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


New Options → New Challenges
“Kubernetes (K8s) is an open-
source system for automating
deployment, scaling, and
management of containerized
applications.”
kubernetes.io

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


“Istio is an open platform for
providing a uniform way to
integrate microservices,
manage traffic flow across
microservices, enforce
policies and aggregate
telemetry data.”
github.com/istio/istio

@nheidloff
“Optimizing Enterprise Java
for a Microservices
Architecture.

[...] by innovating [...] with a


goal of standardization.”
microprofile.io

@nheidloff @Harald_U #IBMDeveloper github.com/ibm/cloud-native-starter


How to use all Pieces together?

Kubernetes Istio

Java Enterprise Edition Eclipse MicroProfile

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Leverage platforms as
much as possible.

Use frameworks for app


specific logic.
@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter
Design principles Use only open- Make the first Be able to run the
for the end-to- source time experience application in
end example components for as simple as different
‘cloud-native- the core services possible environments
starter’ of the application

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Architecture: End-to-End Example ‘cloud-native-starter’

Browser Kubernetes with Istio Optional Cloud Services

Articles SQL / Db2


Web-API v1

Web-API v2 Authors NoSQL / Cloudant

Web-App Ingress

Web-App Sysdig LogDNA

@nheidloff
Authentication OpenID / App ID
“A container image is a
lightweight, standalone,

App D
App B
App A

App C

App E
executable package of
software that includes Container Runtime
everything needed to run an
Host Operating System
application.”
Infrastructure
docker.com

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Portable Containers
Java Image Dockerfile

Open source stack


OpenJ9 0.14.0
OpenJDK 11.0.3+7 from AdoptOpenJDK
Open Liberty 19.0.0.5
MicroProfile 2.2

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Example Application
Example Application – REST APIs

Browser Kubernetes with Istio

Articles

Web-App Web-API

Authors

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Exposing REST APIs GetArticles.java

JAX-RS
Java API for RESTful Web Services

@nheidloff
Exposing REST APIs GetArticles.java

Open API (formerly Swagger)


API description format for REST APIs

@nheidloff
Exposing REST APIs

Open API (formerly Swagger)


API description format for REST APIs

@nheidloff
Consuming REST APIs AuthorsService.java

MicroProfile Rest Client


Type-safe approach to invoke RESTful services
AuthorsServiceDataAccess.java

@nheidloff
Consuming REST APIs AuthorsService.java

MicroProfile Rest Client


Type-safe approach to invoke RESTful services
AuthorsServiceDataAccess.java

@nheidloff
Example Application – Traffic Management

Browser Kubernetes with Istio

Web-API v1 Articles

Web-App

Web-API v2 Authors

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Traffic Management – Web API Version 1
Traffic Management – Web API Version 2
Traffic Management ingress.yaml

Example: 80% / 20% splitting

@nheidloff
Traffic Management Demo
Example Application – Resiliency

Browser Kubernetes with Istio

Articles

Web-App Web-API

Authors

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Resiliency Service.java

Authors service not available


Usage of default values

@nheidloff
Resiliency Service.java

Articles service not available


MicroProfile fallback annotation

@nheidloff
Resiliency Demo
Resiliency Demo
Authentication and policy.yaml

Authorization

OpenID Connect
Identity layer on top of the OAuth 2.0 protocol

IBM App ID
IBM service to authenticate users and protect APIs

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Example Application – Authentication and Authorization

Browser Kubernetes with Istio Optional Cloud Services

Articles

Web-API

Authors
Web-App Ingress

Authentication OpenID Connect /


IBM App ID
@nheidloff
Authentication
Authorization
Authorization
Authorization server.xml

Via MicroProfile

@nheidloff
Authorization Manage.java

Via MicroProfile

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Observability

Tracing Microservices vs monolith Chained invocations Kubernetes


Logging → Higher complexity → 1 service = N pods
Monitoring → Ephemeral
Metrics
Healthchecks

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Example Application – Distributed Logging

Browser Kubernetes with Istio

Articles

Web-App Web-API

Authors

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Distributed Logging
Example Application – Distributed Logging

Browser Kubernetes with Istio

Articles

Web-App Web-API

Authors

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Distributed Logging
Tracing server.xml

OpenTracing
Vendor-neutral APIs and instrumentation for
distributed tracing

Jaeger and Zipkin


Open source distributed tracing systems

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Distributed Tracing
Metrics GetArticles.java

Prometheus
Monitoring system and time series database

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Metrics
Healthchecks HealthEndpoint.java

MicroProfile Health
Liveness probes and readiness probes

Service.yaml

@nheidloff
Persistence via JPA

Browser Kubernetes with Istio Optional Cloud Services

Articles SQL / Db2


Web-API

Web-App Ingress

Web-App

@nheidloff
Persistence server.xml

Via JPA

@nheidloff
Persistence ArticleEntity.java

Via JPA

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Configuration kubernetes.yaml

Via MicroProfile

@nheidloff
Configuration CoreService.java

Via MicroProfile

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Try out the end-to-end
microservices example
cloud-native-starter!

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter


Documentation
IBM Cloud Kubernetes Service including Istio and Knative
Summary

Get the code à


Leverage platforms as IBM loves open source IBM Developer IBM Cloud Lite account
much as possible
Use frameworks for app Kubernetes and Istio developer.ibm.com ibm.biz/nheidloff
specific logic
OpenJ9 & AdoptOpenJDK
MicroProfile
Open Liberty

@nheidloff #IBMDeveloper github.com/ibm/cloud-native-starter

Vous aimerez peut-être aussi