Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

New and smart way to develop microservice for istio with micro profile

106 views

Published on

The new and smart way to develop microservices for Istio - Eclipse MicroProfile
Focus on MicroProfile and demonstrate 8 MicroProfile specifications with some overview on Istio

Published in: Internet
  • Be the first to comment

  • Be the first to like this

New and smart way to develop microservice for istio with micro profile

  1. 1. 1 The new smart way to develop Microservices for Istio - Eclipse MicroProfile Emily Jiang, Java Champion, Liberty Architect for MicroProfile and CDI @IBM @emilyfhjiang
  2. 2. 2 Agile & DevOps & Cloud & Microservices + + + serviceC serviceB serviceA
  3. 3. 3 Microservices spiderweb
  4. 4. 4 Orchestrator connect, manage and secure your microservices
  5. 5. 5 Service Mesh A network for services, not bytes ● Observability ● Resiliency ● Traffic Control ● Security ● Policy Enforcement
  6. 6. 6 Istio A service mesh designed to connect, manage and secure your microservices
  7. 7. 7 Istio Architecture
  8. 8. 8 cloud-native microservice 1. RESTful – like cattle not pet, communicative 2. Configurable 3. Fault tolerance 4. Can be discovered 5. Secure 6. Traceable, monitorable 7. Able to communicate with the cloud infrastructure
  9. 9. 9 How to develop cloud-native microservice for Istio?
  10. 10. 10 Community Driven Lightweight, Iterative Processes Specs, APIs, TCKs NO Reference Implementation
  11. 11. 11 Open specifications Wide vendor support REST services OpenAPI support Security Fault Tolerance Configuration Metrics Health Open Tracing https://wiki.eclipse.org/MicroProfile/Implementation Quarkus
  12. 12. 12 openliberty.io Jan Dec 19.0.0.2 19.0.0.1 19.0.0.3 4-week release cadence
  13. 13. 13 13 MicroProfile 1.0 (Fall 2016) jaxrs-2.0 cdi-1.2 jsonp-1.0 MicroProfile 1.1 (August 2017) microProfile-1.0 mpConfig-1.0 MicroProfile 1.2 (Sept 2017) microProfile-1.1 mpConfig-1.1 mpFaultTolerance-1.0 mpHealth-1.0 mpMetrics-1.0 mpJwt-1.0 2017 2018 MicroProfile 1.3 (Dec 2017) MicroProfile 1.2 mpConfig-1.2 mpMetrics-1.1 mpOpenApi-1.0 mpOpenTracing-1.0 mpRestClient-1.0 MicroProfile 1.4 (June 2018) MicroProfile 1.3 mpConfig-1.3 mpFaultTolerance-1.1 mpJwt-1.1 mpOpenTracing-1.1 mpRestClient-1.1 2019 MicroProfile 2.0.1 (July 2018) MicroProfile 1.4 jaxrs-2.1 // Java EE 8 cdi-2.0 // Java EE 8 jsonp-1.1 // Java EE 8 jsonb-1.0 // Java EE 8 MicroProfile 2.1 (Oct 2018) MicroProfile 2.0 mpOpenTracing-1.2 MicroProfile 2.2 (Feb 2019) Fault Tolerance 2.0 OpenAPI 1.1 OpenTracing 1.3 Rest Client 1.2
  14. 14. 14 There’s a good chance you’ll use REST APIs
  15. 15. 15 Eclipse MicroProfile JAX-RS JSON-PCDIRest Client JSON-B microprofile.io
  16. 16. 16 JAX-RS B @ApplicationPath("System") public class SystemApplication extends Application {} @Path("properties") public class PropertiesResource { @GET @Produces(MediaType.APPLICATION_JSON) public JsonObject getProperties() {…} }
  17. 17. 17 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
  18. 18. 18 CDI BA public class InventoryManager { @Inject private SystemClient systemClient; … }
  19. 19. 19 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(); } }
  20. 20. 20 Handling 100s of Services
  21. 21. 21 Eclipse MicroProfile JAX-RS JSON-PCDI Config Fault Tolerance JWT Propagation Open API Rest Client JSON-B microprofile.io
  22. 22. 22 Where were we...? A B
  23. 23. 23 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 @Operation( summary = "List inventory contents.", description = "Returns the stored host:properties pairs.")
  24. 24. 24 MicroProfile JWT A B @GET @RolesAllowed({ "admin", "user" }) @Path("{hostname}") @Produces(MediaType.APPLICATION_JSON) public Response getPropertiesForHost(@PathParam("hostname") String hostname, @Context HttpHeaders httpHeaders) {…}
  25. 25. 25 MicroProfile Fault Tolerance A B @Fallback(fallbackMethod = "fallbackForGet") public Properties get(String hostname) throws IOException { return invUtils.getProperties(hostname); }
  26. 26. 26 A MicroProfile Config B @Inject @ConfigProperty(name = "io_openliberty_guides_inventory_inMaintenance") private Provider<Boolean> inMaintenance; config_ordinal=100 io_openliberty_guides_inventory_inMaintenance=false { "config_ordinal":150, "io_openliberty_guides_inventory_inMaintenance":true }
  27. 27. 27 Handling 100s of collaborating services requires a strong operations focus
  28. 28. 28 Eclipse MicroProfile Health Check Metrics Open Tracing microprofile.io JAX-RS JSON-PCDI Config Fault Tolerance JWT Propagation Open API Rest Client JSON-B
  29. 29. 29 Where were we...? A B
  30. 30. 30 MicroProfile Health A B @Health @ApplicationScoped public class InventoryResource implements HealthCheck { ... public boolean isHealthy() {...} @Override public HealthCheckResponse call() { if (!isHealthy()) { return HealthCheckResponse.named(“InventoryResource”).withData(…).down().build(); } return HealthCheckResponse.named(“InventoryResource”).withData(…).up().build(); } }
  31. 31. 31 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); }
  32. 32. 32 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
  33. 33. 33 Eclipse MicroProfile  Open specifications  Wide vendor support  REST services  OpenAPI support  Security  Fault Tolerance  Configuration  Metrics  Health  Open Tracing
  34. 34. 34 How to get started?
  35. 35. 35 Into the cloud
  36. 36. 36 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
  37. 37. 37 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;
  38. 38. 38 MicroProfile Health with Kubernetes A B readinessProbe: httpGet: path: /health port: 9080 initialDelaySeconds: 15 periodSeconds: 5 failureThreshold: 1
  39. 39. 39 MicroProfile Open Tracing 7 http headers required by Istio propagated All JAX-RS requests traced
  40. 40. 40 Istio & MicroProfile - Putting it all together
  41. 41. 41 Useful Links • https://microprofile.io • https://openliberty.io/guides • https://docs.docker.com/get-started/ • https://kubernetes.io/docs/tutorials/kubernetes-basics/ • https://istio.io/docs/setup/kubernetes/quick-start/ • https://github.com/eclipse/microprofile-service-mesh • https://www.eclipse.org/community/eclipse_newsletter/2018/septemb er/MicroProfile_istio.php
  42. 42. 4242 Thank you!

×