70
Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva

with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

  • Upload
    others

  • View
    14

  • Download
    1

Embed Size (px)

Citation preview

Page 1: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Introduction to service mesh with Istio and Kiali

Alissa Bonas

mikeyteva

Page 2: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Evolution of application architecture

How did we get to service mesh?

Page 3: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Monolith application

Single unit of executable

= Application

=Single process

Page 4: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Application modules

Application

Handle HTTP

requests

Data processingUI

Alerts

Page 5: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Multiple processes

ApplicationUI

Data processing

Alerts

Handle HTTP

requests

Page 6: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Microservices

Language agnostic

Scaled separately

Upgraded separately

Page 7: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

A shift in Application Packaging and Runtime

Page 8: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Containerizing an app

Page 9: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Run multiple containers

Page 10: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

● Run many containers on multiple hosts

● Scale - manage several instances (replicas)

of the same container

● Manage a container based environment

Orchestrate containers

Page 11: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Container orchestration platforms

Kubernetes OKD

(Openshift)

Page 12: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Kubernetes building blocks (some…)● Pod - a group of one or more containers, with shared

storage/network

● Deployment - manages pod definition and defines replicas of pods

● Service - an abstraction, an access point to a set of Pods

○ Sometimes called a microservice

Page 13: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Replica 3

Microservices - the Kubernetes way

Service A

ServiceB

Replica 2

Pod

Pod Replica 1

Access point =

microserviceCode

Container

Container

Page 14: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

High Complexity

Page 15: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Multiple points of failure

!!!

?

?

Page 16: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Challenges● How are the requests routed between services?

● How do I detect failures and downtime?

● How to upgrade and test new versions of a service?

● Securing the communication

Page 17: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Service mesh to the rescue

Page 18: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

What is a service mesh● Infrastructure/framework that handles communication

between services

● Often implemented as network proxies deployed

alongside the microservices

Page 19: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Istio - Ιστίο

Open source service mesh

Page 20: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

The dry facts● Started in May 2017

● Means “sail” in Greek

● Developed in Go

Page 21: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Istio features● Load balancing (HTTP, gRPC, TCP...)

● Traffic control (routing rules, retries, timeouts, fault

injection, mirroring)

● Secure service-to-service communication

● Access controls (authorization)

● Metrics and traces for traffic

Page 22: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Important Terminology● Workload - anything owning/controlling pods (like a

Deployment) or the pods themselves

● Service - a microservice

● Application - label “app” on a pod/service

● Version - label “version” on a pod/service

Page 23: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Before Istio

POD A

Container

Routing code

Circuit breaker code

Business logic code

POD B

Container2

Routing code2

Circuit breaker code2

Business logic code2

Page 24: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Istio

POD A

Container

Routing code

Circuit breaker code

Business logic code

POD B

Container2

Routing code2

Circuit breaker code2

Business logic code2

Page 25: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Sidecar Proxy● A proxy is deployed in a container next to each instance

of microservice (inside a pod)

● Container name: istio-proxy

● It is transparent to application code

● Envoy open source proxy is currently used

Page 26: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

How is the sidecar injected?● Manually

● Automatically injected to pod on creation○ kubectl label namespace default istio-injection=enabled

○ Mutating Admission Webhook is used for sidecar injection

○ Actually… 2 containers are injected: istio-init and istio-proxy

Page 27: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Istio architecture

Page 28: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Sidecar Proxy in Istio and Kubernetes

POD

Container

Business logic code

POD

Container

Business logic code

Sidecar container

Before Istio, no sidecar With sidecar

Routing code

Circuit breaker code

Page 29: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

With Istio - sidecar intercepts all traffic

Envoy sidecar

container

POD A

Sidecar container

Container

Business logic code

HTTP, TCP, TLS...

HTTP, TCP, TLS...

Envoy sidecar

container

POD C

Sidecar container

Container

Business logic code

Sidecar container

Container

Business logic code

Envoy sidecar

container

POD B

Sidecar container

Container

Business logic code

Configuration is transparent to the services and not part of the code

Page 30: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Istio routing in Kubernetes

Service A

ServiceB

PodReplica 2

Pod

Pod Replica 1

Container

Container

Sidecar container Container

Sidecar container

Sidecar container

Communication is “Envoy to Envoy”bypassing the Kubernetes Service

Page 31: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Different routing scenarios● A/B testing

● Traffic shifting○ Canary deployment (an example of traffic shifting)

● Mirroring traffic

Page 32: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Weighted Routing with Istio - A/B

Service A

ServiceB

Replica 2

Pod Version 2

Pod

Pod Version 1Replica 1

50% traffic

50%traffic

Proportion of traffic routed to a version is independent of number of instances of that version

Page 33: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Weighted Routing - Canary

Service A

ServiceB

Replica 2

Pod

Pod Version 2

Pod Version 1Replica 1

90% traffic

10%traffic

Proportion of traffic routed to a version is independent of number of instances of that version

Page 34: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Matching Routing with Istio

Service A

ServiceB

Pod Version 1

Pod

Pod Version 2

All users

User Alissa

Page 35: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Mirroring traffic

Service A

ServiceB

Pod Version 1

Pod

Pod Version 2

Copy of traffic

Response disregarded

Real traffic

Page 36: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

"Anything that can go wrong will go wrong"

(Murphy’s law)

Page 37: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside
Page 38: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Chaos engineering with Istio● Inject delays

○ Simulate network latency○ Simulate an overloaded service

● Define aborts (Inject Errors)○ Simulate failure in a service (return a predefined HTTP Error)○ A good alternative for a manual shutdown or “scale to zero”

Page 39: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Inject delay

Service A

ServiceB

Instance 2

Pod

PodVersion 2

PodVersion 1Instance 1

Add 7 secondsdelay to

response

Page 40: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Inject Error

Service A

ServiceB

Instance 2

Pod

Pod Version 2

Pod Version 1Instance 1

Return Error 500 for user Alissa

Work as usual for all the users

Page 41: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Circuit breaker● Set a connection pool to limit connections and requests● Example: “Set a connection pool of 100 connections with no more than 10

req/connection to service A”

Page 42: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Outlier detection● Classify instances as healthy/unhealthy

● Eject unhealthy instances for a defined timeframe which

can be increased over time● Example: “Scan all pods every 5 mins, any instance that fails 7

consecutive times with 5XX error code will be ejected for 15 minutes.”

Page 43: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Authorization and Authentication● Authentication

○ End user authentication (JSON Web Token (JWT) )○ Service to service authentication (mutual TLS)

■ Permissive mode is possible for flexible migration● Authorization

○ Can service <A> send <this request> to service <B> ?○ Roles are visible across namespaces○ ServiceRole and ServiceRoleBinding

Page 44: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Security● Defining a Gateway ingress/egress to enable traffic

in/out of mesh

● Citadel monitors service accounts creation and creates a certificate for them

○ Certificates only in memory, sent to Envoy via SDS API

● mTLS can be defined on multiple levels○ Client and server exchange certificates, 2 way

○ All mesh, specific service, etc.

Page 45: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Configuration objects• VirtualService != Kubernetes service

• Rules for how requests to a service are routed within service mesh

• Routing logic, load weighting, chaos injection

• DestinationRule• Configures policies to be applied to a request after VirtualService

routing has occurred

• Load balancer, circuit breaker

• MeshPolicy, Gateway, ServiceEntry and more...

Page 46: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Configuration Yaml example

All Istio objects are CRD

(CustomResourceDefinition)

Page 47: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

New set of challenges● How many versions exist for service A?

● Is there any traffic now?

● Is routing configured for service B?

● Is my configuration valid?

● Is security on?

● Is the app healthy?

Page 48: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Kiali - Κιάλι

Open source Istio service mesh observability

Page 49: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Dry facts● Started in January 2018

● Means “spyglass” or “monocular” in Greek

● Developed in Go and React

Page 50: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Kiali Features● Visualize mesh connections and traffic● Service and application health● Configure routing via UI● Validate Istio configurations● View metrics, traces and logs● Visualize security configuration

Page 51: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

A picture is worth a thousand yamls

Page 52: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Demos based on Bookinfo example

Page 53: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Let’s see Kiali in action● Mesh visualization

● Fault Injection

● Configuration Validation

● Configure routing rules

● Tracing

● Traffic stats

Page 54: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Bookinfo example

Page 55: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Bookinfo on Kiali

Page 56: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Kiali Features

Page 57: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Overview page

Page 58: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Mesh Topology Graph

Page 59: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Hide and Seek

Page 60: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Details Page

Page 61: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Viewing Logs

Page 62: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Runtime metric dashboards

Page 63: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Weighted Routing

Page 64: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Configuration validations

Page 65: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Tracing (integration with Jaeger)

Page 66: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Visualizing security

Page 67: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Connect with the communityKiali.io Istio.io

KialiProject IstioMesh

github.com/kiali github.com/istio

Page 68: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Icon credits● Twitter by Lubos Volkov, the Noun Project

● Light Bulb by artworkbean, the Noun Project

● Magnifying Glass by Musket from the Noun Project

● Questions by Rediffusion from the Noun Project

● Mug by Alex Getty from the Noun Project● Diamond by MarkieAnn Packer from the Noun Project● Box by Cornelius Danger from the Noun Project

Page 69: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Thank you!

mikeyteva

Page 70: with Istio and Kiali Introduction to service mesh · 2019-12-21 · Introduction to service mesh with Istio and Kiali Alissa Bonas mikeyteva. Evolution of application ... alongside

Introduction to service mesh with Istio and Kiali

Alissa Bonas

mikeyteva