cloudstack-kubernetes-provider icon indicating copy to clipboard operation
cloudstack-kubernetes-provider copied to clipboard

Add support to update the loadbalancer rule when source cidr list is updated

Open vishesh92 opened this issue 1 week ago • 0 comments

This requires a new cloudstack-go SDK release for it to work with ACS 4.22+

Generated summary

This pull request introduces support for specifying source CIDRs for CloudStack load balancers via a new Kubernetes service annotation, and improves load balancer rule management to handle CIDR list changes and CloudStack version compatibility. The changes also add version detection for the CloudStack management server, which is used to determine whether certain features (like updating the CIDR list) are supported.

Load Balancer Source CIDRs and Version Handling:

  • Added support for the service.beta.kubernetes.io/cloudstack-load-balancer-source-cidrs annotation to allow specifying a comma-separated list of source CIDRs for load balancers; defaults to allowing all sources if unspecified. (cloudstack_loadbalancer.go, ServiceAnnotationLoadBalancerSourceCidrs) [1] [2]
  • Introduced the getCIDRList helper to parse and validate the CIDR list from the service annotation, ensuring only valid CIDRs are accepted. (cloudstack_loadbalancer.go)

CloudStack Management Server Version Awareness:

  • Added detection of the CloudStack management server version using the semver library, storing it in the CSCloud struct for use in feature gating. (cloudstack.go) [1] [2] [3] [4]

Load Balancer Rule Management Improvements:

  • Enhanced checkLoadBalancerRule to compare the current and desired CIDR lists, and to decide whether to update or recreate the rule based on changes and the CloudStack version (since updating the CIDR list is only supported in CloudStack 4.22+). Added a helper setsEqual for comparing CIDR lists. (cloudstack_loadbalancer.go)
  • Updated EnsureLoadBalancer and related methods to pass the service and version information, enabling proper handling of CIDR list changes and version-specific logic. (cloudstack_loadbalancer.go)

Dependency Updates:

  • Added github.com/blang/semver/v4 as a dependency for semantic version parsing and comparison. (cloudstack.go, cloudstack_loadbalancer.go) [1] [2]

vishesh92 avatar Nov 26 '25 14:11 vishesh92