vishesh92 opened a new pull request, #82:
URL: https://github.com/apache/cloudstack-kubernetes-provider/pull/82

   Fixes https://github.com/apache/cloudstack-kubernetes-provider/issues/51
   
   <details><summary>Details</summary>
   <p>
   
   This pull request introduces enhancements to the CloudStack cloud provider 
for Kubernetes, focusing on better management and tracking of load balancer IP 
addresses associated by the controller. The main improvements are the addition 
of a service annotation to track controller-associated IPs, logic to set and 
use this annotation, and safer handling of public IP allocation and release.
   
   **Enhancements to load balancer IP management:**
   
   * Added a new service annotation, 
`service.beta.kubernetes.io/cloudstack-load-balancer-ip-associated-by-controller`,
 to mark when the controller has associated a load balancer IP. This annotation 
is used to determine if the IP should be disassociated when the service is 
deleted.
   * Implemented the `setServiceAnnotation` method in `cloudstack.go`, which 
uses the Kubernetes client to update service annotations, ensuring that the 
annotation is set when the controller associates an IP.
   * Modified the load balancer lifecycle:
     - When the controller associates an IP, the annotation is set on the 
Service object.
     - On deletion, the controller checks this annotation to decide whether to 
disassociate the IP, ensuring that only controller-associated IPs are released. 
Additional checks prevent disassociation if other load balancer rules still use 
the IP.
   
   **Improvements to public IP address handling:**
   
   * Updated the logic in `getPublicIPAddress` to associate an IP if it is 
found but not yet allocated, and improved error messages for clarity. 
[[1]](diffhunk://#diff-894b1db96572f6f07b810149b1d415c3206535e20a69d57880ff92b0e3782355R548)
 
[[2]](diffhunk://#diff-894b1db96572f6f07b810149b1d415c3206535e20a69d57880ff92b0e3782355L506-R570)
   * Enhanced `associatePublicIPAddress` to set the IP address parameter if 
known and to record when the controller has associated the IP, enabling 
accurate annotation and cleanup. 
[[1]](diffhunk://#diff-894b1db96572f6f07b810149b1d415c3206535e20a69d57880ff92b0e3782355R599-R602)
 
[[2]](diffhunk://#diff-894b1db96572f6f07b810149b1d415c3206535e20a69d57880ff92b0e3782355R611)
   
   **Internal API and structure changes:**
   
   * Added a `clientBuilder` field to `CSCloud` and ensured it is set during 
initialization, enabling the provider to interact with the Kubernetes API for 
annotation management. 
[[1]](diffhunk://#diff-28b0490de1680e4f973851793115f10ce846231b5a48047805322b7bd18dcf20R59)
 
[[2]](diffhunk://#diff-28b0490de1680e4f973851793115f10ce846231b5a48047805322b7bd18dcf20R107)
 
[[3]](diffhunk://#diff-28b0490de1680e4f973851793115f10ce846231b5a48047805322b7bd18dcf20R31-R33)
   * Extended the `loadBalancer` struct to track whether the controller 
associated the IP (`ipAssociatedByController`).
   
   These changes improve the reliability and correctness of load balancer IP 
management, particularly in scenarios where IPs are dynamically allocated and 
need to be safely cleaned up.
   
   </p>
   </details>  


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to