Service Mesh (ASM) can proxy any TCP traffic, including HTTP, HTTPS, gRPC, and raw TCP. By default, ASM automatically detects HTTP and HTTP2 traffic and handles unrecognized traffic as plain TCP. For ASM to identify protocols and provide additional features, specify the protocol of every service in the data plane cluster.
Background information
ASM supports the following common protocols: HTTP, HTTP2, HTTPS, TCP, TLS, gRPC, gRPC-Web, Mongo, MySQL, and Redis. Two methods are available for specifying the protocol of a service:
Method 1: Set the port name of a service to specify the service protocol
In the ports field of a service, set the name of each port to {Protocol name} or {Protocol name}-{Custom suffix}. In the following example, port 9090 uses the gRPC protocol, so its name is set to grpc-demo, and port 3306 uses the MySQL protocol, so its name is set to mysql:
kind: Service
metadata:
name: myservice
spec:
ports:
- port: 9090
name: grpc-demo
- port: 3306
name: mysqlMethod 2: Set the appProtocol of a service port to specify the service protocol
To use this method, your ASM instance must run 1.8.6 or later. The data plane cluster must be an Alibaba Cloud Container Service for Kubernetes (ACK) cluster or an open source Kubernetes cluster running Kubernetes 1.18 or later. Set the appProtocol field of a service port to specify the protocol. The following example specifies HTTPS as the service protocol:
kind: Service
metadata:
name: myservice
spec:
ports:
- port: 3306
name: database
appProtocol: httpsports.appProtocol takes precedence over ports.name.