SlideShare a Scribd company logo
1 of 28
Download to read offline
Service Mesh mit Istio und
MicroProfile
-
eine harmonische Kombination?
Michael Hofmann
Hofmann IT-Consulting
info@hofmann-itconsulting.de
https://hofmann-itconsulting.de
Service Mesh
„The term service mesh is used to describe the network of
microservices that make up such application and the
interactions between them.“ (istio.io)
Anzahl der Services steigt ...
Ohne Werkzeug lässt sich
Service Mesh (Big Ball of Mud)
nicht beherrschen!
Quelle: https://twitter.com/Werner/status/741673514567143424
(Werner Vogels, CTO Amazon)
Service Mesh Funktionen
●
Service Discovery
●
Load Balancing
●
Resilienz
●
Dynamic Routing (Blue/Green Deployments, Canary Releasing, Traffic
Shadowing)
●
Observability (Metrics, Tracing)
●
End-to-End Authentication, Access Control
●
Rate Limiting
Service Mesh womit?
Vergleich Istio und Linkerd: https://abhishek-tiwari.com/a-sidecar-for-your-service-mesh/
Istio
IBM (Amalgam8)
content-based routing
(extended)
service discovery
resilience
load balancing
Google (Istio)
content-based routing
rate limiting
ACLs
telemetry
Kubernetes integration
Lyft (Envoy)
proxy (sidecar)
Istio Architektur
Quelle: istio.io
Data Plane
Control Plane
What is Eclipse MicroProfile?
● Eclipse MicroProfile is an open-source community specification for Enterprise Java
microservices
● A community of individuals, organizations, and vendors collaborating within an open
source (Eclipse) project to bring microservices to the Enterprise Java community
7
Quelle: microprofile.io
Community - individuals, organizations, vendors
8
Quelle: microprofile.io
Current MicroProfile implementations
9
Quelle: microprofile.io
Eclipse MicroProfile 2.2 (Feb 2019)
10
MicroProfile 2.2
JAX-RS 2.1JSON-P 1.1CDI 2.0
Config 1.3
Fault
Tolerance 2.0
JWT
Propagation
1.1
Health
Check 1.0
Metrics 1.1
Open Tracing
1.3
Open API 1.1
= Updated
= No change from last release (MicroProfile 2.1)
= New
Rest Client
1.2
JSON-B 1.0
Quelle: microprofile.io
MicroProfile vs. Istio (Kubernetes)
Funktionalität MicroProfile Istio
Anwendungs-
Konfiguration
Kubernetes ConfigMap
Resilienz Timeout, Retry, CircuitBreaker,
Bulkhead, Fallback
Timeout, Retry, CircuitBreaker
(Bulkhead)
Request-Tracing (MicroProfile Rest Client)
Metrics
Health Checks
JWT + RBAC
Konfiguration: MicroProfile Config
Ziel: mehrere Stage-abhängige Werte von aussen
überschreiben
●
System Properties (400)
●
Environment Variables (300)
●
microprofile-config.properties
im Classpath (100)
abc.key=valueABC
xyz.key=123
@Inject
@ConfigProperty(name=“abc.key“)
private String abc;
@Inject
@ConfigProperty(name=“xyz.key“)
private Long xyz;
Konfiguration: K8S ConfigMap
apiVersion: v1
kind: Pod
metadata:
name: servicea-pod
spec:
containers:
- name: ...
envFrom:
- configMapRef:
name: servicea-config
restartPolicy: Never
/bin/sh -c env
abc_key=valueABC
xyz_key=123
kubectl create configmap servicea-config 
--from-file=servicea/config.properties apiVersion: v1
kind: ConfigMap
metadata:
name: servicea-config
namespace: default
data:
abc_key: valueABC
xyz_key: „123“
Konfiguration: Stolperstein
Namenskonflikt der Variablen
K8S Environment Variables:
"must be a C identifier
(matching regex [A-Za-z_][A-Za-z0-9_]*)"
bei MicroProfile: entsprechend Package-Konvention mit .
Seit MicroProfile Config 1.3:
Mapping von non-alphanumeric auf .
(Mapping-Reihenfolge: abc.key, abc_key, ABC_KEY)
Konfiguration: Reload
Environment-
Variablen können nur
bei Start des Pods
gesetzt werden!
Ausweg: K8S
ConfigMap als
Volume mounten
@Inject
@ConfigProperty(name="xyz.key", defaultValue="100")
private javax.inject.Provider<Long> xyz;
public interface ConfigSource {
Map<String, String> getProperties();
default Set<String> getPropertyNames(){...}
default int getOrdinal(){...}
String getValue(String propertyName);
String getName();
...
}
Timeout
Retry
CircuitBreaker
Bulkhead
Fallback
Resilienz
●
CircuitBreaker / Bulkhead (MicroProfile)
– Semaphor (synchron)
– Threadpool (asynchron)
●
CircuitBreaker im Sidecar wirkt wie Bulkhead
●
Fallback: fachlich motiviert Sidecar
Timeout
Retry
CircuitBreaker
Resilienz
●
CircuitBreaker = Bulkhead
●
Vorsicht: doppelte Ausführung
●
Nur Fallback aktivieren
apiVersion: v1
kind: ConfigMap
metadata:
name: res_off
data: MP_Fault_Tolerance_NonFallback_Enabled: "false"
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
name: reviews
spec:
host: reviews
subsets:
- name: v1
labels:
version: v1
trafficPolicy:
connectionPool:
http:
http1MaxPendingRequests: 2
tcp:
maxConnections: 5
Resilienz: wer die Wahl hat...
●
Frameworks (Hystrix (eol!), Resilience4J, Failsafe, MicroProfile Fault Tolerance)
ABER:
●
richtiges Pattern und Werte: erst in Produktion erkannt (neues Deployment!)
●
Abhängigkeit Bibliothek zur Programmiersprache
●
Versionsmix der Bibliotheken über alle Services hinweg
●
Abhängigkeiten zu anderen Frameworks (Service-Call → LoadBalancing → Service Registry)
●
Service Registry für andere Services verwendbar? Doppelte Service Registry? (hohe
Kopplung der Services an Infrastruktur-Komponenten!)
●
Lernkurve bzgl. vieler Frameworks bei jedem Entwickler-Team
Resilienz Fazit
●
Probleme der Infrastruktur sollten auch dort behoben werden!
●
Fallback-Schalter
●
Healthchecks durch Sidecar
auf Loadbalancing Pool
●
Istio Fault Injection:
Resilienz einfach testen
●
Globale Wirkung
Resilienz im Service Mesh!
apiVersion:networking.istio.io/
v1alpha3
kind: VirtualService
metadata:
name: ratings
...
spec:
hosts:
- ratings
http:
- fault:
delay:
fixedDelay: 7s
percent: 100
Tracing
●
Vom Sidecar oder Istio-Gateway erzeugt
●
Service schickt Header mit (MP OpenTracing)
●
Istio: Jaeger (OpenZipkin, LightStep)
●
Trace-Anzeige über alle beteiligte Komponenten
●
Datenmenge
– Reduktion: PILOT_TRACE_SAMPLING = "0.1"
– Tracing trotzdem erzwingen: Header x-envoy-force-trace = „true“
x-request-id
x-b3-traceid
x-b3-spanid
x-b3-parentspanid
x-b3-sampled
x-b3-flags
x-ot-span-context
MicroProfile Rest Client
●
Trace-Header von Client
– JAX-RS Client
– MicroProfile Rest Client erst seit Spec 1.2 (02/2019)
●
Namensproblem bei Config (geht, … nicht beschrieben in der
Spec!)
MicroProfile Rest Client
@RegisterRestClient
public interface MyClient {
@GET
@Path("/hallo")
public String hallo();
...
@ApplicationScoped
public class MyService {
@Inject
@RestClient
private MyClient client;
...
String txt = client.hallo();
de.company.remote.MyClient/mp-rest/uri=...
apiVersion: v1
kind: ConfigMap
metadata:
name: servicea-config
namespace: default
data:
de_company_remote_myclient_mp_rest_uri: ...
Health und Metrics
●
Service: MicroProfile Health
●
Service: MicroProfile Metrics
●
App-Server: Openliberty
●
Sidecar
●
Sammlung und Query
●
Graphische Anzeige
http://host/health
<feature>monitor-1.0</feature>
http://host/metrics/...
JWT und RBAC
●
Istio übernimmt mTLS transparent für Service
●
Istio und MicroProfile:
– JWT Prüfung
– RBAC
●
Mögliche Kombination:
– Istio: JWT Prüfung
– MicroProfile: RBAC und programmatic security
mTLS und JWT Prüfung
apiVersion:
"authentication.istio.io/v1alpha1"
kind: "MeshPolicy"
metadata:
name: "default"
spec:
peers:
- mtls: {}
apiVersion: "authentication.istio.io/v1alpha1"
kind: "Policy"
metadata:
name: "jwt-example"
spec:
targets: {}
origins:
- jwt:
issuer: "https://mysecurity.mycompany.de"
jwksUri: "https://mysecurity.mycompany.de/jwtkey"
principalBinding: USE_ORIGIN
RBAC + programmatic Security
@LoginConfig(authMethod = "MP-JWT",
realmName = "MY-REALM")
@ApplicationPath("/")
public class MyApplication extends Application {
}
@Path("/myendpoint")
@DenyAll
public class MyEndpoint {
@Inject
private JsonWebToken jwt;
@Resource
Principal principal;
...
}
Zusatznutzen von Istio/K8S
●
Service Discovery and load balancing im Sidecar (client-side)
●
Traffic Managment: Canary (z.B. 5%), Content Based Routing,
A/B Deployment, URL rewrite, Rate Limiting
●
mTLS
●
Fault Injection, Traffic Shadowing
●
Steuerung Tracing Output
Fazit
Funktionale Ergänzung
• Zusatznutzen durch Istio
• Tracing (Jaeger), Metrics (Prometheus), zusätzliche HealthChecks
Funktionale Überlappung
• Resilienz mit Schalter
• JWT und RBAC
Inkompatibles (behoben)
• Namenskonflikt bei Config
• Rest Client Tracing

More Related Content

Similar to Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?

Open icf (open identity connector framework) @ forgerock deutsch
Open icf (open identity connector framework) @ forgerock   deutschOpen icf (open identity connector framework) @ forgerock   deutsch
Open icf (open identity connector framework) @ forgerock deutschHanns Nolan
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederChristoph Pickl
 
Service Mesh - Kilometer 30 im Microservices-Marathon
Service Mesh - Kilometer 30 im Microservices-MarathonService Mesh - Kilometer 30 im Microservices-Marathon
Service Mesh - Kilometer 30 im Microservices-MarathonMichael Hofmann
 
.NET Summit 2016 München: EcmaScript 2015+ with TypeScript
.NET Summit 2016 München: EcmaScript 2015+ with TypeScript.NET Summit 2016 München: EcmaScript 2015+ with TypeScript
.NET Summit 2016 München: EcmaScript 2015+ with TypeScriptManfred Steyer
 
Praesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbasePraesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbaseStefan Frömken
 
Dataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesDataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesQAware GmbH
 
Apache camel
Apache camelApache camel
Apache camelgedoplan
 
Citrix Day 2013: Citirx Networking
Citrix Day 2013: Citirx NetworkingCitrix Day 2013: Citirx Networking
Citrix Day 2013: Citirx NetworkingDigicomp Academy AG
 
Steinzeit war gestern! Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Wege der Cloud-nativen Evolution.Steinzeit war gestern! Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Wege der Cloud-nativen Evolution.QAware GmbH
 
Microprofile-Anwendungen mit Quarkus - reloaded
Microprofile-Anwendungen mit Quarkus - reloadedMicroprofile-Anwendungen mit Quarkus - reloaded
Microprofile-Anwendungen mit Quarkus - reloadedgedoplan
 
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...GFU Cyrus AG
 
Einführung in Elasticsearch
Einführung in ElasticsearchEinführung in Elasticsearch
Einführung in ElasticsearchFlorian Hopf
 
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2dayElegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2dayMario-Leander Reimer
 
In-Memory Computing mit Apache Ignite und Kubernetes
In-Memory Computing mit Apache Ignite und KubernetesIn-Memory Computing mit Apache Ignite und Kubernetes
In-Memory Computing mit Apache Ignite und KubernetesQAware GmbH
 
DOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLDOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLFromDual GmbH
 
Lightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPALightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPAmh0708
 
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?Marc Müller
 
TYPO3 CMS 7.3 - Die Neuerungen - pluswerk
TYPO3 CMS 7.3 - Die Neuerungen - pluswerkTYPO3 CMS 7.3 - Die Neuerungen - pluswerk
TYPO3 CMS 7.3 - Die Neuerungen - pluswerkdie.agilen GmbH
 
OSMC 2012 | Performance graphing mit inGraph by Eric Lippmann
OSMC 2012 | Performance graphing mit inGraph by Eric LippmannOSMC 2012 | Performance graphing mit inGraph by Eric Lippmann
OSMC 2012 | Performance graphing mit inGraph by Eric LippmannNETWAYS
 

Similar to Service Mesh mit Istio und MicroProfile - eine harmonische Kombination? (20)

Open icf (open identity connector framework) @ forgerock deutsch
Open icf (open identity connector framework) @ forgerock   deutschOpen icf (open identity connector framework) @ forgerock   deutsch
Open icf (open identity connector framework) @ forgerock deutsch
 
JSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael GreifenederJSUG - OSGi by Michael Greifeneder
JSUG - OSGi by Michael Greifeneder
 
Service Mesh - Kilometer 30 im Microservices-Marathon
Service Mesh - Kilometer 30 im Microservices-MarathonService Mesh - Kilometer 30 im Microservices-Marathon
Service Mesh - Kilometer 30 im Microservices-Marathon
 
.NET Summit 2016 München: EcmaScript 2015+ with TypeScript
.NET Summit 2016 München: EcmaScript 2015+ with TypeScript.NET Summit 2016 München: EcmaScript 2015+ with TypeScript
.NET Summit 2016 München: EcmaScript 2015+ with TypeScript
 
Praesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit ExtbasePraesentation TYPO3Camp Berlin Speed mit Extbase
Praesentation TYPO3Camp Berlin Speed mit Extbase
 
Dataservices - Data Processing mit Microservices
Dataservices - Data Processing mit MicroservicesDataservices - Data Processing mit Microservices
Dataservices - Data Processing mit Microservices
 
Apache camel
Apache camelApache camel
Apache camel
 
Citrix Day 2013: Citirx Networking
Citrix Day 2013: Citirx NetworkingCitrix Day 2013: Citirx Networking
Citrix Day 2013: Citirx Networking
 
Steinzeit war gestern! Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Wege der Cloud-nativen Evolution.Steinzeit war gestern! Wege der Cloud-nativen Evolution.
Steinzeit war gestern! Wege der Cloud-nativen Evolution.
 
Microprofile-Anwendungen mit Quarkus - reloaded
Microprofile-Anwendungen mit Quarkus - reloadedMicroprofile-Anwendungen mit Quarkus - reloaded
Microprofile-Anwendungen mit Quarkus - reloaded
 
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...
Java Code Quality: Gute Software braucht guten Code - Regeln für verständlich...
 
Einführung in Elasticsearch
Einführung in ElasticsearchEinführung in Elasticsearch
Einführung in Elasticsearch
 
Integration camel
Integration camelIntegration camel
Integration camel
 
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2dayElegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
Elegantes In-Memory Computing mit Apache Ignite und Kubernetes. @data2day
 
In-Memory Computing mit Apache Ignite und Kubernetes
In-Memory Computing mit Apache Ignite und KubernetesIn-Memory Computing mit Apache Ignite und Kubernetes
In-Memory Computing mit Apache Ignite und Kubernetes
 
DOAG: NoSQL with MySQL
DOAG: NoSQL with MySQLDOAG: NoSQL with MySQL
DOAG: NoSQL with MySQL
 
Lightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPALightweight AOP with CDI and JPA
Lightweight AOP with CDI and JPA
 
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?
Karlsruher Entwicklertag 2016 - Monitoring 2.0: Alles im Lot?
 
TYPO3 CMS 7.3 - Die Neuerungen - pluswerk
TYPO3 CMS 7.3 - Die Neuerungen - pluswerkTYPO3 CMS 7.3 - Die Neuerungen - pluswerk
TYPO3 CMS 7.3 - Die Neuerungen - pluswerk
 
OSMC 2012 | Performance graphing mit inGraph by Eric Lippmann
OSMC 2012 | Performance graphing mit inGraph by Eric LippmannOSMC 2012 | Performance graphing mit inGraph by Eric Lippmann
OSMC 2012 | Performance graphing mit inGraph by Eric Lippmann
 

More from Michael Hofmann

Service Specific AuthZ In The Cloud Infrastructure
Service Specific AuthZ In The Cloud InfrastructureService Specific AuthZ In The Cloud Infrastructure
Service Specific AuthZ In The Cloud InfrastructureMichael Hofmann
 
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsNew Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsMichael Hofmann
 
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityDeveloper Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityMichael Hofmann
 
The Easy Way to Secure Microservices
The Easy Way to Secure MicroservicesThe Easy Way to Secure Microservices
The Easy Way to Secure MicroservicesMichael Hofmann
 
Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Michael Hofmann
 
Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Michael Hofmann
 
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...Michael Hofmann
 
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...Michael Hofmann
 
Service Mesh - kilometer 30 in a microservice marathon
Service Mesh - kilometer 30 in a microservice marathonService Mesh - kilometer 30 in a microservice marathon
Service Mesh - kilometer 30 in a microservice marathonMichael Hofmann
 
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderen
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderenAPI-Economy bei Financial Services – Kein Stein bleibt auf dem anderen
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderenMichael Hofmann
 
Microprofile.io - Cloud Native mit Java EE
Microprofile.io - Cloud Native mit Java EEMicroprofile.io - Cloud Native mit Java EE
Microprofile.io - Cloud Native mit Java EEMichael Hofmann
 
Microservices mit Java EE - am Beispiel von IBM Liberty
Microservices mit Java EE - am Beispiel von IBM LibertyMicroservices mit Java EE - am Beispiel von IBM Liberty
Microservices mit Java EE - am Beispiel von IBM LibertyMichael Hofmann
 

More from Michael Hofmann (12)

Service Specific AuthZ In The Cloud Infrastructure
Service Specific AuthZ In The Cloud InfrastructureService Specific AuthZ In The Cloud Infrastructure
Service Specific AuthZ In The Cloud Infrastructure
 
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud ApplicationsNew Ways To Production - Stress-Free Evolution Of Your Cloud Applications
New Ways To Production - Stress-Free Evolution Of Your Cloud Applications
 
Developer Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve ParityDeveloper Experience Cloud Native - Become Efficient and Achieve Parity
Developer Experience Cloud Native - Become Efficient and Achieve Parity
 
The Easy Way to Secure Microservices
The Easy Way to Secure MicroservicesThe Easy Way to Secure Microservices
The Easy Way to Secure Microservices
 
Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?
 
Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?Service Mesh vs. Frameworks: Where to put the resilience?
Service Mesh vs. Frameworks: Where to put the resilience?
 
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
Developer Experience Cloud Native - From Code Gen to Git Commit without a CI/...
 
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...
Servicierung von Monolithen - Der Weg zu neuen Technologien bis hin zum Servi...
 
Service Mesh - kilometer 30 in a microservice marathon
Service Mesh - kilometer 30 in a microservice marathonService Mesh - kilometer 30 in a microservice marathon
Service Mesh - kilometer 30 in a microservice marathon
 
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderen
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderenAPI-Economy bei Financial Services – Kein Stein bleibt auf dem anderen
API-Economy bei Financial Services – Kein Stein bleibt auf dem anderen
 
Microprofile.io - Cloud Native mit Java EE
Microprofile.io - Cloud Native mit Java EEMicroprofile.io - Cloud Native mit Java EE
Microprofile.io - Cloud Native mit Java EE
 
Microservices mit Java EE - am Beispiel von IBM Liberty
Microservices mit Java EE - am Beispiel von IBM LibertyMicroservices mit Java EE - am Beispiel von IBM Liberty
Microservices mit Java EE - am Beispiel von IBM Liberty
 

Service Mesh mit Istio und MicroProfile - eine harmonische Kombination?

  • 1. Service Mesh mit Istio und MicroProfile - eine harmonische Kombination? Michael Hofmann Hofmann IT-Consulting info@hofmann-itconsulting.de https://hofmann-itconsulting.de
  • 2. Service Mesh „The term service mesh is used to describe the network of microservices that make up such application and the interactions between them.“ (istio.io) Anzahl der Services steigt ... Ohne Werkzeug lässt sich Service Mesh (Big Ball of Mud) nicht beherrschen! Quelle: https://twitter.com/Werner/status/741673514567143424 (Werner Vogels, CTO Amazon)
  • 3. Service Mesh Funktionen ● Service Discovery ● Load Balancing ● Resilienz ● Dynamic Routing (Blue/Green Deployments, Canary Releasing, Traffic Shadowing) ● Observability (Metrics, Tracing) ● End-to-End Authentication, Access Control ● Rate Limiting
  • 4. Service Mesh womit? Vergleich Istio und Linkerd: https://abhishek-tiwari.com/a-sidecar-for-your-service-mesh/
  • 5. Istio IBM (Amalgam8) content-based routing (extended) service discovery resilience load balancing Google (Istio) content-based routing rate limiting ACLs telemetry Kubernetes integration Lyft (Envoy) proxy (sidecar)
  • 7. What is Eclipse MicroProfile? ● Eclipse MicroProfile is an open-source community specification for Enterprise Java microservices ● A community of individuals, organizations, and vendors collaborating within an open source (Eclipse) project to bring microservices to the Enterprise Java community 7 Quelle: microprofile.io
  • 8. Community - individuals, organizations, vendors 8 Quelle: microprofile.io
  • 10. Eclipse MicroProfile 2.2 (Feb 2019) 10 MicroProfile 2.2 JAX-RS 2.1JSON-P 1.1CDI 2.0 Config 1.3 Fault Tolerance 2.0 JWT Propagation 1.1 Health Check 1.0 Metrics 1.1 Open Tracing 1.3 Open API 1.1 = Updated = No change from last release (MicroProfile 2.1) = New Rest Client 1.2 JSON-B 1.0 Quelle: microprofile.io
  • 11. MicroProfile vs. Istio (Kubernetes) Funktionalität MicroProfile Istio Anwendungs- Konfiguration Kubernetes ConfigMap Resilienz Timeout, Retry, CircuitBreaker, Bulkhead, Fallback Timeout, Retry, CircuitBreaker (Bulkhead) Request-Tracing (MicroProfile Rest Client) Metrics Health Checks JWT + RBAC
  • 12. Konfiguration: MicroProfile Config Ziel: mehrere Stage-abhängige Werte von aussen überschreiben ● System Properties (400) ● Environment Variables (300) ● microprofile-config.properties im Classpath (100) abc.key=valueABC xyz.key=123 @Inject @ConfigProperty(name=“abc.key“) private String abc; @Inject @ConfigProperty(name=“xyz.key“) private Long xyz;
  • 13. Konfiguration: K8S ConfigMap apiVersion: v1 kind: Pod metadata: name: servicea-pod spec: containers: - name: ... envFrom: - configMapRef: name: servicea-config restartPolicy: Never /bin/sh -c env abc_key=valueABC xyz_key=123 kubectl create configmap servicea-config --from-file=servicea/config.properties apiVersion: v1 kind: ConfigMap metadata: name: servicea-config namespace: default data: abc_key: valueABC xyz_key: „123“
  • 14. Konfiguration: Stolperstein Namenskonflikt der Variablen K8S Environment Variables: "must be a C identifier (matching regex [A-Za-z_][A-Za-z0-9_]*)" bei MicroProfile: entsprechend Package-Konvention mit . Seit MicroProfile Config 1.3: Mapping von non-alphanumeric auf . (Mapping-Reihenfolge: abc.key, abc_key, ABC_KEY)
  • 15. Konfiguration: Reload Environment- Variablen können nur bei Start des Pods gesetzt werden! Ausweg: K8S ConfigMap als Volume mounten @Inject @ConfigProperty(name="xyz.key", defaultValue="100") private javax.inject.Provider<Long> xyz; public interface ConfigSource { Map<String, String> getProperties(); default Set<String> getPropertyNames(){...} default int getOrdinal(){...} String getValue(String propertyName); String getName(); ... }
  • 16. Timeout Retry CircuitBreaker Bulkhead Fallback Resilienz ● CircuitBreaker / Bulkhead (MicroProfile) – Semaphor (synchron) – Threadpool (asynchron) ● CircuitBreaker im Sidecar wirkt wie Bulkhead ● Fallback: fachlich motiviert Sidecar Timeout Retry CircuitBreaker
  • 17. Resilienz ● CircuitBreaker = Bulkhead ● Vorsicht: doppelte Ausführung ● Nur Fallback aktivieren apiVersion: v1 kind: ConfigMap metadata: name: res_off data: MP_Fault_Tolerance_NonFallback_Enabled: "false" apiVersion: networking.istio.io/v1alpha3 kind: DestinationRule metadata: name: reviews spec: host: reviews subsets: - name: v1 labels: version: v1 trafficPolicy: connectionPool: http: http1MaxPendingRequests: 2 tcp: maxConnections: 5
  • 18. Resilienz: wer die Wahl hat... ● Frameworks (Hystrix (eol!), Resilience4J, Failsafe, MicroProfile Fault Tolerance) ABER: ● richtiges Pattern und Werte: erst in Produktion erkannt (neues Deployment!) ● Abhängigkeit Bibliothek zur Programmiersprache ● Versionsmix der Bibliotheken über alle Services hinweg ● Abhängigkeiten zu anderen Frameworks (Service-Call → LoadBalancing → Service Registry) ● Service Registry für andere Services verwendbar? Doppelte Service Registry? (hohe Kopplung der Services an Infrastruktur-Komponenten!) ● Lernkurve bzgl. vieler Frameworks bei jedem Entwickler-Team
  • 19. Resilienz Fazit ● Probleme der Infrastruktur sollten auch dort behoben werden! ● Fallback-Schalter ● Healthchecks durch Sidecar auf Loadbalancing Pool ● Istio Fault Injection: Resilienz einfach testen ● Globale Wirkung Resilienz im Service Mesh! apiVersion:networking.istio.io/ v1alpha3 kind: VirtualService metadata: name: ratings ... spec: hosts: - ratings http: - fault: delay: fixedDelay: 7s percent: 100
  • 20. Tracing ● Vom Sidecar oder Istio-Gateway erzeugt ● Service schickt Header mit (MP OpenTracing) ● Istio: Jaeger (OpenZipkin, LightStep) ● Trace-Anzeige über alle beteiligte Komponenten ● Datenmenge – Reduktion: PILOT_TRACE_SAMPLING = "0.1" – Tracing trotzdem erzwingen: Header x-envoy-force-trace = „true“ x-request-id x-b3-traceid x-b3-spanid x-b3-parentspanid x-b3-sampled x-b3-flags x-ot-span-context
  • 21. MicroProfile Rest Client ● Trace-Header von Client – JAX-RS Client – MicroProfile Rest Client erst seit Spec 1.2 (02/2019) ● Namensproblem bei Config (geht, … nicht beschrieben in der Spec!)
  • 22. MicroProfile Rest Client @RegisterRestClient public interface MyClient { @GET @Path("/hallo") public String hallo(); ... @ApplicationScoped public class MyService { @Inject @RestClient private MyClient client; ... String txt = client.hallo(); de.company.remote.MyClient/mp-rest/uri=... apiVersion: v1 kind: ConfigMap metadata: name: servicea-config namespace: default data: de_company_remote_myclient_mp_rest_uri: ...
  • 23. Health und Metrics ● Service: MicroProfile Health ● Service: MicroProfile Metrics ● App-Server: Openliberty ● Sidecar ● Sammlung und Query ● Graphische Anzeige http://host/health <feature>monitor-1.0</feature> http://host/metrics/...
  • 24. JWT und RBAC ● Istio übernimmt mTLS transparent für Service ● Istio und MicroProfile: – JWT Prüfung – RBAC ● Mögliche Kombination: – Istio: JWT Prüfung – MicroProfile: RBAC und programmatic security
  • 25. mTLS und JWT Prüfung apiVersion: "authentication.istio.io/v1alpha1" kind: "MeshPolicy" metadata: name: "default" spec: peers: - mtls: {} apiVersion: "authentication.istio.io/v1alpha1" kind: "Policy" metadata: name: "jwt-example" spec: targets: {} origins: - jwt: issuer: "https://mysecurity.mycompany.de" jwksUri: "https://mysecurity.mycompany.de/jwtkey" principalBinding: USE_ORIGIN
  • 26. RBAC + programmatic Security @LoginConfig(authMethod = "MP-JWT", realmName = "MY-REALM") @ApplicationPath("/") public class MyApplication extends Application { } @Path("/myendpoint") @DenyAll public class MyEndpoint { @Inject private JsonWebToken jwt; @Resource Principal principal; ... }
  • 27. Zusatznutzen von Istio/K8S ● Service Discovery and load balancing im Sidecar (client-side) ● Traffic Managment: Canary (z.B. 5%), Content Based Routing, A/B Deployment, URL rewrite, Rate Limiting ● mTLS ● Fault Injection, Traffic Shadowing ● Steuerung Tracing Output
  • 28. Fazit Funktionale Ergänzung • Zusatznutzen durch Istio • Tracing (Jaeger), Metrics (Prometheus), zusätzliche HealthChecks Funktionale Überlappung • Resilienz mit Schalter • JWT und RBAC Inkompatibles (behoben) • Namenskonflikt bei Config • Rest Client Tracing