Manage Ingress gateway routes using the saectl tool

更新时间:
复制 MD 格式

SAE gateway routes map to the Ingress resource type in Kubernetes. This topic covers how to create, view, update, and delete gateway routes using saectl, with sample YAML configuration files.

Prerequisites

Before you begin, make sure you have:

  • The saectl tool installed and configured with your AccessKey ID, AccessKey secret, and the region where your application is deployed. For setup instructions, see Install and configure the saectl tool

Create a gateway route

  1. Create a configuration file named ingress.yaml. The following example shows a complete configuration with inline comments explaining each field. For the full list of supported fields, see YAML configuration reference.

    apiVersion: networking.k8s.io/v1
    kind: Ingress
    metadata:
      annotations:
        sae.aliyun.com/description: test-ingress           # Alias for the routing rule
        sae.aliyun.com/idle-timeout: "15"                  # Idle connection timeout, in seconds
        sae.aliyun.com/request-timeout: "60"               # Request timeout, in seconds
        sae.aliyun.com/loadbalancer-id: alb-4iceqaf9jtq0ic7xxx  # SLB ID
        sae.aliyun.com/loadbalancer-port: "443"            # SLB listening port
        sae.aliyun.com/loadbalancer-protocol: HTTPS        # Valid values: HTTP, HTTPS
        sae.aliyun.com/loadbalancer-type: alb              # Valid values: clb, alb
        sae.aliyun.com/loadbalancer-cert-ids: 15408xxx-cn-shenzhen  # Required for HTTPS
        sae.aliyun.com/rule-actions: '{"/sys/(.*)/(.*)/aaa":"[{\"actionType\":\"redirect\",\"actionConfig\":\"{\\\"protocol\\\":\\\"${protocol}\\\",\\\"host\\\":\\\"${host}\\\",\\\"port\\\":\\\"${port}\\\",\\\"path\\\":\\\"/${1}\\\",\\\"query\\\":\\\"${query}\\\",\\\"httpCode\\\":\\\"301\\\"}\"}]"}'
      name: alb-4iceqaf9jtq0ic7xxx-443  # Format: <SLB ID>-<listening port>
      namespace: default
    spec:
      defaultBackend:           # Default forwarding rule
        service:
          name: test-app-1      # Backend application for the default rule
          port:
            number: 8080        # Container port for the default rule
      rules:                    # Custom forwarding rules
      - host: test.xxx.com
        http:
          paths:
          - backend:
              service:
                name: test-app-2  # Backend application for this path
                port:
                  number: 9000    # Container port for this path
            path: /
            pathType: ImplementationSpecific
          - backend:            # Redirect rule — the default value of backend.service.name is dummyRule
              service:
                name: dummyRule
                port:
                  number: 8080
            path: /sys/(.*)/(.*)/aaa
            pathType: ImplementationSpecific
  2. From the directory containing ingress.yaml, run the following command:

    saectl apply -f ingress.yaml

View gateway routes

Run the following command to list gateway routes:

saectl get ingress <ingress-name> -n <namespace>
  • <ingress-name>: Name of the gateway route. Omit this to list all gateway routes in scope.

  • <namespace>: Namespace ID. Defaults to the default namespace if -n is not specified.

The output contains the following fields:

FieldDescription
NAMESPACENamespace where the gateway route resides
NAMEStatic identifier in the format <SLB ID>-<port>
TYPESLB type
DESCRIPTIONAlias of the routing rule
HOSTSDomain names
PORTSPorts
AGEHow long the gateway route has existed

View gateway route details

Use either the get or describe command to inspect the full configuration of a gateway route.

Using `get`:

saectl get ingress <ingress-name> -o yaml -n <namespace>
# Replace -o yaml with -o json to get JSON output

Using `describe`:

saectl describe ingress <ingress-name> -n <namespace>

In both commands, <ingress-name> is the name of the gateway route and <namespace> is the namespace ID. Defaults to the default namespace if -n is not specified.

Update a gateway route

Edit inline

  1. Open the gateway route configuration in your editor:

    saectl edit ingress <ingress-name> -n <namespace>
  2. Modify the configuration, then save and close the file. The changes take effect automatically.

  3. To confirm the update was applied, run:

    saectl describe ingress <ingress-name> -n <namespace>

Apply from a file

Modify ingress.yaml, then run:

saectl apply -f ingress.yaml

Delete a gateway route

saectl delete ingress <ingress-name> -n <namespace>
  • <ingress-name>: Name of the gateway route.

  • <namespace>: Namespace ID. Defaults to the default namespace if -n is not specified.

YAML configuration reference

The following table describes the Kubernetes YAML configuration fields for SAE gateway routes. Fields marked Required must be specified when creating a gateway route. Fields marked Immutable cannot be changed after creation.

Identity and routing

FieldTypeRequiredImmutableDescription
metadata.nameStringYesYesName of the gateway route. Format: <SLB ID>-<SLB listening port>. Example: alb-4iceqaf9jtq0ic7xxx-443.
metadata.namespaceStringYesNamespace where the gateway route resides.

Load balancer annotations

AnnotationTypeRequiredImmutableDescription
sae.aliyun.com/loadbalancer-idStringYesYesSLB ID. Example: alb-4iceqaf9jtq0ic7xxx.
sae.aliyun.com/loadbalancer-portString (integer)YesSLB listening port. Example: "443".
sae.aliyun.com/loadbalancer-protocolStringForwarding protocol. Valid values: HTTP, HTTPS.
sae.aliyun.com/loadbalancer-typeStringYesYesLoad balancer type. Valid values: clb (Classic Load Balancer), alb (Application Load Balancer).
sae.aliyun.com/loadbalancer-cert-idsStringYes (HTTPS only)Certificate ID. Required when the forwarding protocol is HTTPS.

Behavior annotations

AnnotationTypeRequiredImmutableDescription
sae.aliyun.com/descriptionStringAlias for the routing rule.
sae.aliyun.com/idle-timeoutString (seconds)Idle connection timeout. Value is in seconds. Example: "15".
sae.aliyun.com/request-timeoutString (seconds)Request timeout. Value is in seconds. Example: "60".
sae.aliyun.com/rule-actionsString (JSON)Custom forwarding rule for redirection actions.

Forwarding rules

FieldTypeRequiredImmutableDescription
spec.defaultBackendObjectYesDefault forwarding rule applied when no custom rule matches.
spec.defaultBackend.service.nameStringYesBackend application for the default forwarding rule.
spec.defaultBackend.service.port.numberIntegerYesContainer port for the default forwarding rule.
spec.rulesArrayYesCustom forwarding rules.
spec.rules[i].hostStringYesDomain name for the custom forwarding rule.
spec.rules[i].http.paths[i].pathStringYesURL path for the custom forwarding rule. Supports regular expressions for redirect rules.
spec.rules[i].http.paths[i].pathTypeStringYesPath matching behavior. Fixed value: ImplementationSpecific. Path matching is handled by the load balancer.
spec.rules[i].http.paths[i].service.nameStringYesBackend application for this path. The default value for redirect-only paths is dummyRule.
spec.rules[i].http.paths[i].service.port.numberIntegerYesContainer port for this path.