1
Cloud Native Microservice with
MicroProfile, Docker,
Kubernetes, Istio and OpenShift
Emily Jiang, Java Champion
Senior Technical Staff Member, IBM
Liberty Microservice Architect, Advocate
Senior Lead in MicroProfile, IBM
@emilyfhjiang
2
Agenda
• Introduction to MicroProfile
• Introduction to Open Liberty
• Introduction to the Lab
• Summary
• Time to code!
3
Community Driven
Lightweight, Iterative
Processes
Specs, APIs, TCKs
NO Reference
Implementation
4
MicroProfile Community
● Over a dozen vendors and Java
user groups
● Around 169 individual
contributors and growing
● Around a dozen independent
implementations
5
 Open specifications
 Wide vendor support
 REST Client
 OpenAPI support
 Security
 Fault Tolerance
 Configuration
 Metrics
 Health
 Open Tracing
https://wiki.eclipse.org/MicroProfile/Implementation
Quarkus
6
6
MicroProfile 1.0 (Fall 2016)
JAX-RS 2.0
CDI 1.2
JSON-P 1.0
MicroProfile 1.1 (August 2017)
microProfile-1.0
Config 1.0
MicroProfile 1.2 (Sept 2017)
MicroProfile-1.1
Config 1.1
Fault Tolerance 1.0
Health 1.0
Metrics 1.0
JWT 1.0
2017
2018
MicroProfile 1.3 (Dec 2017)
MicroProfile 1.2
Config 1.2
Metrics 1.1
OpenApi 1.0
OpenTracing 1.0
RestClient 1.0
MicroProfile 1.4 (June 2018)
MicroProfile 1.3
Config 1.3
Fault Tolerance 1.1
JWT 1.1
Open Tracing-1.1
Rest Client-1.1
2019
MicroProfile 2.0.1 (July 2018)
MicroProfile 1.4
JAX-RS 2.1 // Java EE 8
CDI 2.0 // Java EE 8
JSON-P 1.1 // Java EE 8
JSON-B 1.0 // Java EE 8
MicroProfile 2.1 (Oct
2018)
MicroProfile 2.0
OpenTracing 1.2
MicroProfile 2.2 (Feb 2019)
Fault Tolerance 2.0
OpenAPI 1.1
OpenTracing 1.3
Rest Client 1.2
MicroProfile 3.0 (June
2019)
MicroProfile 2.1
Metrics 2.0
Health Check 2.0
Rest Client 1.3
MicroProfile 3.2 (Nov 2019)
MicroProfile 3.0
Metrics 2.2
Health Check 2.1
2020
MicroProfile 3.3 (Feb 2020)
MicroProfile 3.2
Config 1.4
Metrics 2.3
Fault Tolerance 2.1
Health 2.2
Rest Client 1.4
7
Eclipse MicroProfile
Health Metrics
Fault
Tolerance
Open API Config
Open Tracing
JWT
JSON-BRest ClientJAX-RSCDI JSON-P LRA
GraphQL
Reactive
Streams
Operators
Reactive
Messaging
Context
Propagation
earlyevolutionspecifications
8
openliberty.io
Jan Dec
20.0.0.2
20.0.0.1 20.0.0.3
4-week release cadence
9
https://github.com/OpenLiberty/tutorial-microprofile
10
There’s a good chance you’ll use REST APIs
11
Eclipse MicroProfile
JAX-RS JSON-PCDIRest Client JSON-B
microprofile.io
12
JAX-RS
B
@ApplicationPath("System")
public class SystemApplication extends
Application {}
@Path("properties")
public class PropertiesResource {
@GET
@Produces(MediaType.APPLICATION_JSON)
public JsonObject getProperties() {…}
}
13
CDI
BA
public class InventoryManager {
@Inject
private SystemClient systemClient;
…
}
14
JSON-B & JSON-P
A B
...
@GET
@Produces(MediaType.APPLICATION_JSON)
public InventoryList listContents() {
return manager.list();
}
public class InventoryList {
private List<SystemData> systems;
public InventoryList(List<SystemData> systems) {
this.systems = systems;
}
public List<SystemData> getSystems() {
return systems;
}
public int getTotal() {
return systems.size();
}
}
15
MicroProfile REST Client
BA
@Inject
@RestClient
private SystemClient defaultRestClient;
@Dependent
@RegisterRestClient
@RegisterProvider(UnknownUrlExceptionMapper.class)
@Path("/properties")
public interface SystemClient {
@GET
@Produces(MediaType.APPLICATION_JSON)
public Properties getProperties() throws
UnknownUrlException, ProcessingException;
}
io.openliberty.guides.inventory.client.SystemClient/mp-rest/url=http://localhost:9080/system
16
https://github.com/OpenLiberty/tutorial-microprofile
17
Handling 100s of Services
18
Eclipse MicroProfile
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
microprofile.io
19
MicroProfile OpenAPI
A B
openapi: 3.0.0
info:
title: Inventory App
description: App for storing JVM system properties of various
hosts.
license:
name: Eclipse Public License - v 1.0
url: https://www.eclipse.org/legal/epl-v10.html
version: "1.0"
servers: - url: http://localhost:{port} description: Simple Open
Liberty.
variables:
port:
description: Server HTTP port.
default: "9080"
paths:
/inventory/systems:
get:
summary: List inventory contents.
description: Returns the currently stored host:properties pairs
in the inventory.
operationId: listContents
responses:
200:
description: host:properties pairs stored in the inventory.
content:
application/json:
schema:
$ref: '#/components/schemas/InventoryList’
….
http://localhost:9080/openapi/ui
20
MicroProfile JWT
A B
@GET
@RolesAllowed({ "admin", "user" })
@Path("{hostname}")
@Produces(MediaType.APPLICATION_JSON)
public Response getPropertiesForHost(@PathParam("hostname") String hostname,
@Context HttpHeaders httpHeaders) {…}
21
MicroProfile Fault Tolerance
A B
@Fallback(fallbackMethod = "fallbackForGet")
public Properties get(String hostname) throws
IOException {
return invUtils.getProperties(hostname);
}
22
A
MicroProfile Config
B
@Inject
@ConfigProperty(name = ”customer_name")
private String customer;
config_ordinal=100
Customer_name=Bob
{
"config_ordinal":150,
”customer_name":Tom
}
23
https://github.com/OpenLiberty/tutorial-microprofile
24
Handling 100s of collaborating services requires a strong operations
focus
25
Eclipse MicroProfile
Health Check Metrics Open Tracing
microprofile.io
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
26
MicroProfile Health
A B
@Readiness
@ApplicationScoped
public class InventoryResource implements HealthCheck {
...
public boolean isHealthy() {...}
@Override
public HealthCheckResponse call() {
if (!isHealthy()) {
return
HealthCheckResponse.named(“ServiceHealthCheck”).withData(…).down().build();
}
return
HealthCheckResponse.named(“ServiceHealthCheck”).withData(…).up().build();
}
}
27
MicroProfile Metrics
A B
@Timed(name = "inventoryPropertiesRequestTime",
absolute = true,
description = "Time needed to get the properties of" +
"a system from the given hostname")
public Properties get(String hostname) {
return invUtils.getProperties(hostname);
}
28
MicroProfile OpenTracing
A B
@Traced(value = true, operationName = "InventoryManager.list")
public InventoryList list() {
return new InventoryList(systems);
}
JAX-RS methods are
automatically
traced by default
29
https://github.com/OpenLiberty/tutorial-microprofile
30
How to get started?
31
Microservice Deployment
microprofile.io
Kubernetes IstioDocker
Health CheckMetrics Open Tracing
JAX-RS JSON-PCDI
Config
Fault
Tolerance
JWT
Propagation
Open API
Rest Client JSON-B
32
Think Warszawa / September 17th, 2019 / © 2019 IBM Corporation 32
Containers
docker build -t ol-runtime --no-cache=true .
docker run -d --name rest-app -p 9080:9080 -p
9443:9443 -v <absolute path to
guide>/start/target/liberty/wlp/usr/servers:/servers ol-
runtime
33
Think Warszawa / September 17th, 2019 / © 2019 IBM Corporation 33
Kubernetes
34
Think Warszawa / September 17th, 2019 / © 2019 IBM Corporation 34
OpenShift
Build, ship and run any app, anywhere
Red Hat OpenShift is a leading hybrid
cloud, enterprise Kubernetes application
platform, trusted by 1000+ organizations.
35
MicroProfile Config with Kubernetes
A B
env:
- name: GREETING
valueFrom:
configMapKeyRef:
name: greeting-config
key: message
kubectl create configmap greeting-config --from-literal
message=Greetings...
@Inject
@ConfigProperty(name = "GREETING")
private String greeting;
36
MicroProfile Health with Kubernetes
A B
readinessProbe:
httpGet:
path: /health/ready
port: 9080
initialDelaySeconds: 15
periodSeconds: 5
failureThreshold: 1
Challenges
▸Security
▸Application roll out
▸A/B testing
▸Canary deployments
• Circuit breaking
• Rate limiting
• Observability
• Requires lot of coding
Service mesh
▸ A network of services, not just bytes
Observability
Resiliency
Traffic control
Security
Policy enforcement
Istio
A service mesh designed to connect, manage and secure micro
services
40
Istio
41
openliberty.io
42
Summary
• MicroProfile - Java APIs for cloud-native applications
o Produce and consume REST services
o Handle faults, security, configuration, APIs
o Monitor health, metrics and trace request flows
• Open Liberty - Java platform for cloud-native applications
o Open Source, Simple, Lightweight, Fast
o Supports latest MicroProfile and Java EE APIs
o Flexible package to suit your Microservices
43
Useful links
• https://github.com/OpenLiberty/tutorial-microprofile
• https://microprofile.io
• https://jakarta.ee/
• https://openliberty.io/
• https://github.com/openliberty/open-liberty
• http://groups.io/g/openliberty
• https://stackoverflow.com/questions/tagged/open-liberty
• http://www.eclipse.org/openj9/
• https://openliberty.io/guides/
• https://www.eclipse.org/community/eclipse_newsletter/2019/september/microprofile.php
4444
Thank You!
&
enjoy the lab!
https://github.com/OpenLiberty/tutorial-microprofile

Cloud nativemicroservices jax-london2020

  • 1.
    1 Cloud Native Microservicewith MicroProfile, Docker, Kubernetes, Istio and OpenShift Emily Jiang, Java Champion Senior Technical Staff Member, IBM Liberty Microservice Architect, Advocate Senior Lead in MicroProfile, IBM @emilyfhjiang
  • 2.
    2 Agenda • Introduction toMicroProfile • Introduction to Open Liberty • Introduction to the Lab • Summary • Time to code!
  • 3.
    3 Community Driven Lightweight, Iterative Processes Specs,APIs, TCKs NO Reference Implementation
  • 4.
    4 MicroProfile Community ● Overa dozen vendors and Java user groups ● Around 169 individual contributors and growing ● Around a dozen independent implementations
  • 5.
    5  Open specifications Wide vendor support  REST Client  OpenAPI support  Security  Fault Tolerance  Configuration  Metrics  Health  Open Tracing https://wiki.eclipse.org/MicroProfile/Implementation Quarkus
  • 6.
    6 6 MicroProfile 1.0 (Fall2016) JAX-RS 2.0 CDI 1.2 JSON-P 1.0 MicroProfile 1.1 (August 2017) microProfile-1.0 Config 1.0 MicroProfile 1.2 (Sept 2017) MicroProfile-1.1 Config 1.1 Fault Tolerance 1.0 Health 1.0 Metrics 1.0 JWT 1.0 2017 2018 MicroProfile 1.3 (Dec 2017) MicroProfile 1.2 Config 1.2 Metrics 1.1 OpenApi 1.0 OpenTracing 1.0 RestClient 1.0 MicroProfile 1.4 (June 2018) MicroProfile 1.3 Config 1.3 Fault Tolerance 1.1 JWT 1.1 Open Tracing-1.1 Rest Client-1.1 2019 MicroProfile 2.0.1 (July 2018) MicroProfile 1.4 JAX-RS 2.1 // Java EE 8 CDI 2.0 // Java EE 8 JSON-P 1.1 // Java EE 8 JSON-B 1.0 // Java EE 8 MicroProfile 2.1 (Oct 2018) MicroProfile 2.0 OpenTracing 1.2 MicroProfile 2.2 (Feb 2019) Fault Tolerance 2.0 OpenAPI 1.1 OpenTracing 1.3 Rest Client 1.2 MicroProfile 3.0 (June 2019) MicroProfile 2.1 Metrics 2.0 Health Check 2.0 Rest Client 1.3 MicroProfile 3.2 (Nov 2019) MicroProfile 3.0 Metrics 2.2 Health Check 2.1 2020 MicroProfile 3.3 (Feb 2020) MicroProfile 3.2 Config 1.4 Metrics 2.3 Fault Tolerance 2.1 Health 2.2 Rest Client 1.4
  • 7.
    7 Eclipse MicroProfile Health Metrics Fault Tolerance OpenAPI Config Open Tracing JWT JSON-BRest ClientJAX-RSCDI JSON-P LRA GraphQL Reactive Streams Operators Reactive Messaging Context Propagation earlyevolutionspecifications
  • 8.
  • 9.
  • 10.
    10 There’s a goodchance you’ll use REST APIs
  • 11.
    11 Eclipse MicroProfile JAX-RS JSON-PCDIRestClient JSON-B microprofile.io
  • 12.
    12 JAX-RS B @ApplicationPath("System") public class SystemApplicationextends Application {} @Path("properties") public class PropertiesResource { @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject getProperties() {…} }
  • 13.
    13 CDI BA public class InventoryManager{ @Inject private SystemClient systemClient; … }
  • 14.
    14 JSON-B & JSON-P AB ... @GET @Produces(MediaType.APPLICATION_JSON) public InventoryList listContents() { return manager.list(); } public class InventoryList { private List<SystemData> systems; public InventoryList(List<SystemData> systems) { this.systems = systems; } public List<SystemData> getSystems() { return systems; } public int getTotal() { return systems.size(); } }
  • 15.
    15 MicroProfile REST Client BA @Inject @RestClient privateSystemClient defaultRestClient; @Dependent @RegisterRestClient @RegisterProvider(UnknownUrlExceptionMapper.class) @Path("/properties") public interface SystemClient { @GET @Produces(MediaType.APPLICATION_JSON) public Properties getProperties() throws UnknownUrlException, ProcessingException; } io.openliberty.guides.inventory.client.SystemClient/mp-rest/url=http://localhost:9080/system
  • 16.
  • 17.
  • 18.
  • 19.
    19 MicroProfile OpenAPI A B openapi:3.0.0 info: title: Inventory App description: App for storing JVM system properties of various hosts. license: name: Eclipse Public License - v 1.0 url: https://www.eclipse.org/legal/epl-v10.html version: "1.0" servers: - url: http://localhost:{port} description: Simple Open Liberty. variables: port: description: Server HTTP port. default: "9080" paths: /inventory/systems: get: summary: List inventory contents. description: Returns the currently stored host:properties pairs in the inventory. operationId: listContents responses: 200: description: host:properties pairs stored in the inventory. content: application/json: schema: $ref: '#/components/schemas/InventoryList’ …. http://localhost:9080/openapi/ui
  • 20.
    20 MicroProfile JWT A B @GET @RolesAllowed({"admin", "user" }) @Path("{hostname}") @Produces(MediaType.APPLICATION_JSON) public Response getPropertiesForHost(@PathParam("hostname") String hostname, @Context HttpHeaders httpHeaders) {…}
  • 21.
    21 MicroProfile Fault Tolerance AB @Fallback(fallbackMethod = "fallbackForGet") public Properties get(String hostname) throws IOException { return invUtils.getProperties(hostname); }
  • 22.
    22 A MicroProfile Config B @Inject @ConfigProperty(name =”customer_name") private String customer; config_ordinal=100 Customer_name=Bob { "config_ordinal":150, ”customer_name":Tom }
  • 23.
  • 24.
    24 Handling 100s ofcollaborating services requires a strong operations focus
  • 25.
    25 Eclipse MicroProfile Health CheckMetrics Open Tracing microprofile.io JAX-RS JSON-PCDI Config Fault Tolerance JWT Propagation Open API Rest Client JSON-B
  • 26.
    26 MicroProfile Health A B @Readiness @ApplicationScoped publicclass InventoryResource implements HealthCheck { ... public boolean isHealthy() {...} @Override public HealthCheckResponse call() { if (!isHealthy()) { return HealthCheckResponse.named(“ServiceHealthCheck”).withData(…).down().build(); } return HealthCheckResponse.named(“ServiceHealthCheck”).withData(…).up().build(); } }
  • 27.
    27 MicroProfile Metrics A B @Timed(name= "inventoryPropertiesRequestTime", absolute = true, description = "Time needed to get the properties of" + "a system from the given hostname") public Properties get(String hostname) { return invUtils.getProperties(hostname); }
  • 28.
    28 MicroProfile OpenTracing A B @Traced(value= true, operationName = "InventoryManager.list") public InventoryList list() { return new InventoryList(systems); } JAX-RS methods are automatically traced by default
  • 29.
  • 30.
    30 How to getstarted?
  • 31.
    31 Microservice Deployment microprofile.io Kubernetes IstioDocker HealthCheckMetrics Open Tracing JAX-RS JSON-PCDI Config Fault Tolerance JWT Propagation Open API Rest Client JSON-B
  • 32.
    32 Think Warszawa /September 17th, 2019 / © 2019 IBM Corporation 32 Containers docker build -t ol-runtime --no-cache=true . docker run -d --name rest-app -p 9080:9080 -p 9443:9443 -v <absolute path to guide>/start/target/liberty/wlp/usr/servers:/servers ol- runtime
  • 33.
    33 Think Warszawa /September 17th, 2019 / © 2019 IBM Corporation 33 Kubernetes
  • 34.
    34 Think Warszawa /September 17th, 2019 / © 2019 IBM Corporation 34 OpenShift Build, ship and run any app, anywhere Red Hat OpenShift is a leading hybrid cloud, enterprise Kubernetes application platform, trusted by 1000+ organizations.
  • 35.
    35 MicroProfile Config withKubernetes A B env: - name: GREETING valueFrom: configMapKeyRef: name: greeting-config key: message kubectl create configmap greeting-config --from-literal message=Greetings... @Inject @ConfigProperty(name = "GREETING") private String greeting;
  • 36.
    36 MicroProfile Health withKubernetes A B readinessProbe: httpGet: path: /health/ready port: 9080 initialDelaySeconds: 15 periodSeconds: 5 failureThreshold: 1
  • 37.
    Challenges ▸Security ▸Application roll out ▸A/Btesting ▸Canary deployments • Circuit breaking • Rate limiting • Observability • Requires lot of coding
  • 38.
    Service mesh ▸ Anetwork of services, not just bytes Observability Resiliency Traffic control Security Policy enforcement
  • 39.
    Istio A service meshdesigned to connect, manage and secure micro services
  • 40.
  • 41.
  • 42.
    42 Summary • MicroProfile -Java APIs for cloud-native applications o Produce and consume REST services o Handle faults, security, configuration, APIs o Monitor health, metrics and trace request flows • Open Liberty - Java platform for cloud-native applications o Open Source, Simple, Lightweight, Fast o Supports latest MicroProfile and Java EE APIs o Flexible package to suit your Microservices
  • 43.
    43 Useful links • https://github.com/OpenLiberty/tutorial-microprofile •https://microprofile.io • https://jakarta.ee/ • https://openliberty.io/ • https://github.com/openliberty/open-liberty • http://groups.io/g/openliberty • https://stackoverflow.com/questions/tagged/open-liberty • http://www.eclipse.org/openj9/ • https://openliberty.io/guides/ • https://www.eclipse.org/community/eclipse_newsletter/2019/september/microprofile.php
  • 44.
    4444 Thank You! & enjoy thelab! https://github.com/OpenLiberty/tutorial-microprofile