-
Notifications
You must be signed in to change notification settings - Fork 107
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: loadbalancer source range #611
Conversation
✅ Deploy Preview for kamaji-documentation ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
This is a feature I really want. You're a genius. I hope this PR gets merged into the release as soon as possible. Let me know if you'd like any changes! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is definitely useful, it would be great if we could have CEL validation here, as we're doing with other fields.
In the TenantControlPlaneSpec
struct something like this:
// +kubebuilder:validation:XValidation:rule="(self.controlPlane.service.serviceType != 'LoadBalancer') && size(self.networkProfile.loadBalancerSourceRanges) > 0", message="load balancer source ranges are supported only with LoadBalancer Service type"
@jds9090 may I ask you to give it a try? According to the CEL Playground it seems correct, but better having a real smoke test!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
duplicated review
@@ -229,6 +229,7 @@ func NewCmd(scheme *runtime.Scheme) *cobra.Command { | |||
}, | |||
}, | |||
handlers.TenantControlPlaneServiceCIDR{}, | |||
handlers.TenantControlPlaneLoadBalancerSourceRanges{}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're able to achieve the same result with CEL we can decrease the validation at the webhook server, and Kamaji will benefit a lot!
Thank you for the suggestion to leverage CEL for the validation logic. However, after further review, I realized that validating CIDR formats exceeds the capabilities of CEL. CEL is excellent for field existence checks, size validations, and relational comparisons but lacks the capability to handle complex logic such as network-related validation like CIDR parsing. In our case, the ability to:
it seems reasonable to implement the CIDR validation logic using a webhook. In this case, we can leverage CEL for the simpler rule enforcement—like ensuring loadBalancerSourceRanges is used only with LoadBalancer services—while delegating the actual CIDR format validation to the webhook. This approach ensures correctness while minimizing the reliance on external webhooks. If this sounds good, I’ll proceed with keeping the CIDR-specific logic to the webhook, moving only the basic checks in CEL. Is this what you meant? |
I got your point and you're right. Let's keep the handler just for the cidr validation, then, there shouldn't be any problem with CEL and custom validation. |
I changed the rule because it is not valid in my test cases.
Components of the Rule
This validation logic ensures the following:
|
dfb5b86
to
723827f
Compare
Closes #610