You need to enable JavaScript to run this app.
Volcengine Kubernetes Engine

Volcengine Kubernetes Engine

Copy page
Download PDF
Customize ALB Ingress forwarding rules
Configuring traffic forwarding based on request methods
Copy page
Download PDF
Configuring traffic forwarding based on request methods
An ALB Ingress that uses a standard ALB instance supports configuring header-based traffic distribution policies and determining the back-end Service to forward traffic to based on different HTTP request methods.​
warning​
It is highly recommended that you first read Considerations for using ALB Ingresses carefully before getting started.​
Prerequisites​
  • The alb-ingress-controller add-on has been installed and upgraded to v0.36.0 or later. For details, see Upgrading add-ons.​
Usage limits​
This configuration is supported only when an ALB Ingress associates with a Standard edition ALB instance. For details, see Overview of ALB instance editions.​
Procedure​
Configure through the console​
  1. Log in to the VKE console.​
  1. In the left navigation bar, click Cluster.​
  1. On the cluster list page, click the target cluster for which you need to configure an Ingress.​
  1. In the left navigation bar of the cluster management page, click Services and Ingresses > Ingress. On the page that appears, click Create Ingress.​
  • Select Application Load Balancer (ALB) for Ingress type.​
  • In the Forwarding rules settings, select the Enable check box to configure custom forwarding rules.​
​
Parameter​
Description​
Forwarding conditions​
Configure forwarding conditions. In this example, select HTTP request method to forward traffic based on HTTP request methods.​
From the Request method drop-down menu, select an HTTP request method. Available HTTP request methods include GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS.​
  • Forwarding conditions can be configured individually or in combination. When multiple forwarding conditions are configured, the logical relationship between these forwarding conditions is AND. For example, if you configure both a domain name and a path in a forwarding rule, only requests that match the specified domain name and path will match this forwarding rule.​
  • Multiple values can be configured within the same forwarding condition, and these values have a logical relationship of OR. For example, if you configure multiple methods in an HTTP method-based forwarding condition, a request that uses any of the methods is considered a match for the forwarding condition.​
Forwarding actions​
Configure the forwarding action. For this example, select the Forward to option to forward requests to the target service and port.​
​
  1. Click Confirm.​
Using kubectl​
An ALB Ingress allows you to configure request header-based forwarding policies by using annotations. The following is an example YAML with comments for annotations.​
  • The {{service-name}} field in the annotation must match the name of the back-end service configured in spec.rules. For example, in this case, the correct annotation is ingress.vke.volcengine.com/loadbalancer-conditions.service-demo.​
  • The Method configuration in the annotations section and the host configuration in spec.rules will be combined. For example, in this case, requests with example.com as the host and request method GET or POST will all be forwarded to the service-demo service.​
​
apiVersion: networking.k8s.io/v1​
kind: Ingress​
metadata:​
name: alb-ingress # The custom Ingress name.​
namespace: default # Namespace of the Ingress​
annotations:​
ingress.vke.volcengine.com/loadbalancer-conditions.{{service-name}}: | # Replace {{service-name}} with the name of the service.​
[​
{​
"type": "Method",​
"methodConfig": {​
"values": [​
"GET",​
"POST"​
]​
}​
}​
]​
spec:​
ingressClassName: alb # The resource name of the ALBInstance.​
rules:​
- host: example.com​
http:​
paths:​
- pathType: Prefix​
path: / # The matching path for the request.​
backend:​
service:​
name: service-demo # The name of the service to forward requests to.​
port:​
number: 80 # The service port number to forward to.​
​
The following table describes fields in the ingress.vke.volcengine.com/loadbalancer-conditions.{{service-name}} annotation.​
​
Parameter​
Type​
Description​
Default value​
type​
String​
The forwarding policy type. In this example, the type is Method, which indicates a method-based forwarding policy.​
None​
methodConfig.value​
Array of String​
The HTTP request methods in the forwarding policy. Valid methods include GET, POST, PUT, DELETE, PATCH, HEAD, and OPTIONS.​
You can configure multiple request methods that are in a logical OR relationship.​
None​
​
Validating results​
Viewing configuration​
  1. Log in to the ALB console.​
  1. Click Instance in the left navigation bar. In the instance list, find the target ALB instance and click Listener in the Actions column.​
  1. On the listener details page, find the target listener. In the Actions column, click Edit forwarding rules to view the existing forwarding rules of the listener. Confirm that the request methods are consistent with the configured ones.​
Sending access requests for verification​
tip​
Before verification, make sure that you have deployed back-end applications and services in the cluster. In this example, an Nginx image is used and the service path is /. For deployment steps, see Using ALB Ingresses for service deployment.​
  1. Access the service by using the domain name configured in the ALB Ingress. In this example, 14.***.***.*** is the public IP address of the ALB instance.​
​
curl -X OPTIONS -H "Host: example.com" http://14.***.***.***​
​
Since an HTTP method that is not allowed was used during access, the back-end service cannot be accessed correctly.​
​
<html>​
<head><title>503 Service Temporarily Unavailable</title></head>​
<body bgcolor="white">​
<center><h1>503 Service Temporarily Unavailable</h1></center>​
</body>​
</html>​
​
  1. Run the following command again to access the service using an allowed HTTP request method.​
​
curl -X GET -H "Host: example.com" http://14.***.***.***​
​
Since an allowed HTTP request method was used, the back-end service can be accessed correctly.​
​
<!DOCTYPE html>​
<html>​
<head>​
<title>Welcome to nginx!</title>​
<style>​
html { color-scheme: light dark; }​
body { width: 35em; margin: 0 auto;​
font-family: Tahoma, Verdana, Arial, sans-serif; }​
</style>​
</head>​
<body>​
<h1>Welcome to nginx!</h1>​
<p>If you see this page, the nginx web server is successfully installed and​
working. Further configuration is required.</p>​
​
<p>For online documentation and support please refer to​
<a href="http://nginx.org/">nginx.org</a>.<br/>​
Commercial support is available at​
<a href="http://nginx.com/">nginx.com</a>.</p>​
​
<p><em>Thank you for using nginx.</em></p>​
</body>​
</html>​
​
Last updated: 2026.07.24 14:51:39