cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first...

54
How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff Harald Uebele Developer Advocate, IBM @Harald_U

Transcript of cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first...

Page 1: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff Harald Uebele Developer Advocate, IBM @Harald_U

Page 2: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Once upon a time ...

Page 3: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Never not be afraid”

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

Grug Crood Beginning of ‘The Croods’

Page 4: cloud-native Applications with Java Developer Advocate, IBM …€¦ · 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 @Harald_U #IBMDeveloper github.com/nheidloff/cloud-native-starter

Page 5: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Continuous delivery

→ DevOps

Elasticity

→ App stays responsive

What are cloud-native Applications?

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

Page 6: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

New Options → New Challenges

Page 7: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“A container image is a lightweight, standalone, executable package of software that includes everything needed to run an application.” docker.com

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

Infrastructure

Host Operating System

Container Runtime

App

A

App

B

App

C

App

D

App

E

Page 8: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“I’m a caveman. Can you explain containers so that I understand it?”

@nheidloff @Harald_U

Grug Crood Caveman learning microservices

Page 9: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Portable Containers

Page 10: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Java Image

@nheidloff @Harald_U

Open source stack

OpenJ9 0.12.1

OpenJDK 8u202-b08 from AdoptOpenJDK

Open Liberty 18.0.0.4

MicroProfile 2.1

Dockerfile

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

Page 11: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

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

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

Page 12: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“When a container contains everything to run a microservice, why do I need Kubernetes?”

@nheidloff @Harald_U

Grug Crood Caveman learning microservices

Page 13: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Example Application

Page 14: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Example Application – REST APIs

Web-App Web-API

Articles

Authors

Browser Kubernetes with Istio

Page 15: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Exposing REST APIs

@nheidloff @Harald_U

JAX-RS

Java API for RESTful Web Services

GetArticles.java

Page 16: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Exposing REST APIs

@nheidloff @Harald_U

Open API (formerly Swagger)

API description format for REST APIs

GetArticles.java

Page 17: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Exposing REST APIs

@nheidloff @Harald_U

Open API (formerly Swagger)

API description format for REST APIs

Page 18: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Consuming REST APIs

@nheidloff @Harald_U

MicroProfile Rest Client

Type-safe approach to invoke RESTful services

AuthorsService.java

AuthorsServiceDataAccess.java

Page 19: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Consuming REST APIs

@nheidloff @Harald_U

MicroProfile Rest Client

Type-safe approach to invoke RESTful services

AuthorsService.java

AuthorsServiceDataAccess.java

Page 20: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“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 @Harald_U

Page 21: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Why do I need a service mesh? Can’t I just use Kubernetes?”

@nheidloff @Harald_U

Grug Crood Caveman learning microservices

Page 22: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Example Application – Traffic Management

Web-App

Web-API v1 Articles

Web-API v2 Authors

Browser Kubernetes with Istio

Page 23: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Traffic Management

@nheidloff @Harald_U

80% / 20% splitting

ingress.yaml

Page 24: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Traffic Management

Page 25: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Optimizing Enterprise Java for a Microservices Architecture. [...] by innovating [...] with a goal of standardization.” microprofile.io

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

Page 26: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Dude, I just learned Istio and Kubernetes. Can you show me a simple MicroProfile example?”

@nheidloff @Harald_U

Grug Crood Caveman learning microservices

Page 27: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Example Application – Resiliency

Web-App Web-API

Articles

Authors

Browser Kubernetes with Istio

Page 28: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Resiliency

@nheidloff @Harald_U

Authors service not available

Usage of default values

Service.java

Page 29: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Resiliency

@nheidloff @Harald_U

Articles service not available

MicroProfile Fallback annotation

Service.java

Page 30: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Resiliency

Page 31: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Authentication and Authorization

@nheidloff @Harald_U

OpenID Connect

Identity layer on top of the OAuth 2.0 protocol

IBM App ID

IBM service to authenticate users and protect APIs

policy.yaml

Page 32: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Example Application – Authentication and Authorization

Web-App

Web-API

Articles

Authors

OpenID Connect / IBM App ID

Authentication

@nheidloff @Harald_U

Browser Kubernetes with Istio Optional Cloud Services

Ingress

Page 33: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Authentication

Page 34: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Authorization

Page 35: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Authorization

Page 36: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Authorization

@nheidloff @Harald_U

Via MicroProfile

Manage.java

Page 37: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Microservices sound great, but where is the log file?”

@nheidloff @Harald_U

Grug Crood Caveman learning microservices

Page 38: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Chained invocations Kubernetes

→ 1 service = N pods

Microservices vs monolith

→ Higher complexity

→ Ephemeral

Tracing

Logging

Monitoring

Metrics

Healthchecks

Observability

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

Page 39: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Tracing

@nheidloff @Harald_U

OpenTracing

Vendor-neutral APIs and instrumentation for distributed tracing

Jaeger and Zipkin

Open source distributed tracing systems

server.xml

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

Page 40: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Distributed Tracing

Page 41: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Metrics

@nheidloff @Harald_U

Prometheus

Monitoring system and time series database

GetArticles.java

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

Page 42: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Metrics

Page 43: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

LogDNA

Page 44: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Sysdig

Page 45: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Healthchecks

@nheidloff @Harald_U

MicroProfile Health

Liveness probes and readiness probes

HealthEndpoint.java

Service.yaml

Page 46: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

How to use all Pieces together?

Kubernetes

Java Enterprise Edition

Istio

Eclipse MicroProfile

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

Page 47: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

Leverage platforms as much as possible.

@nheidloff @Harald_U

Use frameworks for app specific logic.

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

Page 48: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

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

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

Page 49: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

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

Web-App

NoSQL / Cloudant

Web-API v1 Articles

Web-API v2 Authors

Web-App

SQL / Db2

OpenID / App ID

LogDNA Sysdig

Authentication @nheidloff @Harald_U

Browser Kubernetes with Istio Optional Cloud Services

Ingress

Page 50: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

IBM Cloud Kubernetes Service including Istio and Knative

Page 51: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Never not be afraid”

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

Grug Crood Beginning of ‘The Croods’

Page 52: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

“Never be afraid”

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

Grug Crood End of ‘The Croods’

Page 53: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff

IBM Developer

developer.ibm.com

IBM Cloud Lite account

ibm.biz/nheidloff

IBM loves open source

Kubernetes and Istio

OpenJ9 & AdoptOpenJDK

MicroProfile

Open Liberty

Leverage platforms as much as possible

Use frameworks for app specific logic

Summary Get the code à

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

Page 54: cloud-native Applications with Java Developer Advocate, IBM …€¦ · How to develop your first cloud-native Applications with Java Niklas Heidloff Developer Advocate, IBM @nheidloff