Slide 1

Slide 1 text

No content

Slide 2

Slide 2 text

Service Mesh - Ein kritischer Blick auf die neue Infrastruktur für Microservices 2 7. 0 5 . 2 0 2 0 I N N O Q Te c h n o l o g y L u n c h 2 Hanna Prinz

Slide 3

Slide 3 text

Technology Lunch. Aha. @INNOQ @HannaPrinz

Slide 4

Slide 4 text

Monolith Microservices @INNOQ @HannaPrinz

Slide 5

Slide 5 text

Microservices @INNOQ @HannaPrinz

Slide 6

Slide 6 text

Timeout Circuit Breaking Verschlüsselung Retry Metriken erzeugen & bereitstellen Entschlüsselung Autorisierung prüfen Routing @INNOQ @HannaPrinz

Slide 7

Slide 7 text

Service Mesh Metriken Konfiguration Retry Timeout Circuit Breaker Routing Verschlüsseln Entschlüsseln Autorisierung Metriken ... } @INNOQ @HannaPrinz

Slide 8

Slide 8 text

Microservices mit Service Mesh Service Mesh Evolution Monolith Microservices Theorie Microservices Praxis @INNOQ @HannaPrinz

Slide 9

Slide 9 text

Infrastruktur-Service Y Service Mesh Architektur Microservice 1 Microservice 2 Proxy Proxy Control Plane App Infrastruktur-Service X Anwendung Data Plane Control Plane Infrastruktur @INNOQ @HannaPrinz

Slide 10

Slide 10 text

Hurra, Technologie! @INNOQ @HannaPrinz

Slide 11

Slide 11 text

Service Mesh Features Observability Resilience Routing Security @INNOQ @HannaPrinz

Slide 12

Slide 12 text

Monitoring Ein Service Mesh kann automatisch alle 4 "Golden Signals" liefern: Latenz Requests/Sekunde Status Codes (Fehler) Auslastung ... es hat aber keinen Einblick in die Microservices https://landing.google.com/sre/sre-book/chapters/monitoring-distributed-systems/#xref_monitoring_golden-signals @INNOQ @HannaPrinz

Slide 13

Slide 13 text

Monitoring mit Service Mesh Metriken zum Netzwerkverkehr generieren -> Latenz / Antwortzeit -> HTTP Status Codes -> Anfragen pro Sekunde ... einem Monitoring-System zur Verfügung stellen ... und mit Dashboards aufbereiten @INNOQ @HannaPrinz

Slide 14

Slide 14 text

Service Mesh Features Observability Resilience Routing Security @INNOQ @HannaPrinz

Slide 15

Slide 15 text

Routing Typischerweise im Edge Router / API-Gateway implementiert z.B. NGINX, Envoy, Ambassador, Traefik Instance A Instance B Load Balancing Instance A Instance B Pfad-basiertes Routing /a /b Instance A Instance B Blue/Green Deployment Instance A Instance B A/B-Testing 50% 50% Instance A Instance B Canary Releasing Berlin Welt 15 @INNOQ @HannaPrinz

Slide 16

Slide 16 text

Routing mit Service Mesh Microservice 1 Microservice 2 Proxy Proxy Control Plane App Anwendung Data Plane Control Plane Routing- Regeln 16 @INNOQ @HannaPrinz

Slide 17

Slide 17 text

Routing mit Service Mesh GET /neu GET / 90% 10% Service 1 Service 2A Proxy Proxy Service 2B Proxy Komplexe Routing-Regeln für A/B Testing und Canary Releasing Service 1 Service 2 Proxy Proxy Service 2 Proxy PRODUKTION STAGING Traffic Mirroring locality=mars locality=* 17 @INNOQ @HannaPrinz

Slide 18

Slide 18 text

Service Mesh Features Observability Resilience Routing Security @INNOQ @HannaPrinz

Slide 19

Slide 19 text

Resilience Was wenn ein Service nicht wie erwartet zur Verfügung steht? Ziel: Gesamtsystem funktioniert weiter ... ggf. mit Einschränkungen Maßnahmen: Retry, Timeout, Circuit Breaking 19 500 @INNOQ @HannaPrinz

Slide 20

Slide 20 text

Resilience mit Service Mesh Microservice 1 Microservice 2 Proxy Proxy Control Plane App Anwendung Data Plane Control Plane Resilienz- Regeln 20 @INNOQ @HannaPrinz

Slide 21

Slide 21 text

Resilience mit Service Mesh Fault Injection Delay Injection Service 1 Service 2 Proxy Proxy Timeout Retry Service 1 Service 2 Proxy Proxy 4s 502 21 @INNOQ @HannaPrinz

Slide 22

Slide 22 text

Service Mesh Features Observability Resilience Routing Security @INNOQ @HannaPrinz

Slide 23

Slide 23 text

Security mit Service Mesh Microservice 1 Microservice 2 Proxy Proxy Anwendung Data Plane Control Plane Control Plane App Autorisierungs- Regeln TLS-Zertifikat 23 @INNOQ @HannaPrinz

Slide 24

Slide 24 text

Security mit Service Mesh Service 1 Service 2 Proxy Proxy Authentifizierung mit mTLS Autorisierung Service 1 Service 2 Proxy Proxy GET /api GET / Autorisierungs-Regel TLS-Zertifikat 24 @INNOQ @HannaPrinz "Service 1"

Slide 25

Slide 25 text

Service Mesh Features Netzwerk-Metriken und Access Logs Tracing-Daten an Backend senden Automatische Timeouts & Retrys Automatisches Circuit Breaking Business-Metriken oder -Logs Weitergabe von Tracing-Headern Alerting Cache oder Standardantworten in Circuit Breaker nutzen Automatisches Canary Releasing Authentifizierung mit mTLS Autorisierung Komplexe Routing-Regeln Canary Releasing & A/B-Testing Observability Resilience Routing Security @INNOQ @HannaPrinz

Slide 26

Slide 26 text

Service Mesh Menu @INNOQ @HannaPrinz

Slide 27

Slide 27 text

Service Mesh Implementierungen Istio @INNOQ @HannaPrinz

Slide 28

Slide 28 text

28 @INNOQ @HannaPrinz

Slide 29

Slide 29 text

Istio VS Linkerd 2 *2017 von Google & IBM optimiert auf Featureanzahl und Konfigurierbarkeit optimiert für Kubernetes, aber nicht exklusiv *2017 von Buoyant optimiert auf Usability und Performance Kubernetes only @INNOQ @HannaPrinz

Slide 30

Slide 30 text

Features Istio 1.6 Linkerd 2.7 Generell Plattform Kubernetes Kubernetes Automatische Sidecar-Injektion ✓ ✓ Sicherheit Authentifizierung via mTLS HTTP & TCP HTTP Autorisierung ✓ ✘ Resilienz Timeouts & Retrys ✓ ✓ Circuit Breaker ✓ ✘ Routing Load Balancing ✓ ✓ Routing-Regeln ✓ ✓ Monitoring Metriken ✓ ✓ Tracing ✓ (✓) Dashboard mit Service Graph ✓ ✓ @INNOQ @HannaPrinz

Slide 31

Slide 31 text

Schöne Tabelle. @INNOQ @HannaPrinz

Slide 32

Slide 32 text

@INNOQ @HannaPrinz Istio VS Linkerd 2 Konfiguration im Vergleich

Slide 33

Slide 33 text

Monitoring Infrastruktur Microservice 1 Microservice 2 @INNOQ @HannaPrinz Microservice 1 Microservice 2 Grafana Prometheus Grafana Prometheus Istio Linkerd 2 Envoy Proxy Envoy Proxy Istiod Linkerd Proxy Linkerd Proxy Linkerd Kiali Linkerd Dashboard

Slide 34

Slide 34 text

Demo @INNOQ @HannaPrinz

Slide 35

Slide 35 text

@INNOQ @HannaPrinz

Slide 36

Slide 36 text

@INNOQ @HannaPrinz

Slide 37

Slide 37 text

Service A Service B Service A GET /users POST /order GET /invoice/42 11ms Service B 4ms 17ms 2ms Monitoring pro Service VS pro Endpunkt @INNOQ @HannaPrinz

Slide 38

Slide 38 text

Endpoint- Config mit apiVersion: linkerd.io/v1alpha1 kind: ServiceProfile metadata: name: service-b.default.svc.cluster.local namespace: default spec: routes: - name: GET /users condition: method: GET pathRegex: /users - name: POST /order condition: method: POST pathRegex: /order Service A GET /users POST /order GET /invoice/42 Service B 4ms 17ms 2ms @INNOQ @HannaPrinz Linkerd 2 Path- & Method-based

Slide 39

Slide 39 text

Endpoint- Config mit apiVersion: linkerd.io/v1alpha1 kind: ServiceProfile metadata: name: service-b.default.svc.cluster.local namespace: default spec: routes: - name: GET /users condition: method: GET pathRegex: /users - name: POST /order condition: method: POST pathRegex: /order - name: GET /invoice/{id} condition: method: GET pathRegex: /invoice/[^/]* Service A GET /users POST /order GET /invoice/42 Service B 4ms 17ms 2ms @INNOQ @HannaPrinz Linkerd 2 Regex für Path Params

Slide 40

Slide 40 text

Endpoint- Config mit apiVersion: linkerd.io/v1alpha1 kind: ServiceProfile metadata: name: service-b.default.svc.cluster.local namespace: default spec: routes: - name: GET /users condition: method: GET pathRegex: /users isRetryable: true - name: POST /order condition: method: POST pathRegex: /order isRetryable: false - name: GET /invoice/{id} condition: method: GET pathRegex: /invoice/[^/]* isRetryable: true Service A GET /users POST /order GET /invoice/42 Service B 4ms 17ms 2ms @INNOQ @HannaPrinz Linkerd 2 + Retry

Slide 41

Slide 41 text

Endpoint- Config mit apiVersion: linkerd.io/v1alpha1 kind: ServiceProfile metadata: name: service-b.default.svc.cluster.local namespace: default spec: routes: - name: GET /users condition: method: GET pathRegex: /users isRetryable: true timeout: 300ms - name: POST /order condition: method: POST pathRegex: /order isRetryable: false - name: GET /invoice/{id} condition: method: GET pathRegex: /invoice/[^/]* isRetryable: true Service A GET /users POST /order GET /invoice/42 Service B 4ms 17ms 2ms @INNOQ @HannaPrinz Linkerd 2 + Timeout

Slide 42

Slide 42 text

Endpoint- Metriken mit apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: istio-attributegen-filter spec: workloadSelector: labels: app: reviews configPatches: - applyTo: HTTP_FILTER match: context: SIDECAR_INBOUND proxy: proxyVersion: '1\.6.*' listener: filterChain: filter: name: "envoy.http_connection_manager" subFilter: name: "istio.stats" patch: operation: INSERT_BEFORE value: name: istio.attributegen typed_config: "@type": type.googleapis.com/udpa.type.v1.TypedStruct type_url: type.googleapis.com/envoy.extensions.filters.http.wasm.v3.Wasm value: config: configuration: | { "attributes": [ { "output_attribute": "istio_operationId", "match": [ { "value": "GET /users", "condition": "request.url_path == '/users' && request.method == 'GET'" }, { "value": "POST /order", "condition": "request.url_path == '/order' && request.method == 'POST'" }, { "value": "GET /invoice/{id}", "condition": "request.url_path.matches('^/invoice/[[:alnum:]]*$') && request.method == 'GET'" } ] } ] } vm_config: runtime: envoy.wasm.runtime.null code: local: { inline_string: "envoy.wasm.attributegen" } Service A GET /users POST /order GET /invoice/42 Service B 4ms 17ms 2ms @INNOQ @HannaPrinz Istio Experimentell in Version 1.6

Slide 43

Slide 43 text

43 Usability @INNOQ @HannaPrinz

Slide 44

Slide 44 text

44 Performance & Ressourcen •Latenz - stark abhängig vom Traffic •Istio: zusätzlich ca. 3ms Latenz - pro Aufruf zwischen Services! •Linkerd 2: keine aktuellen Zahlen, in früheren Versionen ähnlich •Ressourcen •Zusätzliche Container für Control Plane & jedes Sidecar •→ Erhöhter CPU- & Arbeitsspeicher-Verbrauch Aber: Abhängig von konkretem Setting → eigenen Benchmark machen! @INNOQ @HannaPrinz

Slide 45

Slide 45 text

TL;DR @INNOQ @HannaPrinz

Slide 46

Slide 46 text

Service Mesh Löst viele wesentliche Probleme von Microservices + Eine weitere komplexe Technologie – ... ohne Codeänderungen! Latenz- und Ressourcen- Overhead 46 @INNOQ @HannaPrinz

Slide 47

Slide 47 text

Entscheidungshilfe Service Mesh Indikatoren Kriterien für die Auswahl • Viele Microservices, viele synchrone Aufrufe • Viele ungelöste Probleme beim Monitoring, Routing, Resilienz und/oder Security • Großteil läuft in Kubernetes • Welche Features fehlen wirklich? • Vorhandene Infrastruktur - Kubernetes, Consul, AWS, ... • Zeitliche und kognitive Kapazität im Team • Aktivität der Community @INNOQ @HannaPrinz Ziel: So viel Komplexität wie nötig, aber so wenig wie möglich

Slide 48

Slide 48 text

Komplexität? Ehem... @INNOQ @HannaPrinz

Slide 49

Slide 49 text

Monolith Microservices @INNOQ @HannaPrinz

Slide 50

Slide 50 text

"don't distribute your objects." ☝ https://martinfowler.com/articles/distributed-objects-microservices.html Martin Fowler @INNOQ @HannaPrinz

Slide 51

Slide 51 text

Alternativen? @INNOQ @HannaPrinz https://www.infoq.com/articles/architecture-trends-2020/

Slide 52

Slide 52 text

Try not to need a Service Mesh

Slide 53

Slide 53 text

Mehr zum Thema • Service Mesh Vergleich auf servicemesh.es https://servicemesh.es/ • Artikel: Glücklich ohne Service Mesh https://www.innoq.com/de/blog/gluecklich-ohne-service-mesh/ • Artikel: Brauchen asynchrone Microservices und Self-Contained-Systems ein Service Mesh? https://www.innoq.com/de/articles/2020/02/service-mesh-asynchrone-microservices-scs/ • Artikel: Alle 11 Minuten verliebt sich ein Microservice in Linkerd https://www.innoq.com/en/articles/2020/01/linkerd2/ • Podcast zu Service Meshes https://www.innoq.com/de/podcast/059-service-meshes-1/ • Beispiel-Anwendung auf GitHub https://github.com/ewolff/microservice-istio • Tutorial von Linkerd https://linkerd.io/2/tasks/ • Tutorial von Istio https://istio.io/docs/setup/getting-started/ @INNOQ @HannaPrinz

Slide 54

Slide 54 text

Krischerstr. 100 40789 Monheim am Rhein Germany +49 2173 3366-0 Ohlauer Str. 43 10999 Berlin Germany +49 2173 3366-0 Ludwigstr. 180E 63067 Offenbach Germany +49 2173 3366-0 Kreuzstr. 16 80331 München Germany +49 2173 3366-0 Hermannstrasse 13 20095 Hamburg Germany +49 2173 3366-0 Gewerbestr. 11 CH-6330 Cham Switzerland +41 41 743 0116 innoQ Deutschland GmbH innoQ Schweiz GmbH www.innoq.com Danke! Fragen? Hanna Prinz [email protected] @HannaPrinz Icons made by srip, Smashicons, Nikita Golubev, Freepik, surang and Darius Dan from www.flaticon.com and licensed by CC 3.0 BY Service Mesh Primer - 2nd Edition Kostenlos auf leanpub.com/service-mesh-primer