All Products
Search
Document Center

Microservices Engine:Access applications in an ACK cluster by using a cloud-native gateway

Last Updated:Sep 27, 2024

Cloud-native gateways are seamlessly integrated with the service discovery feature of Alibaba Cloud Container Service for Kubernetes (ACK). This allows you to easily publish applications deployed in an ACK cluster by using the cloud-native gateways. This way, you can efficiently and securely expose services. In this topic, an application that is deployed in an ACK cluster is used as an example to help you get started with cloud-native gateways.

Prerequisites

  • An ACK cluster is created. A deployment and a related service are deployed in the cluster. For more information about how to create an ACK cluster, see Create an ACK managed cluster.

  • If no suitable deployment and service are available, you must deploy a deployment named httpbin and a service named httpbin based on the following YAML code. For more information about how to deploy a deployment and a service, see Create a stateless application by using a Deployment.

    Show YAML code

    apiVersion: apps/v1
    kind: Deployment
    metadata:
      name: httpbin
      namespace: default
    spec:
      replicas: 1
      selector:
        matchLabels:
          app: httpbin
      template:
        metadata:
          labels:
            app: httpbin
            version: v1
        spec:
          containers:
            - image: registry.cn-hangzhou.aliyuncs.com/mse-ingress/go-httpbin
              args:
                - "--version=v1"
              imagePullPolicy: Always
              name: httpbin
    ---
    apiVersion: v1
    kind: Service
    metadata:
      name: httpbin
      namespace: default
    spec:
      ports:
        - port: 8080
          protocol: TCP
      selector:
        app: httpbin

Procedure

You can perform the following steps to directly deploy applications in an ACK cluster by using a cloud-native gateway:

  1. Create a cloud-native gateway.

    Create a cloud-native gateway in the same region where your ACK cluster resides.

  2. Create a route.

    Create a routing policy and associate the routing policy with a service and a service source.

  3. Debug the route.

    Debug the route by using the route debugging feature.

Step 1: Create a cloud-native gateway

Note

If a cloud-native gateway is available in the region where your ACK cluster resides, skip this step.

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the upper-left corner of the Gateways page, click Create Gateway.

    image

  3. On the buy page, select the region where your ACK cluster resides and select the virtual private cloud (VPC) in which your ACK cluster is deployed. Set Network Type to Internet and click Buy Now.

    image

    Note

    The system may require 2 to 3 minutes to create the cloud-native gateway.

Step 2: Create a route

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click the Routes tab. On the Routes tab, click Add Route.

  4. On the Add Route page, configure the Routing Rule Name parameter. Select * from the Domain name drop-down list. In the Path section, select Prefix from the drop-down list and enter / in the field. Select Single Service for the Route Point parameter. Then, click Associate Service in the Service Name drop-down list.

    image

  5. In the Associate Service panel, set Source Type to Container Service, select the name of your ACK cluster for Service Source, select the applications in your ACK cluster that you want to expose in the service list, such as httpbin, and then click OK.

    image

  6. Select httpbin from the Service Name drop-down list. Click Save and Advertise.

Note
  • When you create a route, you can create a domain name and associate the domain name with the route. For more information, see Create a domain name.

  • Cloud-native gateways are seamlessly integrated with container services and microservice systems, and support multiple service discovery methods, such as service discovery based on Kubernetes, MSE Nacos, or Enterprise Distributed Application Service (EDAS). For more information, see Add a service source.

Step 3: Debug the route

  1. Log on to the MSE console. In the top navigation bar, select a region.

  2. In the left-side navigation pane, choose Cloud-native Gateway > Gateways. On the Gateways page, click the name of the gateway.

  3. In the left-side navigation pane, click Routes, and click the Routes tab.

  4. On the Routes tab, click Debug in the Actions column of the httpbin-demo route.

    On the page that appears, enter version for the API parameter and click Send. The following figure shows the result that is returned.

    image

References