WIP: Application load balancer controller#3
Conversation
|
@fischerman either mark the PR as "Draft" or use "WIP" as the title. The PR will then automatically marked as WIP/Draft |
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
dergeberl
left a comment
There was a problem hiding this comment.
This is my first batch of review comments. Only had a look into the /cmd/*, /pkg/controller/* (except the tests) and the *.md files, yet. I will continue with my review for the rest.
Maybe some comments are already resolved as you also pushed during my review (I did not crosscheck again, before submitting the comments now).
| | `alb.stackit.cloud/traget-pool-tls-skip-certificate-validation`| Boolean | IngressClass, Ingress, Service | Optional | Enables TLS bridging but skips certificate validation. | | ||
| | `alb.stackit.cloud/allowed-source-ranges`| String | IngressClass | Accepts a comma-separated list of IP ranges. E.g. 10.0.0.0/24,1.2.3.4/32. If unset, all IPs are allowed. | | ||
|
|
||
| ### Known Limitations |
There was a problem hiding this comment.
Maybe we add the NodePort requirement here? Also there are limits in the amount of resources (like listeners) which we should add here (or somewhere else).
There was a problem hiding this comment.
The limits like listeners, targetpools and path should also be documented. I remeber you having a list what the limits. We should also document how the this translate to ingress objects, like for the listeners it is the ports.
| ### Limits | ||
|
|
||
| The following limitations are imposed directly by the STACKIT ALB API (not the controller itself): | ||
| - Maximum targets per pool: An individual target pool can contain a maximum of 250 targets. |
|
|
||
| #### When to watch out for the listener limit | ||
|
|
||
| Because each IngressClass provisions a dedicated ALB instance, hitting the 20-listener threshold is rarely an issue for a basic setup but becomes a real risk when you start stacking custom ports across multiple applications sharing that same ALB. If your Ingress resources use the `alb.stackit.cloud/http-port` or `alb.stackit.cloud/https-port` annotations to expose different apps on unique custom port numbers, each distinctive port allocates its own listener on the shared ALB instance. This risk compounds quickly when those applications also require TLS encryption; since the controller must keep an extra HTTP listener active alongside the HTTPS listener to smoothly process automated ACME certificate challenges, a single secure app immediately consumes two slots instead of one, accelerating how fast you approach the API limit if multiple unique custom ports are configured. |
There was a problem hiding this comment.
This needs a rephrase. The ALB per ingress does not make it rarely to hit the limit (It is the default of 2 ports).
|
|
||
| A "target" in a pool corresponds directly to a worker node in your cluster. If you run a large cluster with a high number of worker nodes, or expect your cluster to dynamically scale to a large size, keep this limit in mind since a single backend Service port mapping cannot route traffic to more than 250 worker nodes simultaneously. | ||
|
|
||
| #### When to watch out for the listener limit |
There was a problem hiding this comment.
Also something for the Known Limitations.
|
|
||
| Because each IngressClass provisions a dedicated ALB instance, hitting the 20-listener threshold is rarely an issue for a basic setup but becomes a real risk when you start stacking custom ports across multiple applications sharing that same ALB. If your Ingress resources use the `alb.stackit.cloud/http-port` or `alb.stackit.cloud/https-port` annotations to expose different apps on unique custom port numbers, each distinctive port allocates its own listener on the shared ALB instance. This risk compounds quickly when those applications also require TLS encryption; since the controller must keep an extra HTTP listener active alongside the HTTPS listener to smoothly process automated ACME certificate challenges, a single secure app immediately consumes two slots instead of one, accelerating how fast you approach the API limit if multiple unique custom ports are configured. | ||
|
|
||
| ### Configuration |
There was a problem hiding this comment.
Please check that this are all, WAF seems to be missing
dergeberl
left a comment
There was a problem hiding this comment.
Comments for the stackit package and testutil
| @@ -0,0 +1,22 @@ | |||
| package stackit | |||
There was a problem hiding this comment.
Can we also add the ResponseID to the error, to be able to trace errors
We do this also in cloud-provider-stackit for the LB api see:
https://github.com/stackitcloud/cloud-provider-stackit/blob/7a0ef7fa43f1d30f6ed4f88bfa2de1312c79b62f/pkg/stackit/client/loadbalancer.go#L43
https://github.com/stackitcloud/cloud-provider-stackit/blob/7a0ef7fa43f1d30f6ed4f88bfa2de1312c79b62f/pkg/stackit/client/helper.go#L12
There was a problem hiding this comment.
I looked at a request to our API and the response does not contain the header X-Request-Id. So it is not an easy copy. I feel like this expected API behavior is a bit underspec'ed. So I wouldn't add this logic until this is properly spec'ed.
|
|
||
| if *alb.Status != stackit.LBStatusReady { | ||
| // ALB is not yet ready, requeue | ||
| return ctrl.Result{RequeueAfter: 10 * time.Second}, nil |
There was a problem hiding this comment.
Should we write an event for this? In NLB controller we inform the user about this state via event
| }) | ||
| } | ||
|
|
||
| if len(listeners) == 0 { |
There was a problem hiding this comment.
This feels weird to me. If the load balancer does not yet contain any port, we shouldn't create it at all.
| DisableTargetSecurityGroupAssignment: new(true), // TODO: Make this configurable via flag. | ||
| Name: new(fmt.Sprintf("k8s-ingress-%s", t.ingressClass.UID)), | ||
| Labels: &map[string]string{ | ||
| "ingress-class-uid": string(t.ingressClass.UID), |
There was a problem hiding this comment.
Also from a user perspective it might be useful to add a cluster name label or something likewise here, so one can easily see which alb is for which cluster.
| } | ||
| for i := range ingressClassCertificates { | ||
| cert := &ingressClassCertificates[i] | ||
| if err := r.CertificateClient.DeleteCertificate(ctx, r.ALBConfig.Global.ProjectID, r.ALBConfig.Global.Region, *cert.Id); err != nil { |
There was a problem hiding this comment.
Is this an async call? If yes we should wait until certs are gone before removing the finalizer.
| CertificateIds: []string{}, | ||
| }, | ||
| } | ||
| for fingerprint, cert := range t.certificates { |
There was a problem hiding this comment.
Map interactions are not deterministic. If I remember correctly the order in the ALB matters, as always the first match will be used. This could lead in a flapping which cert is used if multiple are fitting.
There was a problem hiding this comment.
Fixed in 5c25864
The order is stable but cannot be influenced by the customer.
| expected: true, | ||
| }, | ||
| { | ||
| name: "https certificates changed", |
There was a problem hiding this comment.
we should add the same but with also 2 Ids.
| expected: true, | ||
| }, | ||
| { | ||
| name: "target pool tls validation changed", |
There was a problem hiding this comment.
We should also add targets itself and test.
| @@ -0,0 +1,302 @@ | |||
| package ingress | |||
There was a problem hiding this comment.
In the update.go are multiple functions which also should be tested, like getServicesForIngresses, getTLSSecretsFromIngresses, getCertificatesForIngressClass. But also the logic for duplicateCerts should get tested.
| ) | ||
|
|
||
| Expect(errs).To(HaveLen(1)) | ||
| Expect(errs[0].Description).To(Equal("invalid certificate: tls: failed to find any PEM data in certificate input")) |
There was a problem hiding this comment.
Same as in test should return an error when the TLS secret isn't of type TLS
|
|
||
| tree := &WorkTreeALB{ | ||
| ingressClass: ingressClass, | ||
| planID: GetAnnotation(AnnotationPlanID, "", ingressClass), |
There was a problem hiding this comment.
Should we validate that we only get working PlanIDs. For NLBs we check that in cloud-provider-stackit
There was a problem hiding this comment.
Ties together with https://github.com/stackitcloud/application-load-balancer-controller/pull/3/changes#r3511950744
However, this does not only break an ingress but the entire ALB. Because we introduce the webhook I would just return an error here and not process any updates.
| @@ -0,0 +1,658 @@ | |||
| package spec | |||
There was a problem hiding this comment.
We should also add tests for:
theAnnotationHTTPSOnlyand that it not serves HTTP.the sorting based onAnnotationPriorityand creation timestamp.AnnotationPlanID- the handling when setting not allowed values in annotation (like no valid int/port, not valid cidr in source range)
GetUnusedCertificates
| @@ -0,0 +1,85 @@ | |||
| apiVersion: apps/v1 | |||
There was a problem hiding this comment.
We should align this with the deploy of CSI and CCM in cloud-provider-stackit (which are also not perfect, see stackitcloud/cloud-provider-stackit#1162).
For example:
- we can use also the kube-system namespace as this is also a system component like CSI and CCM
- the cloud config don't need to be a secret
- the mount path of the service account and cloud config
- the
apiEndpointsdon't need to be in the example (this is only internally needed) - lets also create a
/deployfolder instead if the/samples/deploy/ - we need to find a image tag which is working and don't need to be updated like
latest(not sure if this will be tagged on release)
There was a problem hiding this comment.
With #6 we get a latest tag for tagged versions. Lets use that in the deployment.
There was a problem hiding this comment.
I vote for latest tag here. We can leave it like it is for now and solve this directly before merging. After merge I will create a release which then also creates the latest tag
| ConditionNodeTermination corev1.NodeConditionType = "Terminating" | ||
| ) | ||
|
|
||
| func isNodeTerminating(node *corev1.Node) bool { |
There was a problem hiding this comment.
That changes also need to be added to the nodePredicate().
|
@fischerman: The following test failed, say
Full PR test history. Your PR dashboard. Command help for this repository. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here. |
How to categorize this PR?
/kind enhancement
What this PR does / why we need it:
Implements the first alpha version of the STACKIT ALB controller.
Which issue(s) this PR fixes:
Fixes #
Special notes for your reviewer:
Breaking changes: