To ensure communication security in public networks, HTTPS is typically used for communication when services are exposed to public networks through Ingresses. This topic introduces how to configure HTTPS certificates for ALB Ingress.
Certificate categories
Based on the effective scopes of certificates, ALB supports the following certificate types.
Based on the certificate sources, ALB supports the following certificate types.
Certificate configuration
The following Kubernetes resources are involved when configuring ALB Ingress for a VKE cluster.
ALB Ingress supports the following certificate configuration methods, with differences and use cases shown below.
warning
To use certificates from Certificate Center, log in to the Volcano Engine console with your account, click Service authorization, and on the page that appears, click Authorize now to complete cross-service authorization. Certificates for ALB instances are configured at the listener level. Both Ingresses and ALBInstances can specify certificates for a listener. Therefore, a single listener may be associated with one ALBInstance and multiple Ingresses simultaneously. Certificates configured on these associated resources may differ. When multiple resources have certificates with conflicts, VKE selects the one with the latest expiration date.
For example, assume that the ALB instance has a listener on port 80; Ingress-A, Ingress-B, and Ingress-C use certificates A, B, and C, respectively; and ALBInstance uses certificate D. If certificate C has the most distant expiration date, VKE associates certificate C with the ALB instance.
To prevent traffic interruption caused by accidental certificate modification/deletion, VKE provides special handling for the following scenarios.
Hash-based security protection
Certificate deletion protection
In addition to adding certificates to the ALB when configuring ALB Ingress or ALBInstance, users sometimes directly change the certificates associated with the listener of the corresponding ALB instance in the ALB console. During reconciliation, the alb-ingress-controller may overwrite certificates added or changed manually in the ALB console based on ALB Ingress/ALBInstance configurations. To avoid that, it uses the certificate Hash value as additional protection. If the Hash value remains unchanged, the controller does not actively change the ALB certificate configuration. The following table lists main scenarios and provides examples.
When the domain name is still used in any forwarding rules, the certificate will not be deleted. For example:
- When creating an ALB Ingress, an extension certificate is configured for example.com. In this case, the certificates associated with the ALB include the default certificate and the extension certificate corresponding to example.com. The sample code is as follows:
- When the certificate configured on the ALB Ingress is deleted but the forwarding rules for example.com are not, the alb-ingress-controller skips deleting the extension certificate corresponding to example.com. This can prevent accidental certificate deletion that could impact traffic. Only after the forwarding rules for example.com are deleted will the alb-ingress-controller delete the extension certificate for the domain. The sample code is as follows:
Default certificates vs extension certificates
When creating an Ingress, use a Secret to specify the default or extension certificate, as shown in the example below.
Configure a default certificate or an extension certificate by using an ALBInstance. The following content provides an example:
Use the Secret that contains the certificate ID
You can provide the certificate ID in the Secret, and then associate the Secret with the Ingress that you want to create. The example is as follows:
tip
You can use the echo -n "$(cert)" | base64 command to Base64-encode the certificate ID and source. Replace $(cert) with your actual value. For example, if $(cert) is cert_center, the encoding command is echo -n "cert_center" | base64. The encoded value is Y2VydF9jZW50ZXI=.
Using a Secret of type TLS that contains the certificate content.
You can enter the certificate content in the Secret, and then associate the Secret when configuring Ingress. The example is as follows:
Specifying a certificate ID in the ALBInstance
You can specify the certificate ID when configuring ALBInstance. The example is as follows:
Question 1: What is the difference between configuring via the console and via YAML?
The core difference is whether the certificate ID is synced to ALBInstance.
- Configuring via the console: The certificate ID is automatically synced to ALBInstance. When a certificate is removed, the ID is also removed from ALBInstance.
- Configuring via YAML: The certificate ID is not synced to ALBInstance. When a certificate is removed, the ID is not removed from ALBInstance.
Question 2: After an extension certificate is removed in the console, it remains bound to the ALB.
Two possible causes for this issue. Handle it based on the actual situation.
- Possible cause: Ingress still has forwarding rules using this certificate, so the alb-ingress-controller skips deletion.
- Solution: After confirming the certificate is no longer in use, manually delete it in the ALB console.
- Possible cause: ALBInstance has been edited via YAML and still has the extension certificate ID recorded.
- Solution: After confirming the certificate is no longer in use, edit ALBInstance to remove the ID.
Question 3: The console shows "Certificate does not meet expectations."
Two possible causes for this issue. Handle it based on the actual situation.
- Possible cause: The certificate for the corresponding listener was changed directly in the ALB console, causing a mismatch between the certificate actually in effect on the ALB and the Kubernetes resource records.
- Solution: We recommend always binding ALB Ingress certificates on the VKE, and avoiding changing them directly in the ALB console.
- Possible cause: Multiple ALB Ingresses are associated with the same ALB instance, and the certificates configured on different Ingresses conflict with each other. In this case, the alb-ingress-controller automatically selects the certificate with the most distant expiration date and applies it to the ALB instance. The certificate configurations on other Ingresses are not adopted, hence the "Certificate does not meet expectations" message.
- Solution: When multiple ALB Ingresses share the same ALB instance, ensure that the certificates configured on each Ingress are consistent.
Unify the configuration channel and avoid mixing methods.
We recommend using the same method (console or YAML) throughout the certificate management process. Avoid mixing the two channels, as this may lead to inconsistent certificate status.
Configure certificates via the console
Follow the console page guidance to complete certificate configuration, and adhere to the following principles:
- The default certificates of multiple Ingresses should be consistent.
- Each Ingress manages its own extension domains and certificates.
The example is as follows:
Configure certificates via YAML
Choose the corresponding configuration path based on how the certificates are managed:
- Already have a certificate ID: We recommend configuring the certificate ID uniformly on the ALBInstance.
- Manage certificates (including crt, key, etc.) by yourself using components such as cert-manager: We recommend configuring TLS Secrets on the Ingress.