In Kubernetes, an ingress is a resource object that controls how Services within a cluster can be accessed from outside the cluster. You can use ingresses to configure different forwarding rules to access pods in a cluster. The following uses an Nginx workload as an example to describe how to create a LoadBalancer ingress on the console.
This section uses an Nginx workload as an example to describe how to add a LoadBalancer ingress.
A load balancer can be dedicated or shared. A dedicated load balancer must be of the application type (HTTP/HTTPS) and support private networks.
You can select Use existing or Auto create to obtain a load balancer. For details about the configuration of different creation modes, see Table 1.
How to Create | Configuration |
|---|---|
Use existing | Only the load balancers in the same VPC as the cluster can be selected. If no load balancer is available, click Create Load Balancer to create one on the ELB console. |
Auto create |
|
For clusters v1.25.16-r10, v1.27.16-r10, v1.28.15-r0, v1.29.10-r0, v1.30.6-r0, v1.31.1-r0, or later, when using a dedicated load balancer, you can select a maximum of five IP address groups at a time for access control.
If there is already an HTTPS ingress for the chosen port on the load balancer, the certificate of the new HTTPS ingress must be the same as the certificate of the existing ingress. This means that a listener has only one certificate. If two certificates, each with a different ingress, are added to the same listener of the same load balancer, only the certificate added earliest takes effect on the load balancer.
For details about security policies, see Elastic Load Balance User Guide.
When the listener is HTTP-compliant, only HTTP can be selected.
If it is an HTTPS listener, this parameter can be set to HTTP or HTTPS.
Configuration | Description | Constraint |
|---|---|---|
Transfer Listener Port Number | If this function is enabled, the listening port on the load balancer can be transferred to backend servers through the HTTP header of the packet. | This function is available only for dedicated load balancers. |
Transfer Port Number in the Request | If this function is enabled, the source port of the client can be transferred to backend servers through the HTTP header of the packet. | This function is available only for dedicated load balancers. |
Rewrite X-Forwarded-Host | If this function is enabled, X-Forwarded-Host will be rewritten using the Host field in the client request header and transferred to backend servers. | This function is available only for dedicated load balancers. |
Data Compression | If this function is enabled, specific files will be compressed. If it is not enabled, files will not be compressed.
| This function is available only for dedicated load balancers. |
Idle Timeout | The duration for which a client connection can remain idle before being terminated. If there are no requests reaching the load balancer during this period, the load balancer will disconnect the connection from the client and establish a new connection when there is a new request. | This configuration is not supported if the port of a shared load balancer uses UDP. |
Request Timeout | The duration within which a request from a client must be received. There are two cases:
| This function is available only for HTTP and HTTPS listeners. |
Response Timeout | The duration within which a response from the backend server is expected. If the backend server does not respond within this period after receiving a request, the load balancer will stop waiting and return an HTTP 504 error. | This function is available only for HTTP and HTTPS listeners. |
Enable HTTP/2 | Whether to enable HTTP/2 for HTTPS requests between the client and the load balancer. Request forwarding using HTTP/2 improves access performance between your application and the load balancer. However, the load balancer still uses HTTP/1.x to forward requests to the backend server. | This function is available only when the listener is HTTPS-compliant. |
to add multiple forwarding policies.The access path added here must exist in the backend application. Otherwise, the forwarding fails.
For example, the default access URL of the Nginx application is /usr/share/nginx/html. When adding /test to the ingress forwarding policy, ensure the access URL of your Nginx application contains /usr/share/nginx/html/test. Otherwise, error 404 will be returned.
Parameter | Description |
|---|---|
Protocol | TCP, HTTP are supported.
|
Port | By default, the service port (NodePort or container port of the Service) is used for health check. You can also specify another port for health check. After the port is specified, a service port named cce-healthz will be added for the Service.
|
Check Period (s) | Specifies the maximum interval between health checks. The value ranges from 1 to 50. |
Timeout (s) | Specifies the maximum timeout for each health check. The value ranges from 1 to 50. |
Max. Retries | Specifies the maximum number of health check retries. The value ranges from 1 to 10. |
On the ELB console, you can check the load balancer automatically created through CCE. The default name is cce-lb-<ingress.UID>. Click the load balancer name to go to the details page. On the Listeners tab page, check the listener and forwarding policy of the target ingress.
After an ingress is created, upgrade and maintain the selected load balancer on the CCE console. Do not modify the configuration on the ELB console. Otherwise, the ingress service may be abnormal.
Figure 1 Accessing the /healthz interface of defaultbackend
