Code Monkey home page Code Monkey logo

alibaba-centralized-mesh-gateway's Introduction

avatar

Table of Contents

Introduction

The east-west traffic in Istio is carried by envoy sidecars, which are deployed in every pod together with the application containers. Sidecars provide the functions of secure service-to-service communication, load balancing for various protocols, flexible traffic control and policy, and complete tracing.

However, there are also a few disadvantages of sidecars. First of all, deploying one sidecar to every pod can be resource-consuming and introduce complexity, especially when the number of pods is huge. Not only must those resources be provisioned to the sidecars, but also the control plane to manage the sidecar and to push configurations can be demanding. Second, a query needs to go through two sidecars, one in the source pod and the other one in the destination pod, in order to reach the destination. For delay-sensitive applications, sometimes, the extra time spent in the sidecars is not acceptable.

We noted that, for the majority of our HTTP applications, many of the rich features in sidecars are unused. That's why we want to propose a light-weighted way to serve east-west traffic without the drawbacks mentioned in the previous paragraph. Our focus is on the HTTP applications that do not require advanced security features, like mTLS.

We propose the centralized east-west traffic gateway, which moves the sidecars and the functionalities they carry to nodes that are dedicated for sidecars, and no application container shares those nodes. This way, no modifications are required on the nodes, and we can save on the resources and the delay. In addition, we can decouple the network management from application management, and also avoid the resource competition between application and networking. However, because we move the sidecars out of the nodes of applications, we at the same time lose some of the security and tracing abilities provided by the original sidecars. Our observation is that the majority of our applications do not require those features.

Build

  1. Dependency management(Optional)
go mod vendor
  1. Build
go build -o bin/canal-controller cmd/main.go
  1. Build cross-platform images(Optional)
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o bin/canal-controller cmd/main.go
  1. Get a base image
docker pull docker.io/library/alpine:3.11.6
  1. Build the image with the following Dockerfile
FROM alpine:3.11.6
COPY bin/canal-controller /canal-controller
CMD /canal-controller --logtostderr=true
  1. Build the docker image
docker build -f /path/to/your/Dockerfile . -t ${region}/${namespce}/canal:${tag}
  1. Push the image to the remote repository
docker push ${region}/${namespce}/canal:${tag}

Prerequisite

  1. Only one Gateway can be attached to InternalGateway.
  2. The VirtualService managed by InternalGateway must be attached to the Gateway mention in 1.
  3. CoreDNS is required.

Install

  1. Install the Istio base chart which contains cluster-wide resources used by the Istio control plane
helm install istio-base ./base -n istio-system
  1. Install the Istio discovery chart which deploys the istiod service
helm install istiod ./istio-discovery/ -n istio-system
  1. Install the Canal Gateway(router mode Envoy)
helm install canal-gateway ./canal -n istio-system
  1. Install the Canal Controller
helm install canal-control ./canal-control -n istio-system \
    --set global.hub=${your hub} \
    --set global.imagePullSecrets[0]=${your secret} \
    --set global.tag=${your tag}

Usage

Use centralized east-west traffic gateway to handle east-west traffic

  1. Deploy Canal Service.

  2. Create HelloWorld service. Note that the port opened must be consistent with the port opened on the gateway.

apiVersion: v1
kind: Service
metadata:
  name: helloworld
  labels:
    app: helloworld
spec:
  ports:
  - port: 5000
    name: http
  selector:
    app: helloworld
---
  1. Create Gateway, and attach it to Canal Gateway.
kind: Gateway
metadata:
  name: canal
  namespace: istio-system
spec:
  selector:
    app: canal-gateway
  servers:
  - port:
      number: 5000
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
  1. Create VirtualService.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - canal
  http:
  - match:
    - uri:
        exact: /hello
    route:
    - destination:
        host: helloworld.default.svc.cluster.local
---
  1. Execute the following command. You should find the IP address of the HelloWorld service changed to the gateway's IP.
dig helloworld.default.svc.cluster.local

Move existing traffic to centralized east-west traffic gateway

Approach 1: move only the traffic, and keep the service

  1. Deploy Canal Service.

  2. Create Gateway, and attach it to Canal Gateway.

kind: Gateway
metadata:
  name: canal
  namespace: istio-system
spec:
  selector:
    app: canal-gateway
  servers:
  - port:
      number: 5000
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
  1. Create VirtualService.
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - canal
  http:
  - match:
    - uri:
        exact: /hello
    route:
    - destination:
        host: helloworld.default.svc.cluster.local
---
  1. Un-inject sidecars by removing the injection command.
kubectl label namespace your-namespace istio-injection=disabled

Approach 2: replace the existing service

Note that we can also create a new replacement service, and attach the new service with InternalGateway, and remove the old service.

  1. Create a new service and attach it to the internal gateway as instructed before.
kind: Gateway
metadata:
  name: canal
  namespace: istio-system
spec:
  selector:
    app: canal-gateway
  servers:
  - port:
      number: 5000
      name: http
      protocol: HTTP
    hosts:
    - "*"
---
apiVersion: v1
kind: Service
metadata:
  name: helloworld-on-canal
  labels:
    app: helloworld-on-canal
spec:
  ports:
  - port: 5000
    name: http
  selector:
    app: helloworld-on-canal
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: helloworld-on-canal
  namespace: istio-system
spec:
  hosts:
  - "*"
  gateways:
  - canal
  http:
  - match:
    - uri:
        exact: /hello
    route:
    - destination:
        host: helloworld-on-canal.default.svc.cluster.local
  1. remove the old service.

License

Apache License 2.0

Welcome to communicate with us

avatar

alibaba-centralized-mesh-gateway's People

Contributors

alibaba-oss avatar yuri-lcy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

alibaba-centralized-mesh-gateway's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.