1 of 23

Service Mesh

服务网格

2 of 23

Objective

Distributed multi-cloud, multi-region architecture

Enables core capabilities by default at the platform level

A layer that lets you connect, secure, control, observe microservices

3 of 23

Products

Linkerd (CNCF graduated project)

Istio

Consul

Kuma (CNCF sandbox project)

AWS App Mesh

NGINX Service Mesh

AspenMesh

Kong

Solo Gloo Mesh

Tetrate Service Bridge

Traefik Mesh (formerly Maesh)

Meshery

Open Service Mesh (CNCF sandbox project)

Cilium eBPF

4 of 23

Core Features

  • Traffic Management, Routing Policies
    • Canary Deployment
    • A/B Testing
    • Request Routing
    • Traffic Shifting
    • Failover
    • Request Timeouts
    • Circuit Breaking
    • Traffic Mirroring

5 of 23

Capabilities

  • Security by default
    • Client authentication
    • Rate limiting
    • TLS termination, traffic encryption

  • Observability
    • Networking metrics
    • Tracing
    • Service graph

6 of 23

7 of 23

8 of 23

Proxy lib

Application A

Proxy lib

Application B

Control Plane

HTTP, gRPC, TCP

mTLS

Routing

Policy management

Cert management

9 of 23

Proxy

Service A

Proxy

Service B

Istio Control Plane

HTTP, gRPC, TCP

mTLS

Routing

Policy management

Cert management

Application A

Application B

Sidecar network Policy

10 of 23

Proxy

Service A

Proxy

Service B

Istio Control Plane

HTTP, gRPC, TCP

mTLS

Routing

Policy management

Cert management

Application A

Application B

Ingress

gateway

mTLS

Egress

gateway

mTLS

11 of 23

High-Level Architecture (old)

12 of 23

High-Level Architecture (1.5+)

13 of 23

Proxy: Sidecar Injection

Istio proxy sidecar injected during pod creation time via mutatingwebhookconfiguration istio-sidecar-injector

Istio-init: the init container sets up the iptable rules so inbound/outbound traffic will go through sidecar proxy

Istio-proxy: the sidecar proxy based on envoy

To see the template being used:

kubectl -n istio-system get configmap istio-sidecar-injector

Spec:

initContainers:

- name: istio-init

image: docker.io/istio/proxy_init:1.0.2

args:

- istio-iptables

- -p

- "15001"

- -u

- 1337

.....

securityContext:

capabilities:

add:

- NET_ADMIN

restartPolicy: Always

containers:

- name: istio-proxy

14 of 23

Proxy: Packet walk

Pod

Istio-proxy

Envoy

Application

iptable

:15001

eth0

:8080

IO

127.0.0.1:8080

127.0.0.1:15001

  • Pilot and Mixer program the Envoy Proxy with config rules
  • Traffic destined for a container is redirected to the envoy via iptable
  • Envoy applies it config rules and send traffic to container via localhost

15 of 23

K8s Pod

16 of 23

Pilot

  • Core component for traffic management that configures and manages all Envoy proxies deployed in a service mesh
  • Converts high level routing rules into envoy-specific configs and propagates them to envoys at runtime
  • Provides service discovery for envoys

17 of 23

Traffic Management (networking.istio.io)

VirtualService rules that control how requests for services are routed within the mesh

DestinationRule specifies a set of policies to be applied to the request

Gateway HTTP/TCP loadbalancer, at the ingress to enable traffic

ServiceEntry enable requests to services outside of the mesh

18 of 23

Traffic Management Features

apiVersion: networking.istio.io/v1beta1

kind: VirtualService

...

spec:

hosts:

- reviews

http:

- match:

- headers:

end-user:

exact: jason

route:

- destination:

host: reviews

subset: v2

- route:

- destination:

host: reviews

subset: v1

ConditionRouting: based on http header

apiVersion: networking.istio.io/v1beta1

kind: VirtualService

...

spec:

hosts:

- reviews

http:

- match:

- sourceLabel:

app: reviews

version: v1

route:

- destination:

host: rate

subset: v2

- route:

- destination:

host: rate

subset: v1

ConditionRouting: based on source label

19 of 23

Traffic Management Features

Timeout

apiVersion: networking.istio.io/v1alpha3

kind: VirtualService

metadata:

name: reviews

spec:

hosts:

- reviews

http:

- route:

- destination:

host: reviews

subset: v2

timeout: 0.5s

Retry

apiVersion: networking.istio.io/v1alpha3

kind: VirtualService

metadata:

name: reviews

spec:

hosts:

- reviews

http:

- route:

- destination:

host: reviews

subset: v2

retries:

attempts: 3

perTryTimeout: 2s

20 of 23

Traffic Management Features

Circuit Break

apiVersion: networking.istio.io/v1beta1

kind: DestinationRule

...

spec:

host: httpbin

trafficPolicy:

connectionPool:

http:

http1MaxPendingRequests: 1

maxRequestsPerConnection: 1

tcp:

maxConnections: 1

outlierDetection:

baseEjectionTime: 3m

consecutive5xxErrors: 1

interval: 1s

maxEjectionPercent: 100

21 of 23

Security Features

Enable mutual TLS per namespace

apiVersion: security.istio.io/v1beta1

kind: PeerAuthentication

metadata:

name: "default"

namespace: "foo"

spec:

mtls:

mode: STRICT

Allow access with GET method to the specified workload

apiVersion: security.istio.io/v1beta1

kind: AuthorizationPolicy

metadata:

name: "productpage-viewer"

namespace: default

spec:

selector:

matchLabels:

app: productpage

action: ALLOW

rules:

- to:

- operation:

methods: ["GET"]

22 of 23

Security Architecture

  • Citadel issues keys and certificates to Envoy
  • Envoys implement secure communication.
  • Mixer manages authorization and auditing
  • Pilot distributes policies and secure naming information to the proxies.

23 of 23