32
#IstioCon Best practice: from spring cloud to Istio [email protected]

Best practice: from spring cloud to Istio

  • Upload
    others

  • View
    8

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Best practice: from spring cloud to Istio

#IstioCon

Best practice: from spring cloud to Istio

[email protected]

Page 2: Best practice: from spring cloud to Istio

#IstioCon

About me

Chaomeng Zhang is the Chief Architect of Huawei Cloud ASM (Application Service Mesh) service, which is based on Istio and Kubernetes.

Chaomeng has been working on cloud native technologies for more than 6 years, including Kubernetes, microservices, service catalog, APM, devops and service mesh for now. He is an Istiocommunity member, author of one bestselling Chinese Istio book "Cloud Native Service Mesh Istio". He is also an experienced speaker of many cloud native and open source conferences, including KubeCon, Cloud Native Days, Service mesh meetup, k8smeetup.

Page 3: Best practice: from spring cloud to Istio

#IstioCon

Agenda

● Concepts

● Problems

● Solutions

● Practice

Page 4: Best practice: from spring cloud to Istio

#IstioCon

Complexities of micro service

module

modulem

odule

module

module

module

module

svc

svc

svc

svc

svc

svc

Page 5: Best practice: from spring cloud to Istio

#IstioCon

Microservice SDK

Node 1

Consumer svc

app

SDK

Service management

Node 2

Producer svc

app

SDK

Service management

Network

Service discoveryLoad balancingCircuit breakerDynamic routing...

Page 6: Best practice: from spring cloud to Istio

#IstioCon

Service Mesh

Node 1

Consumer svc

app

Proxy

Service management

Node 2

Producer svc

app

Proxy

Service management

Network

Service discoveryLoad balancingCircuit breakerDynamic routing...

Page 7: Best practice: from spring cloud to Istio

#IstioCon

Spring cloud•Spring Cloud Bus•Spring Cloud Circuit Breaker•Spring Cloud CLI•Spring Cloud for Cloud Foundry•Spring Cloud - Cloud Foundry Service Broker•Spring Cloud Cluster•Spring Cloud Commons•Spring Cloud Config•Spring Cloud Connectors•Spring Cloud Consul•Spring Cloud Contract•Spring Cloud Function•Spring Cloud Gateway•Spring Cloud GCP•Spring Cloud Kubernetes•Spring Cloud Netflix•Spring Cloud Open Service Broker•Spring Cloud OpenFeign•Spring Cloud Pipelines•Spring Cloud Schema Registry•Spring Cloud Security•Spring Cloud Skipper•Spring Cloud Sleuth•Spring Cloud Stream•Spring Cloud Stream App Starters•Spring Cloud Stream Applications•Spring Cloud Task•Spring Cloud Task App Starters•Spring Cloud Vault•Spring Cloud Zookeeper•Spring Cloud App Broker

Page 8: Best practice: from spring cloud to Istio

#IstioCon

Istio

Automatic load balancing for HTTP, gRPC, WebSocket, and TCP traffic.

Fine-grained control of traffic behavior with rich routing rules, retries, failovers, and fault injection.

A pluggable policy layer and configuration API supporting access controls, rate limits and quotas.

Automatic metrics, logs, and traces for all traffic within a cluster, including cluster ingress and egress.

Secure service-to-service communication in a cluster with strong identity-based authentication and authorization.

Page 9: Best practice: from spring cloud to Istio

#IstioCon

Service Discovery & Load balance

Registry(Eureka)

Producer(Eureka client)

Consumer(Eureka client

& Ribbon)

Discover

Register

Loadbalance

IstioD Kube-apiserver

Listwatch

Envoy

SVC

Pod

Kubelet

Envoy

SVC

Pod

Kubelet

Spring cloud Istio

Service Registry

Service register to Eureka Not need

Service discovery

Consumer calls eureka get instance list

Pilot listwatch kube-apiserver service and endpoints

Load balance Ribbon in SDK selet instance Proxy select instance

Location In process Out of process

Discover

Load balance

(Spring cloud)

(Istio)

Page 10: Best practice: from spring cloud to Istio

#IstioCon

Circuit breaker

Compare Hystrix Istio

Method White box Black boxActions Coding fallback Only configuration

With application

Wraped with HystrixCommand Non-invasive, by proxy

Function Circuit breaker, threadpool

Outlier detection, threadpool

Protect functionality

Micro service call, and other potentially risky functionality

Service call over the network with fault and latency tolerance

Open

Half Open

Closed

request

reset(timeout)

fail

success

success

fail(not match threshold)

fail(match threshold)

Page 11: Best practice: from spring cloud to Istio

#IstioCon

Agenda

● Concepts

● Problems

● Solutions

● Practice

Page 12: Best practice: from spring cloud to Istio

#IstioCon

Problem 1: Multi language

Spring cloud Spring cloud

Spring cloud

GolangPython

Spring cloud

Spring cloud

C++

Node.js

Control plane

Page 13: Best practice: from spring cloud to Istio

#IstioCon

Problem 2: Discovery latency when Spring cloud running inside Kubernetes

Kube-apiserver

Consumer(Springcloud)

Pod

Kubelet

Eureka

Pod

Kubelet

Producer(Springcloud)

Pod2

Kubelet

Producer(Springcloud)

Pod1

Kubelet

register

deregister

discover

Producer

pod migration

Producer:Pod1Pod2

Page 14: Best practice: from spring cloud to Istio

#IstioCon

Problem 3: Upgrade all application in case of service management changing

Spring cloud SDK(v1)

svc1

Spring cloud SDK(v1)

svc2

Spring cloud SDK(v1)

svc3

Spring cloud SDK(v1)

svc101

Spring cloud SDK(v1)

svc102

Spring cloud SDK(v1)

svc103

Spring cloud SDK(v2)

svc1

Spring cloud SDK(v2)

svc2

Spring cloud SDK(v2)

svc3

Spring cloud SDK(v2)

svc101

Spring cloud SDK(v2)

svc102

Spring cloud SDK(v2)

svc103

SDK Bug fix, new feature

All apprebuild, reimage, upgrade

Page 15: Best practice: from spring cloud to Istio

#IstioCon

Problem 4: Gradually migrate from a monolith to micro services

SDK

svc11

SDK

svc13

SDK

svc22

SDK

svc12

SDK

svc21

SDK

svc23

Micro Service

svc1

svc2

Monolithic Service

Rewrite with unified SDK

The only thing a Big Bang rewrite guarantees is a Big Bang -- Martin Fowler

Page 16: Best practice: from spring cloud to Istio

#IstioCon

Agenda

● Concepts

● Problems

● Solutions

● Practice

Page 17: Best practice: from spring cloud to Istio

#IstioCon

Solution 1: Multi language

Spring cloud Proxy Spring cloud Proxy Spring cloud Proxy

Spring cloud Proxy Spring cloud Proxy C++ Proxy

Python Proxy Golang Proxy Node.js Proxy

IstioD

Page 18: Best practice: from spring cloud to Istio

#IstioCon

Solution 2: Native Kubernetes service discovery

Kube-apiserver

Consumer(Springcloud)

Pod

Kubelet

Producer

pod migration Proxy

Producer(Springcloud)

Pod1

Kubelet

Proxy

Producer(Springcloud)

Pod2

Kubelet

Proxy

IstioD

Producer:Pod1Pod2

Page 19: Best practice: from spring cloud to Istio

#IstioCon

Solution 3: Application NOT affected in case of Service management upgrading

svc1 Proxy(v1) svc101 Proxy

(v1)

svc2 Proxy(v1) svc102 Proxy

(v1)

svc3 Proxy(v1) svc103 Proxy

(v1)

svc1 Proxy(v2) svc101 Proxy

(v2)

svc2 Proxy(v2) Svc102 Proxy

(v2)

svc3 Proxy(v2) Svc103 Proxy

(v2)

Istio upgrade

ApplicationNot affected

IstioD(v1)

IstioD(v2)

Page 20: Best practice: from spring cloud to Istio

#IstioCon

Solution 4: Gradually migrate from a monolith to micro services

svc11

Proxy

svc12

Proxy

svc13

Proxy

svc2

Proxy

svc11

Proxy

svc12

Proxy

svc13

Proxy

svc22

Proxy

svc23

Proxy

svc21

Proxy

IstioD IstioD

Old Monolith also equally managed by Istio as well as new micro service

Page 21: Best practice: from spring cloud to Istio

#IstioCon

Agenda

● Concepts

● Problems

● Solutions

● Practice

Page 22: Best practice: from spring cloud to Istio

#IstioCon

Make SDK to be SDK

Spring cloud

VM

Application

InfrastructureKubernetes/VM

Istio

Spring

Development + Management Development

Running Running + Management

Cloud native Infrastructure:

• Kubernetes: Flexible application deployment, management and scaling

• Istio: Non-intrusive traffic management, security and observability

Application Development:

Spring Boot: Create production-grade applications that you can "just run".

Page 23: Best practice: from spring cloud to Istio

#IstioCon

Detailed migrating Process

Consumer

Application call

Service discovery

Load balance

Producer

Eureka

Consumer

Application call

Service discovery

Load balance

Producer

IstioD

EnvoySDK

① Discard SDK service registry

② Bypass sdk service discovery and Loadbalancer, call producer directly by Kubernetes service name

③ Replace SDK’s service management logic with meshgradually.

Kube-apiserver

migrate

Page 24: Best practice: from spring cloud to Istio

#IstioCon

Bypass SDK by changing configuration

# disable eureka discovery#eureka:# client:# serviceUrl:# defaultZone: http://10.133.249.158:8761/eureka/# instance:# leaseRenewalIntervalInSeconds: 10

# ribbon static instance set to kubernetes service name and portproducer:ribbon:

listOfServers: producer:7111

application.yaml

(Similar modification to annotation based config)

Page 25: Best practice: from spring cloud to Istio

#IstioCon

PASSTHROUGH: Offload CLOUD in Spring cloud

Spring cloud

Spring

Page 26: Best practice: from spring cloud to Istio

#IstioCon

Micro service Gateway migration

SpringcloudGateway(or zuul)

svc1

svc2

svc3

SpringcloudGateway(or zuul)

Eureka

svc1

svc2

svc3

Spring cloud

Gatewayto

App facade

IstioD

IngressGateway

svc1

svc2

svc3

IstioD

Proxy

Solution 1:for specified gateway scenario(specified application related filters)

Solution 2:for general gateway scenario(service mapping, security)

Page 27: Best practice: from spring cloud to Istio

#IstioCon

IstioD

Multi language, Multi framework, Multi Env.

Envoy

C++

VM

SDKEnvoy

SDK

Pod

KubeletEnvoy

Python

VM

JavaRest

HTTP

Envoy

Java

Pod

Kubelet

Envoy

C++

Pod

Kubelet

gRPCRest

• Control plane: The unified control plane of Istio is used for service discovery and policy management.

• Data plane: Service discovery, load balancing, and management are performed on the Envoy of the Istio data plane. The application can be code in c, cpp,

python normal java ,or springcloud framework .The Spring Cloud serves as the development framework and provides the service development framework and service protocols.

Page 28: Best practice: from spring cloud to Istio

#IstioCon

Example: Istio canary for SpringCloud app

kubectl logs helloclient-6fcc9cb8c9-qz5ng -c istio-proxy -nspringcloud-passthrough -f

Page 29: Best practice: from spring cloud to Istio

#IstioCon

Example: Istio circuit breaker help isolate unhealthy Springcloud instance

① Unhealthy instance triggers circuit breaker

② Traffic of the unhealthy instance decreases

③ The unhealthy instance is isolated

The traffic on the unhealthy instance is gradually reduced until it is completely isolated. As a whole, only healthy instances of the service receive traffic.

Page 30: Best practice: from spring cloud to Istio

#IstioCon

Example: Istio circuit breaker help isolate unhealthy Springcloud instance

① There is no traffic on the recovered failed instance

② A small amount of traffic starts to be received on the recovered failed instance

③ The recovered failed instance receives the same traffic as

other instances

When the unhealthy instance is normal back, under circuit breaker policy, traffic will be automatically distributed to it .

Page 31: Best practice: from spring cloud to Istio

#IstioCon

Summary: Micro service, Container, Kubernetes,Istio

Micro Service Container

Istio Kubernetes

④ Manage

Run

Orchestrate ②

Integrate

Application

Infrastructure

① Containers and microservices share the same lightweight and agile features. ② The use of Kubernetes for container orchestration is already the current standard.③ Istio and Kubernetes are closely combined to provide an end-to-end microservice running & management platform.④ Istio becomes the trend of microservice management.

Page 32: Best practice: from spring cloud to Istio

#IstioCon

Thank you!

@idouba