All Products
Search
Document Center

Alibaba Cloud Service Mesh:Connect to Consul service registries

Last Updated:Jun 20, 2026

Service Mesh ASM supports integration with a Consul service registry to help you migrate microservices to ASM. This topic describes how to integrate a Consul service registry with ASM.

Prerequisites

  • Your ASM instance must run version v1.7.5.31-g28ec7490-aliyun or later.

  • Consul is deployed as a service registry. For more information, see Installing Consul on Kubernetes.

  • Pods in the Kubernetes cluster added to the Service Mesh must be able to access the Consul server endpoint. For example, the Consul server is installed in the same Kubernetes cluster and exposes a public endpoint, or provides an accessible internal endpoint.

  • Sample services, including Web, Web2, and the built-in Consul service, must be registered in Consul. For more information, see Services.

Background

ASM provides a feature to connect to a Consul service registry, which facilitates the migration of microservices to ASM by allowing services inside the Service Mesh to call services outside the Service Mesh. ASM does not automatically register services from within the Service Mesh with the Consul service registry. To allow services outside the Service Mesh to call services inside the service mesh, you must manually register the services from within the Service Mesh with the Consul service registry.

Step 1: Obtain ASM-se-syncer configuration

  1. Obtain the ASM instance ID.

    1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

    2. On the Mesh Management page, find the ID of your target instance in the Name/ID column.

  2. Obtain the cluster region ID.

    1. Log on to the ACK console. In the left navigation pane, click Clusters.

    2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Cluster Information.

    3. In the Basic Information section, view the region of the cluster. For example, if the region is China (Beijing), the region ID is cn-beijing. For more information about regions, see Supported regions.

  3. Obtain an AccessKey ID and an AccessKey secret. For more information, see Create an AccessKey pair.

Step 2: Install ASM-se-syncer

  1. Connect to your cluster by using kubectl. For more information, see Obtain the kubeconfig file of a cluster and use kubectl to connect to the cluster.

  2. Install Helm on your local machine. For more information, see the Helm documentation.

    Note

    After you connect to the cluster with kubectl, the Helm client automatically uses the KubeConfig file to connect to the cluster.

  3. Download and decompress the asm-se-syncer Helm chart to your local machine.

  4. Enter the asm-se-syncer folder and find the values.yaml file. In the values.yaml file, add the ASM ID, cluster region ID, AccessKey ID, and AccessKey secret, modify the following Consul service information, and then save the values.yaml file.

    [
      {
        "name": "consul-test",
        "prefix": "consul-",
        "type": "consul",
        "endpoint": "http://consul-server.consul:8500",
        "toNamespace": "default"
      }
    ]

    Parameter

    Description

    name

    A unique name for the service registry.

    prefix

    The prefix for the names of the generated service entry resources.

    type

    The type of the service registry. The only supported value is consul.

    endpoint

    The endpoint address of the service registry.

    toNamespace

    The namespace where the generated service entry resources are created. If the namespace does not exist, it is automatically created.

    To connect to multiple Consul service registries, add the configuration for each registry to the values.yaml file. Then, save the values.yaml file.

    [
      {
        "name": "consul-test01",
        "prefix": "consul01-",
        "type": "consul",
        "endpoint": "http://consul-server01.consul:8500",
        "toNamespace": "default"
      },
      {
        "name": "consul-test02",
        "prefix": "consul02-",
        "type": "consul",
        "endpoint": "http://consul-server02.consul:8500",
        "toNamespace": "default"
      }
    ]
  5. Run the following command to install ASM-se-syncer.

    helm install -f values.yaml se-syncer ./

    After ASM-se-syncer is installed, ASM automatically connects to the Consul service registry, installs the asm-serviceregistry-syncer component in the ACK cluster, and synchronizes services from Consul to the Service Mesh.

Step 3: Verify the Consul integration

  1. Check the installation status of the ASM component.

    1. Log on to the ACK console. In the left navigation pane, click Clusters.

    2. On the Clusters page, click the name of your cluster. In the left navigation pane, click Workloads > Deployments.

    3. On the Deployments page, find the component named asm-serviceregistry-syncer.

      If the component is in the 1/1 ready state, it is running correctly.

  2. Check the synchronization status of the service entry resources.

    1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

    2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Cluster & Workload Management > External Service(ServiceEntry).

    3. On the External Service(ServiceEntry) page, verify that the services registered in Consul have been synchronized to the Service Mesh.

      Note
      • On the External Service(ServiceEntry) page, the names of the Consul services follow the format: [prefix]-[service name in Consul]. The prefix is the value specified for the prefix parameter.

      • On the External Service(ServiceEntry) page, the namespace of the Consul services is the value of the toNamespace parameter you specified.

FAQ

How do I call a synchronized service?

Once the calling service's cluster is part of the service mesh data plane, you can call the synchronized service in one of the following ways:

  • Method 1: Enable the DNS proxy and call the service by using the hostname and port from the hosts field of the service entry.

    1. Enable the DNS proxy. For more information, see Use the DNS proxy feature in an ASM instance.

    2. Obtain the hostname and port to call the service.

      1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

      2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Cluster & Workload Management > External Service(ServiceEntry).

      3. On the External Service(ServiceEntry) page, find the target service entry and click View YAML in the Operator column.

        In the Edit dialog box, obtain the hostname and port, and use http://<hostname>:<port> to call the service. In the ServiceEntry YAML file, the key configuration item hosts is set to pro-qf-test, and the port number (number) is set to 80.

        - apiVersion: istio.alibabacloud.com,
              controller: true
              kind: ASMServiceRegistry
              name: default
              uid: 5d301b4e-39bc-46b5-xxx
              resourceVersion: '432158678'
              selfLink: >-
                /apis/networking.istio.io/v1beta1/naxxx
              uid: e446b651-be82-4e13-99xxx
          spec:
            addresses:
              - 172.30.xxx
            endpoints:
              - address: 172.xxx
                ports:
                  http: 80
            hosts:
              - pro-qf-test
            ports:
              - name: http
                number: 80
                protocol: HTTP
            resolution: STATIC
  • Method 2: Call the service by using the address from the endpoints field of the External Service(ServiceEntry).

    1. Log on to the ASM console. In the left-side navigation pane, choose Service Mesh > Mesh Management.

    2. On the Mesh Management page, click the name of the ASM instance. In the left-side navigation pane, choose Cluster & Workload Management > External Service(ServiceEntry).

    3. On the External Service(ServiceEntry) page, find the target service entry and click View YAML in the Operator column.

      In the Edit dialog box, find the address. Call the service using the http://<address> format. In the YAML, the key configuration item is the address field under spec.endpoints.

      - apiVersion: istio.alibacloud.com
            controller: true
            kind: ASMServiceRegistry
            name: default
            uid: 5d301b4e-39bc-46b5-xxx
            resourceVersion: '432158678'
            selfLink: >-
              /apis/networking.istio.io/v1beta1/naxxx
            uid: e446b651-be82-4e13-99xxx
        spec:
          addresses:
            - 172.30.xxx
          endpoints:
            - address: 172.xxx
              ports:
                http: 80
          hosts:
            - pro-qf-test
          ports:
            - name: http
              number: 80
              protocol: HTTP
          resolution: STATIC

How does service synchronization work?

Services registered in Consul are automatically synchronized to Istio as service entry resources. When a service is deleted or updated in Consul, the change is automatically synchronized to the corresponding service entry in Istio.

How to disable Consul integration?

Run the following command to delete the Consul synchronization resources.

helm uninstall se-syncer