All Products
Search
Document Center

API Gateway:Access applications in ACK by using an HTTP API

Last Updated:Mar 13, 2025

If you have applications in a Container Service for Kubernetes (ACK) cluster and the applications are accessed over the Internet, you can use an HTTP API and a route in the Cloud-native API Gateway console for the access. This topic uses Alibaba Cloud ACK as an example to describe how to use Cloud-native API Gateway to allow external access to microservices applications.

Prerequisites

  1. An ACK cluster is created. For more information, see Create an ACK managed cluster.

  2. A microservices demo is deployed to ACK.

    Deploy a microservices demo

    Log on to the ACK console. In the left-side navigation pane, choose Clusters.

    On the Clusters page, click the cluster that you want to manage. In the left-side navigation tree of the cluster details page, choose Workloads > Deployments.

    On the Deployments page, click Create from YAML. In the Template field, enter the following code in the YAML format to create a deployment named httpbin and a service named httpbin.

    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

    On the Deployments page, click the httpbin deployment that you created. If the status of the deployment is Running, the microservices application is successfully deployed, as shown in the following figure.

    image

Process overview

First you create a Cloud-native API Gateway instance. Then, you associate a service from ACK. After that, you create a routing policy for your associated service in Cloud-native API Gateway to make the service available for access based on the routing policy.

  1. Create a Cloud-native API Gateway instance.

    In this step, you create a Cloud-native API Gateway instance based on your microservices environment.

  2. Create an HTTP API.

    In this step, you create an HTTP API in the gateway instance.

  3. Create a route.

    In this step, you configure a routing policy for your service and publish the routing policy.

    1. Add a service source.

      In this sub-step, you add a service source in Cloud-native API Gateway. In this example, ACK is used as a service source.

    2. Add a service.

      In this sub-step, you add a service. Cloud-native API Gateway can obtain namespaces from ACK and then add existing services as candidate services.

  4. Debug the route.

    In this step, you check whether the created route works as expected and adjust the route if necessary.

Step 1: Create a Cloud-native API Gateway instance

  1. Log on to the Cloud-native API Gateway console. If you are using Cloud-native API Gateway for the first time, you must perform the following operations:

    Note

    If you are accessing Cloud-native API Gateway for the first time, the system prompts you to authorize it to create a service-linked role.

    1. On the page that appears, click Authorize Now. In the dialog box that appears, click OK to create the service-linked role.

    2. Click Experience Cloud-native API Gateway Now to go to the console.

  2. In the left-side navigation pane, click Instance. In the top navigation bar, select a region. Then, click Create Instance.

    Important

    Make sure that the instance is created in the same region as the ACK cluster.

  3. On the buy page, configure the parameters and click Buy Now.

    image

  4. On the Confirm Order page, read the terms of service and click Activate Now.

    Note

    Instance creation may require two to three minutes to complete.

  5. Go back to the Instance page to check the information and status of the created instance.

    If the instance information is as expected and its status is Running, the instance is successfully created.image

Step 2: Create an HTTP API

  1. On the API page of the Cloud-native API Gateway console, click Create API.

  2. In the dialog box that appears, click Create in the HTTP API section. In the Create HTTP API panel, configure the API Name parameter as prompted.

Step 3: Create a route

  1. On the API page of the Cloud-native API Gateway console, click the API that you want to manage.

    Click Create Route. In the Create Route panel, configure the parameters.

Configure basic route information

image

  • Domain Name: You can click Add Domain Name on the right to create a domain name in the Add Domain Name panel.

  • Path: Select Prefix from the drop-down list and enter a forward slash (/) in the field to match HTTP requests that start with a /.

Select an instance and configure the backend service

Note

When you create a gateway instance, the system automatically creates a default environment and associates the environment with the instance.

  1. Select the instance created in Step 1 from the Instance drop-down list.

    image

  2. Scenarios: Select Single Service from the Scenarios drop-down list.

  3. For the Backend Services parameter, click Create Service below Service Name. image

  4. Create a service source and a service.

    1. Select ACK from the Source Type drop-down list.

    2. Click Add Source and select the cluster that you created in Prerequisites section.

    3. From the service list, select httpbin and click OK.

      image

    4. In the Backend Services configuration item, select the service created in the previous step from the Service Name drop-down list.

      image

  5. Click Save and Publish.

Step 4: Debug the route

  1. On the API page of the Cloud-native API Gateway console, click the API that you want to manage.

  2. In the route list, find httpbin-demo and click Debug in the Actions column.

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

    image

References