All Products
Search
Document Center

API Gateway:Configure ApigConfig

Last Updated:Dec 02, 2026

ApigConfig is a CRD provided by the APIG Controller to manage the lifecycle of APIG gateway instances, configure Ingress listener options, and define global settings. Install and manage ApigConfig to configure features such as global instance-level IP blacklist and whitelist access control, log collection, and tracing.

ApigConfig overview

Configuration

ApigConfig is a CRD provided by the APIG Controller. The APIG Controller uses ApigConfig to manage the lifecycle and global configurations of APIG gateway instances.

Each ApigConfig corresponds to one APIG gateway instance. To use multiple APIG gateway instances, create multiple ApigConfig resources.
Except in reuse scenarios, deleting an ApigConfig cascade-deletes the corresponding APIG gateway instance.
Important

For a gateway instance created by using a CRD (ApigConfig), manage business configurations such as APIs, routes, and certificates in the CRD. You can perform operations such as scaling in the console. Do not modify the business configurations of these instances in the console. Otherwise, CRD synchronization may overwrite your changes and cause configuration conflicts.

The following sample code shows a complete ApigConfig configuration.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
  name: apig-ingress
spec:
  name: apig-ingress
  common:
    pay:
      payType: POSTPAY
    instance:
      spec: apigw.small.x1
    network:
      vSwitches:
        - "vsw-1"
        - "vsw-2"
      networkType: InternetAndIntranet # Public and internal networks. Supported only in APIG Controller v1.1.0 and later
    securityGroupType: enterprise
  global:
    tls:
      enableHardwareAcceleration: true
    ipAccessControl:
      whitelist:
        - 1.1.XX.XX
        - 2.2.XX.XX
  monitor:
    logging:
      sls:
        reuseProject: "xxx" # Leave blank to use the default Project
    tracing:
      openTelemetry:
        sampleRate: "100"
  ingress:
    local:
      ingressClass: apig
      watchNamespace: "" # An empty value watches Ingress resources in all namespaces
  gatewayAPI: # Supported only in APIG Controller v1.1.0 and later
    local:
      enable: true
      watchNamespace: "" # An empty value watches all namespaces
      gatewayClass: "" # An empty value watches every GatewayClass

Parameter

Description

Default value

name

The gateway name.

apig-ingress

common.pay.payType

The billing method.

Only pay-as-you-go is supported. If you do not configure this parameter, pay-as-you-go is used by default.

POSTPAY

common.instance.spec

The gateway instance type.

Valid values:

  • apigw.small.x1

  • apigw.small.x2

  • apigw.small.x4

  • apigw.medium.x1

  • apigw.medium.x2

  • apigw.medium.x3

  • apigw.large.x1

  • apigw.large.x2

  • apigw.large.x3

apigw.small.x1

common.network.vSwitches

The primary and standby vSwitches. List the primary vSwitch first, followed by the standby vSwitch.

Specify at least one and at most two vSwitches. If you leave this parameter empty, the vSwitch is obtained from the node where the Controller pod runs.

None

common.network.networkType

The network access type of the Cloud-native API Gateway instance.

Valid values:

Internet: public network

Intranet: internal network

InternetAndIntranet: public and internal networks

Note: InternetAndIntranet is supported only in APIG Controller v1.1.0 and later.

Internet (public network)

common.securityGroupType

The security group type.

Valid values:

  • enterprise: advanced security group

  • normal: basic security group

normal

global.tls.enableHardwareAcceleration

Specifies whether to enable TLS hardware acceleration.

This feature can significantly improve the performance of HTTPS traffic.

Enabled

global.ipAccessControl.whitelist

The global IP whitelist. This parameter cannot be configured together with the blacklist.

Not configured

global.ipAccessControl.blacklist

The global IP blacklist. This parameter cannot be configured together with the whitelist.

Not configured

monitor.logging.sls

Specifies whether to enable Simple Log Service (SLS) logging.

To enable this feature, grant the Controller the required SLS permissions.

Disabled

monitor.logging.sls.reuseProject

The SLS project to which access logs are delivered.

Valid values:

  • Empty: uses the default project, which is newly created.

  • Specified value: uses an existing project.

Empty

monitor.tracing.xTrace.sampleRate

The sample rate for XTrace tracing. Configure the value as an integer string.

Not configured

monitor.tracing.openTelemetry

Specifies whether to enable OpenTelemetry tracing.

Disabled by default. Do not configure this parameter together with XTrace. If both are configured, OpenTelemetry takes precedence.

monitor.tracing.openTelemetry.sampleRate

The sample rate for OpenTelemetry tracing. Configure the value as an integer string.

Not configured

ingress.local.ingressClass

The APIG gateway listens for Ingress resources under the specified IngressClass in the cluster.

Valid values:

Not configured: listens for Ingress resources whose IngressClass is apig.

Empty string: listens for all Ingress resources.

nginx: listens for Ingress resources whose IngressClass is nginx or that are not associated with any IngressClass.

Other values: listens for Ingress resources of the specified IngressClass.

Note: Associating an ApigConfig through an IngressClass resource takes precedence.

apig

ingress.local.watchNamespace

The namespaces in the cluster whose Ingress resources the APIG gateway listens for.

Valid values:

  • Empty: listens to all namespaces.

  • Specified value: listens to the specified namespace. Only one namespace can be specified.

Empty

monitor.tracing.xTrace

Specifies whether to enable XTrace tracing.

Disabled by default. Do not configure this parameter together with OpenTelemetry. If both are configured, OpenTelemetry takes precedence.

gatewayAPI.local.enable

Specifies whether to listen for Gateway API resources in the cluster where the Controller runs.

Note: Gateway API listening is supported only in APIG Controller v1.1.0 and later.

false (disabled)

gatewayAPI.local.watchNamespace

The namespace in which Gateway API resources are watched. Only one namespace can be specified.

Empty, which means all namespaces are watched.

gatewayAPI.local.gatewayClass

The GatewayClass to watch. Only one GatewayClass can be specified.

Empty, which means all GatewayClasses are watched.

Status

After you create an ApigConfig resource, you can run kubectl get ApigConfig to view the resource status. ApigConfig transitions through these states in order: Pending > Running > Listening. The following list describes each state:

  • Pending: The APIG gateway is being created. Wait about 3 minutes.

  • Running: The APIG gateway is created and is running.

  • Listening: The APIG gateway is running and listens for Ingress resources in the cluster.

  • Failed: The APIG gateway is in an invalid state. Check the Message in the Status field to identify the cause.

Tags

APIG gateway instances created or reused through ApigConfig are assigned resource tags. You can view the tag information of a gateway in Basic Information on the APIG console.

Important

Do not edit the tags listed in the following table in the APIG gateway console. Otherwise, your gateway instance may be affected.

Tag

Description

ack.aliyun.com

The ingress traffic of the Container Service for Kubernetes (ACK) cluster that the APIG gateway manages.

ingress.k8s.alibaba/ApigConfig

Associates the APIG gateway with the ApigConfig.

kubernetes.reused.by.user

Indicates whether the APIG gateway is in a reuse scenario. In a reuse scenario, the APIG gateway instance is not deleted when the associated ApigConfig is deleted.

Create an APIG gateway instance

  1. Configure ApigConfig.

    The following sample code creates an APIG gateway instance named apig-ingress with 3 replicas and an instance type of 2c4g. You can modify other ApigConfig settings as needed.

    apiVersion: apig.alibabacloud.com/v1alpha1
    kind: ApigConfig
    metadata:
      name: apig-ingress
    spec:
      name: apig-ingress
      common:
        instance:
          spec: apigw.small.x1
  2. In your Container Service for Kubernetes (ACK) cluster, create an IngressClass resource and associate it with the ApigConfig by using spec.parameters to declare an Ingress processor in the cluster.

    After the configuration takes effect, the APIG gateway instance associated with the preceding ApigConfig processes and enforces the Ingress resources in the cluster that are associated with this IngressClass.

    apiVersion: networking.k8s.io/v1
    kind: IngressClass
    metadata:
      name: apig
    spec:
      controller: apig.alibabacloud.com/ingress
      parameters:
        apiGroup: apig.alibabacloud.com
        kind: ApigConfig
        name: apig-ingress

Reuse an existing APIG gateway instance

To reuse an existing APIG gateway instance, use spec.id to specify the unique ID of the gateway instance when you create the ApigConfig. The ID is in the gw-xxx format. Use the spec.override parameter to control whether the ApigConfig overwrites the configurations of the reused APIG gateway instance.

The following sample code uses ApigConfig to reuse an existing APIG gateway instance, associate the gateway instance with a container cluster, and listen for Ingress resources whose ingressClass is apig in that cluster.

Important
  • In the following configuration, spec.override is set to false, which means that the Ingress listener options and global configurations of the existing APIG gateway are not overwritten. If the existing gateway instance is not associated with the container cluster, the instance is automatically associated with the cluster. Its Ingress listener options are then set to listen for Ingress resources in the cluster whose ingressClass matches the value of spec.ingress.local.ingressClass (apig in this example). If the existing gateway instance is already associated with the container cluster, its original Ingress listener options are not overwritten.

  • To overwrite the Ingress listener options and global configurations of an existing APIG gateway, first verify the gateway parameter settings in the ApigConfig (Ingress listener options, hardware acceleration, global blacklists and whitelists, and observability), and then enable spec.override. If these configurations are not specified in the ApigConfig, enabling spec.override overwrites the original gateway parameter settings (Ingress listener options, hardware acceleration, global blacklists and whitelists, and observability), which may affect traffic.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
  name: reuse
spec:
  id: gw-xxxx
  override: false
  ingress:
    local:
      ingressClass: apig

Parameter

Description

spec.id

The ID of the target APIG gateway instance to reuse. The ID starts with gw-.

spec.override

Specifies whether to overwrite the configurations of the reused APIG gateway instance based on the ApigConfig.

  • Set to true: overwrites the original gateway parameter settings (Ingress listener options, hardware acceleration, global blacklists and whitelists, and observability)

  • Set to false: the original gateway parameter settings (Ingress listener options, hardware acceleration, global blacklists and whitelists, and observability) are not overwritten. However, if the existing gateway instance is not associated with the container cluster, the instance is automatically associated with the cluster. Its Ingress listener options are then set to listen for Ingress resources in the cluster whose ingressClass matches the value of spec.ingress.local.ingressClass.

Delete an APIG gateway instance

Each ApigConfig corresponds to one APIG gateway instance. Except in reuse scenarios, deleting an ApigConfig cascade-deletes the corresponding APIG gateway instance.

The following table describes the deletion policy.

Gateway billing method

Automatically created by APIG Controller

Reused gateway purchased in the console

Pay-as-you-go

Deleting the ApigConfig automatically deletes the gateway instance.

Deleting the ApigConfig retains the gateway instance.

Run the following command to delete the ApigConfig:

kubectl delete ApigConfig your-config-name

Configure global instance-level IP access control

Configure an IP whitelist

Configure a global instance-level IP whitelist to allow only specified source IP addresses to access the APIG Ingress.

The following sample code configures the APIG Ingress gateway instance to allow access only from the source IP address 1.1.XX.XX or the CIDR block 2.0.XX.XX/8.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
   name: apig-ingress
spec:
   ...
  global:
    ipAccessControl:
      whitelist:
      - 1.1.XX.XX
      - 2.0.XX.XX/8
   ...

Configure an IP blacklist

Configure a global instance-level IP blacklist to deny specified source IP addresses access to the APIG Ingress.

The following sample code configures the APIG Ingress gateway instance to deny access from the source IP address 1.1.XX.XX or the CIDR block 2.0.XX.XX/8.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
   name: apig-ingress
spec:
   ...
  global:
    ipAccessControl:
      blacklist:
      - 1.1.XX.XX
      - 2.0.XX.XX/8
   ...

Enable SLS logging

Before you enable SLS logging, see Authorize the APIG controller.

The following sample code configures the APIG Ingress gateway to deliver access logs to an SLS project named demo.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
   name: apig-ingress
spec:
   ...
  monitor:
    logging:
      sls:
        # Configure reuseProject to enable Simple Log Service. To use the default Project, leave this field blank.
        reuseProject: "demo"
    ...

Enable OpenTelemetry tracing

Configure the Alibaba Cloud OpenTelemetry tracing service for the gateway to build an end-to-end full-link tracing and monitoring system. This helps you quickly diagnose and locate issues in production.

The following sample code configures OpenTelemetry tracing for the APIG Ingress gateway, with a sample rate (sampleRate) of 100%.

apiVersion: apig.alibabacloud.com/v1alpha1
kind: ApigConfig
metadata:
   name: apig-ingress
spec:
   ...
  monitor:
    tracing:
      openTelemetry:
        sampleRate: "100"
   ...

Additional configurations

The gateway instance used by APIG Ingress supports the following additional settings.

To use these settings, log on to the Cloud-native API Gateway console. On Cloud-native API Gateway > Instance, find the existing or automatically created gateway instance used by the APIG Controller, click the instance ID, and then click Parameters in the left-side navigation pane.

Configuration item

Type

Description

EnableGenerateRequestId

Bool

Applies to the request scope. Generates a requestId in the request header based on the configuration so that requests can be traced.

EnableGzip

Bool

Applies to requests and responses. Enabling gzip compresses requests and responses, which reduces gateway traffic and increases gateway CPU consumption.

EnableSlashMerge

Bool

Applies to requests. Specifies whether to merge redundant '/' After this option is enabled, in www.a.com//b, the redundant '/' characters are merged, so that the path is the same as www.a.com/b.

DownstreamConnectionBufferLimits

Int

Applies to gateway connections. The buffer size of a single connection. This setting affects throughput and gateway memory usage.

Value range: [0, 2147483647].

XffTrustedNum

Int

Applies to requests. The number of trusted proxies in front of the gateway. This setting affects whether the gateway uses request headers generated by the client, such as x-forwarded-for and x-request-id.

Value range: [0, 10]. Unit: items.

DownstreamHttp2MaxConcurrentStream

Int

Applies to requests. The maximum number of concurrent streams on a single connection when the client uses HTTP/2.

Value range: [0, 2147483647]. Unit: bytes.

InitialStreamWindowSize

Int

Applies to requests. The initial stream window size negotiated between the gateway and the client when HTTP/2 is used.

Value range: [65535, 2147483647]. Unit: bytes.

InitialConnectionWindowSize

Int

Applies to requests. The connection-level initial window size between the gateway and the client when HTTP/2 is used.

Value range: [65535, 2147483647]. Unit: bytes.

EnableHttp3

Bool

Specifies whether to support the HTTP/3 protocol.

HTTP/3 is incompatible with hardware acceleration. Disable hardware acceleration before you enable HTTP/3 support.

PathWithEscapedSlashes

String

Determines the action to take for requests whose URI paths contain escaped characters such as %2F, %2f, %5C, or %5c. Default value: KEEP_UNCHANGED, which keeps the path unchanged.

Valid values: KEEP_UNCHANGED, REJECT_REQUEST, UNESCAPE_AND_REDIRECT, and UNESCAPE_AND_FORWARD.

ZipAlgorithm

List<String>

The algorithm used after compression is enabled. If EnableGzip is not enabled, the EnableGzip option is automatically enabled.

Valid values: brotli and gzip.

EnableProxyProtocol

Bool

Specifies whether to enable the Proxy protocol. If gateway ingress traffic is routed through an NLB, the real client IP address cannot be obtained unless this option is enabled. Enabling this option does not affect requests that do not use the Proxy protocol.

EnableCustomAuthConfigPush

Bool

Applies to scenarios in which a self-managed authorization service is used. After this option is enabled, changes to authorization rules do not interrupt connections. This option is suitable for WebSocket and online business scenarios.

KeepaliveHeaderTimeout

Int

Used to generate the Keep-Alive response header that is returned to the client to indicate the keep-alive duration of the connection. For example, if this parameter is set to 10, the response header keep-alive: timeout=10 is returned. If this parameter is set to 0, this response header is not returned.

Valid values: [0, 600]. Unit: seconds.

WebsocketTermGracePeriod

Int

The keep-alive duration maintained for WebSocket connections when the gateway instance must close connections, such as during upgrades or restarts.

Value range: [20, 900]. Unit: seconds.

EnableGzipHardwareAccelerate

Bool

Performs Gzip compression by using dedicated hardware. After this feature is enabled, requests and responses are compressed, which significantly reduces gateway traffic. Compared with software-based Gzip, hardware acceleration delivers higher performance and lower CPU consumption. Gzip hardware acceleration is available in the China (Hangzhou), China (Beijing), China (Shanghai), China (Shenzhen), and Singapore regions. In unsupported regions, or if you did not enable Gzip hardware acceleration when you purchased the instance, the gateway instance cannot enable this feature. After this feature is enabled, EnableGzip and ZipAlgorithm do not take effect.

EnableK8sSourceWorkloadFilter

Bool

Filters Ingress, Service, and Pod resources based on specified labels when you add a service source. Inverse filtering is supported.

FAQ

What do I do if the endpoint is empty after I delete and re-create an APIG Ingress?

If you delete an Ingress and re-create it by using the same YAML file, and the endpoint remains empty after a long wait, the Ingress listener options are usually not configured in the ApigConfig. As a result, the APIG gateway does not listen for the Ingress resource. Troubleshoot the issue as follows:

  1. Check whether spec.ingress.local.ingressClass is configured in the ApigConfig. If it is not configured, the APIG gateway does not listen for any Ingress resources, and the endpoint is not restored after you re-create the Ingress. Set this field to apig.

  2. Make sure that the IngressClass of the Ingress matches the ingress.local.ingressClass value of the ApigConfig. You can specify the IngressClass of an Ingress by using the kubernetes.io/ingress.class: apig annotation or the spec.ingressClassName field.

  3. Run the kubectl get apigconfig command to check whether the status of the ApigConfig is Listening.

  4. You do not need to re-create the APIG gateway instance. After the preceding configurations are correct, re-create the Ingress and the endpoint is automatically restored.