Add support to update the loadbalancer rule when source cidr list is updated #86
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:
service.beta.kubernetes.io/cloudstack-load-balancer-source-cidrsannotation 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]getCIDRListhelper 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:
semverlibrary, storing it in theCSCloudstruct for use in feature gating. (cloudstack.go) [1] [2] [3] [4]Load Balancer Rule Management Improvements:
checkLoadBalancerRuleto 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 helpersetsEqualfor comparing CIDR lists. (cloudstack_loadbalancer.go)EnsureLoadBalancerand 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:
github.com/blang/semver/v4as a dependency for semantic version parsing and comparison. (cloudstack.go,cloudstack_loadbalancer.go) [1] [2]