This is my architecture - Service Mesh

2023年02月04日


I HAVE BEEN RUNNING MY WEB APP ON ISTIO FOR 2 YEARS+. SERVICE MESH IS A BIG PART OF MY ARCHITECTURE.
简单介绍一句Istio和service mesh​。
​A service mesh is a dedicated infrastructure layer for handling service-to-service communication. It is responsible for the reliable delivery of requests through the complex topology of services that comprise a modern and cloud native application. In practice, the service mesh is typically implemented as an array of lightweight network proxies that are deployed alongside application code, without the application needing to be aware.
Istio知识图景​:


​使用Istio service mesh期间的收益:
- 将业务逻辑与非业务逻辑解耦。处理非业务逻辑的代码中被移到service mesh中进行处理,例如处理超时、重试逻辑的代码。
- 自动mTLS。
- 更强大的流量处理能力。
- Kubernetes-native mesh,与K8s有着天然好的配合。
- Istio is language agnostic. 不同于其他微服务框架对于对于开发语言的强绑定。

 
Service Mesh整体架构


 
Ingress部分架构



这里将AWS云资源、K8s资源,以及Istio资源放在一起,互相对照着进行展示。
Gateway把内部的服务暴露给外部访问。
不同于与服务负载共同运行的sidecar/Envoy proxies,Gateway使用位于服务网格边缘的独立的Envoy proxies。Istio Gateway会对Istio Ingress Gateway进行配置。Istio提供了预配置好的gateway proxy deployments(就是我们通常所说的istio-ingressgateway和istio-egressgateway) 。
Istio Gateway之于Istio Ingress Gateway proxy,就像Ingress resource之于ingress controller,Ingress resource定义了一系列的规则和配置并应用到Ingress Controller,Istio Gateway的配置同样会被被应用到Istio Ingress Gateway proxies上(就像上面说过的)。
下面展示了样例的Istio gateway的YAML配置。
其中的selector部分指定了istio: ingressgateway的label,也就是说它指明这个Gateway需要绑定到的Istio ingress gateway。
其中的servers部分指明了这个gateway期望接收的流量。

apiVersion: networking.istio.io/v1beta1
kind: Gateway
metadata:
  name: foo-gateway
  namespace: default
spec:
  selector:
    istio: ingressgateway
  servers:
  - hosts:
    - '*'
    port:
      name: http
      number: 80
      protocol: HTTP
 
在Istio里,Ingress是服务的访问入口,接收外部的请求,并转发到后端的服务。Ingress是通过Gateway方式实现的网关。在K8s里也有Ingress的概念。K8s里的Ingress针对的是7层协议,在功能上受到一定的限制。另外在它的Ingress里面,可以定义一些比较基础的路由规则。Istio里的Ingress针对的是4到6层协议,它只用来定义接入点,而把所有的路由规则全部交给Virtual Service管理。



istio-ingressgateway服务的类型是LoadBalancer。它类似于NodePort类型的service,区别是cloud-controller-manager组件会配置外部的负载均衡器(相对于K8s的内部而言,本示例使用的是AWS ALB),并将流量转发到指定的node port。
apiVersion: networking.istio.io/v1beta1
kind: VirtualService
metadata:
  name: foo
  namespace: default
spec:
  gateways:
  - default/foo-gateway
  hosts:
  - tianzhui.cloud
  http:
  - route:
    - destination:
        host: foo.default.svc.cluster.local
        port:
          number: 80
        subset: v1
      weight: 50



-

Category: container Tags: public

Upvote


Downvote