Create an HTTP API

更新时间:
复制 MD 格式

HTTP APIs use the HTTP protocol to quickly expose internal services in a distributed system. This topic describes how to create an HTTP API in the console.

Use cases

These methods are suitable for the following use cases:

Create an API within an instance

  • Dedicated resource management: The API manages resources or internal logic exclusively for a specific instance.

  • Security and isolation: Data or capabilities require strict security isolation and can be invoked only from within the instance.

  • Simplified configuration: This method simplifies API configuration and management within a specific instance.

Create an API outside an instance

  • Cross-instance sharing: Multiple instances can share the same API definition.

  • Centralized management and monitoring: Provides unified access control, logging, and traffic management.

Important
  • APIs created within an instance are visible and can be managed only in that instance.

  • APIs created outside an instance cannot be edited or deleted within an instance. You must manage them from the external API list.

Create an HTTP API in the console

  1. You can create an API in Cloud-native API Gateway in two ways:

    External API

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose API. In the top menu bar, select a region.

    2. Click Create API, and then click Create on the HTTP API card.

    In-instance API

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose Instance. In the top menu bar, select a region.

    2. On the Instance page, click the ID of the target gateway instance. In the navigation pane on the left, choose API. In the upper-right corner, click Create API.

    3. Click Create on the HTTP API card.

  2. In the Create REST API panel, configure the parameters and click OK.

    Configuration item

    Description

    API Name

    A custom name for the API. The API name must be globally unique.

    Description

    Enter a description for the API.

    resource

    Select the target resource group. You can click Create Resource Group on the right.

Create an HTTP API by importing an Ingress

Prerequisites

You must create a Container Service source in Cloud-native API Gateway. For more information, see Manage service sources.

Procedure

  1. You can create an API in Cloud-native API Gateway in two ways:

    Outside an instance

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose API. In the top menu bar, select a region.

    2. Click Create API, and then click Import Ingress on the HTTP API card.

    In-instance API

    1. Log on to the Cloud-native API Gateway console. In the navigation pane on the left, choose Instance. In the top menu bar, select a region.

    2. On the Instance page, click the ID of the target gateway instance. In the navigation pane on the left, choose API. In the upper-right corner, click Create API.

    3. Click Import Ingress on the HTTP API card.

  2. In the HTTP API section, click Import Ingress. On the Import Ingress page, configure the Ingress parameters and click OK.

    Configuration item

    Description

    API Name

    The name of the API. You can also click Add Description to add a description for the routing.

    Description

    The description of the API. It can be up to 255 characters long.

    Instance

    Select the Cloud-native API Gateway instance.

    Source Cluster

    The service source is the container service cluster where the Ingress resides.

    resource

    Select the resource group.

    Namespace

    The namespace to listen to. If you leave this empty, the gateway listens to Ingress resources in all namespaces.

    IngressClass

    The IngressClass to listen to. If you leave this empty, the gateway listens to all types of Ingress resources.

    Update Ingress Status

    If you enable this feature, the Status Endpoint in the listened Ingress is replaced with the gateway's entry endpoint.