All Products
Search
Document Center

Alibaba Cloud Service Mesh:How do I specify the protocol of a service in a standard manner?

Last Updated:Mar 04, 2024

Service Mesh (ASM) allows you to manage any TCP traffic, including the traffic based on HTTP, HTTPS, gRPC, and TCP protocols. ASM can automatically identify HTTP and HTTP2 traffic. The traffic whose protocols cannot be automatically identified is treated as TCP traffic. To enable ASM to identify the protocols so that it can provide desired functions, you need to specify the protocol of a service in the cluster on the data pane. This topic describes how to specify the protocol of a service in a standard manner.

Background information

ASM supports the following common protocols: HTTP, HTTP2, HTTPS, TCP, TLS, gRPC, gRPC-Web, Mongo, MySQL, and Redis. You can specify the protocol of a service by using one of the following methods:

Method 1: Set the port name of a service to specify the service protocol

In the YAML file of a service, set the name of a port in the following format: {Protocol name} or {Protocol name}-{Custom suffix}. In the following example, the name of port 9090 that uses the gRPC protocol is set to grpc-demo, and the name of port 3306 that uses the MySQL protocol is set to mysql.

kind: Service
metadata:
  name: myservice
spec:
  ports:
  - port: 9090
    name: grpc-demo
  - port: 3306
    name: mysql

Method 2: Set the appProtocol of a service port to specify the service protocol

If your ASM instance is of V1.8.6 or later, and an Alibaba Cloud Container Service for Kubernetes (ACK) cluster or open source Kubernetes cluster of V1.18 or later is used, you can set the appProtocol of a service port to specify the service protocol. The following example shows a YAML file that specifies HTTPS as the service protocol:

kind: Service
metadata:
  name: myservice
spec:
  ports:
   -port: 3306
    name: database
    appProtocol: https
Note

appProtocol has a higher priority than name.