An AlbConfig object is a CustomResourceDefinition (CRD) object that Container Service for Kubernetes (ACK) provides for the Application Load Balancer (ALB) Ingress controller. The ALB Ingress controller uses AlbConfig objects to configure ALB instances and listeners. This topic describes how to create and modify an AlbConfig object, and how to use an AlbConfig object to enable Log Service.
Background information
The ALB Ingress controller retrieves the changes to Ingresses from the API server and dynamically generates AlbConfig objects when Ingresses changes are detected. Then, the ALB Ingress controller performs the following operations in sequence: create ALB instances, configure listeners, create Ingress rules, and configure backend server groups. The Service, Ingress, and AlbConfig objects interact with each other in the following ways:
- A Service is an abstraction of an application that is deployed in a group of replicated pods.
- An Ingress contains reverse proxy rules. It controls to which Services HTTP or HTTPS requests are routed. For example, an Ingress routes requests to different Services based on the hosts and URLs in the requests.
- An AlbConfig object is a CustomResourceDefinition (CRD) object that the ALB Ingress controller uses to configure ALB instances and listeners. An AlbConfig object corresponds to one ALB instance.

An AlbConfig object is used to configure an ALB instance. The ALB instance can be specified in forwarding rules of multiple Ingresses. Therefore, an AlbConfig object can be associated with multiple Ingresses.
Create an AlbConfig object
An AlbConfig object is used to configure an ALB instance. If you want to configure multiple ALB instances, you must create multiple AlbConfig objects. Perform the following steps to create an AlbConfig object:
Associate an AlbConfig object with an Ingress
You can associate an AlbConfig object with an Ingress by using an IngressClass. To do this, you must first create an IngressClass.
Change the name of an AlbConfig object
kubectl -n kube-system edit AlbConfig default
...
spec:
config:
name: test # The new name that you want to use.
...
Change the vSwitches that are specified for an AlbConfig object
kubectl -n kube-system edit AlbConfig default
...
zoneMappings:
- vSwitchId: vsw-wz92lvykqj1siwvif****
- vSwitchId: vsw-wz9mnucx78c7i6iog****
...
Enable Log Service for log collection
If you want to collect the access logs of ALB Ingresses, set the logProject
and logStore
parameters in the AlbConfig configuration.
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
name: default
spec:
config:
accessLogConfig:
logProject: "k8s-log-xz92lvykqj1siwvif****"
logStore: "alb_****"
...
alb_
. If the specified Logstore does not exist, the system automatically creates one with
the specified name.
After you save the modification to the AlbConfig configuration, you can go to the Log Service console and view the collected log in the specified Logstore.
Reuse an existing ALB instance
apiVersion: alibabacloud.com/v1
kind: AlbConfig
metadata:
name: reuse-alb
spec:
config:
id: ****
forceOverride: false # Specify whether to overwrite the existing listeners. If you set the value to true, the existing listeners are overwritten. If you set the value to false, the existing listeners are not overwritten.
Use multiple ALB instances
If you want to use multiple ALB instances, specify multiple IngressClasses in the
spec.ingressClassName
field of the Ingress configuration.
Delete an ALB instance
An AlbConfig object is used to configure an ALB instance. Therefore, you can delete an ALB instance by deleting the corresponding AlbConfig object. Before you can delete an AlbConfig object, you must delete all Ingresses that are associated with the AlbConfig object.
kubectl -n kube-system delete AlbConfig default
Replace default
with the name of the AlbConfig object that you want to delete.