Slide 1

Slide 1 text

Service Mesh - was die neue Infrastruktur für Microservices taugt 1 Hanna Prinz @HannaPrinz Microservices Meetup Hamburg

Slide 2

Slide 2 text

Hanna Prinz Consultant innoQ Deutschland GmbH [email protected] @HannaPrinz - Software Development - DevOps, Kubernetes, Service Mesh

Slide 3

Slide 3 text

~ Fix your Microservices by throwing a Mesh at it! ~

Slide 4

Slide 4 text

Wie ist es dazu gekommen? @INNOQ @HannaPrinz

Slide 5

Slide 5 text

Monolith Microservices @INNOQ @HannaPrinz

Slide 6

Slide 6 text

Microservices @INNOQ @HannaPrinz

Slide 7

Slide 7 text

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

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

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

Slide 10

Slide 10 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 11

Slide 11 text

Hurra, Technologie! @INNOQ @HannaPrinz

Slide 12

Slide 12 text

12 ‣ Was ist ein Service Mesh? ‣ Service Mesh Features ‣ Kosten eines Service Mesh ‣ Istio Demo ‣ Service Mesh Implementierungen ‣ Wann man ein Service Mesh (nicht) braucht Agenda

Slide 13

Slide 13 text

Service Mesh Features @INNOQ @HannaPrinz Observability Resilience Routing Security

Slide 14

Slide 14 text

Monitoring Ein Service Mesh kann automatisch "Golden Signals" liefern: Latenz Requests/Sekunde Status Codes (Fehler) Auslastung (durch Kubernetes) ... 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 15

Slide 15 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 16

Slide 16 text

Tracing •Beantwortet... •Welcher Aufruf erzeugt welchen Folgeaufruf? •Welchen Anteil hat jeder Teilaufruf an der Latenz? •Wo ist ein Fehler entstanden? •Umsetzung: Tracing- Backend B C A 3s Latenz #42 #42 #42 Trace von Aufruf #42 A B C 16 @INNOQ @HannaPrinz

Slide 17

Slide 17 text

Tracing mit Service Mesh Tracing-Header an ausgehende Anfragen kopieren Tracing-Daten an ein Tracing-Backend senden Tracing-Daten in Dashboard aufbereiten 17 @INNOQ @HannaPrinz

Slide 18

Slide 18 text

Service Mesh Features @INNOQ @HannaPrinz Observability Resilience Routing Security

Slide 19

Slide 19 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 @INNOQ @HannaPrinz

Slide 20

Slide 20 text

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

Slide 21

Slide 21 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=* @INNOQ @HannaPrinz

Slide 22

Slide 22 text

Service Mesh Features @INNOQ @HannaPrinz Observability Resilience Routing Security

Slide 23

Slide 23 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 500 @INNOQ @HannaPrinz

Slide 24

Slide 24 text

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

Slide 25

Slide 25 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 @INNOQ @HannaPrinz

Slide 26

Slide 26 text

Service Mesh Features @INNOQ @HannaPrinz Observability Resilience Routing Security

Slide 27

Slide 27 text

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

Slide 28

Slide 28 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 "Service 1" @INNOQ @HannaPrinz

Slide 29

Slide 29 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 30

Slide 30 text

Zu welchen Kosten? @INNOQ @HannaPrinz

Slide 31

Slide 31 text

Lernkurve Docker, Kubernetes (bzw. AWS oder Consul) mTLS , Monitoring/Tracing (z.B. Prometheus) Service Mesh Funktionsweise & Konfigurationsmodell @INNOQ @HannaPrinz

Slide 32

Slide 32 text

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.wa value: config: configuration: | { "attributes": [ { "output_attribute": "istio_operationId", "match": [ { "value": "GET /users", "condition": "request.url_path == '/users' && }, { "value": "POST /order", "condition": "request.url_path == '/order' && }, { "value": "GET /invoice/{id}", "condition": "request.url_path.matches('^/invo && request.method == 'GET'" } ] } ] } vm_config: runtime: envoy.wasm.runtime.null code: local: { inline_string: "envoy.wasm.attributegen" } Service Mesh Magie basiert auf einem Haufen YAML 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.was value: config: configuration: | { "attributes": [ { "output_attribute": "istio_operationId", "match": [ { "value": "GET /users", "condition": "request.url_path == '/users' && r }, { "value": "POST /order", "condition": "request.url_path == '/order' && r }, { "value": "GET /invoice/{id}", "condition": "request.url_path.matches('^/invoi && request.method == 'GET'" } ] } ] } vm_config: runtime: envoy.wasm.runtime.null code: local: { inline_string: "envoy.wasm.attributegen" }

Slide 33

Slide 33 text

Lernkurve Docker, Kubernetes (bzw. AWS oder Consul) PKI , Monitoring/Tracing (z.B. Prometheus) Service Mesh Funktionsweise & Konfigurationsmodell Einfluss des Service Mesh auf Applikations-Architektur Betriebserfahrungen sammeln Updates, Debugging, Customization @INNOQ @HannaPrinz

Slide 34

Slide 34 text

Latenz zur Laufzeit •Zusätzliche ~3ms Latenz* für jede Anfrage zwischen Services! •Abhängig von der Service Mesh Implementierung & der Kommunikation zwischen den Services Stark abhängig vom Projekt → eigener Benchmark empfehlenswert! *https://istio.io/latest/docs/ops/deployment/performance-and-scalability/ @INNOQ @HannaPrinz

Slide 35

Slide 35 text

Ressourcenverbrauch zur Laufzeit •Zusätzliche Containers für Control Plane & Sidecars •→ erhöhter Verbrauch von CPU & Memory •Ressourcenverbrauch hängt ab von •... der Service Mesh Implementierung •... der Anzahl von Services & Pods •... der Menge der Anfragen → eigener Benchmark empfehlenswert! @INNOQ @HannaPrinz

Slide 36

Slide 36 text

Komplexität •Anpassungen abseits vom happy path •Verlagerung von Funktionen aus den Services in das Mesh (Retry/Timeout, mTLS) •Organisatorische Aspekte: Wem gehört die Mesh-Konfiguration? •Debugging •Debugging •Debugging ... aber der wahre Preis eines Meshes ist @INNOQ @HannaPrinz

Slide 37

Slide 37 text

Istio Demo @INNOQ @HannaPrinz

Slide 38

Slide 38 text

Service Mesh Implementierungen @INNOQ @HannaPrinz

Slide 39

Slide 39 text

Service Mesh Implementierungen Istio 39 Open Service Mesh @HannaPrinz @joergm @INNOQ

Slide 40

Slide 40 text

40 @HannaPrinz @joergm @INNOQ

Slide 41

Slide 41 text

Mehr zu den Implementierungen Istio Talk: Istio, Linkerd & Co - Service Meshes im Vergleich @INNOQ @HannaPrinz ... in 2 Wochen auf dem INNOQ Technology Day

Slide 42

Slide 42 text

technologyday.innoq.com

Slide 43

Slide 43 text

TL;DR @INNOQ @HannaPrinz

Slide 44

Slide 44 text

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

Slide 45

Slide 45 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 46

Slide 46 text

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

Slide 47

Slide 47 text

Monolith Microservices @INNOQ @HannaPrinz

Slide 48

Slide 48 text

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

Slide 49

Slide 49 text

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

Slide 50

Slide 50 text

Try not to need a Service Mesh @INNOQ @HannaPrinz

Slide 51

Slide 51 text

Mehr zum Thema • Service Mesh Vergleich auf servicemesh.es https://servicemesh.es/ • Gut gesiebt: Service Meshes im Vergleich https://www.innoq.com/de/articles/2020/10/service-meshes-im-vergleich/ • Artikel: Glücklich ohne Service Mesh https://www.innoq.com/de/blog/gluecklich-ohne-service-mesh/ • 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/ • Artikel: Alle 11 Minuten verliebt sich ein Microservice in Linkerd https://www.innoq.com/en/articles/2020/01/linkerd2/ • Beispiel-Anwendung mit Istio und Linkerd Tutorial on GitHub https://github.com/ewolff/microservice-istio https://github.com/ewolff/microservice-linkerd @INNOQ @HannaPrinz GOTO 2020 • Getting started with Service Mesh https://www.youtube.com/watch?v=w14ge2838Vs

Slide 52

Slide 52 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