diff --git a/pkg/controller/constants.go b/pkg/controller/constants.go index 11abac702..f5d9b6e20 100644 --- a/pkg/controller/constants.go +++ b/pkg/controller/constants.go @@ -71,6 +71,7 @@ const ( TLSNoInsecure = "none" LBServiceIPAMLabelAnnotation = "cis.f5.com/ipamLabel" + LBServiceIPAnnotation = "cis.f5.com/ip" LBServiceHostAnnotation = "cis.f5.com/host" HealthMonitorAnnotation = "cis.f5.com/health" LBServicePolicyNameAnnotation = "cis.f5.com/policyName" diff --git a/pkg/controller/informers.go b/pkg/controller/informers.go index e58705083..fb12a59ee 100644 --- a/pkg/controller/informers.go +++ b/pkg/controller/informers.go @@ -1150,6 +1150,7 @@ func (ctlr *Controller) enqueueUpdatedService(obj, cur interface{}, clusterName } if (svc.Spec.Type != curSvc.Spec.Type && svc.Spec.Type == corev1.ServiceTypeLoadBalancer) || + (svc.Annotations[LBServiceIPAnnotation] != curSvc.Annotations[LBServiceIPAnnotation]) || (svc.Annotations[LBServiceIPAMLabelAnnotation] != curSvc.Annotations[LBServiceIPAMLabelAnnotation]) || !reflect.DeepEqual(svc.Labels, curSvc.Labels) || !reflect.DeepEqual(svc.Spec.Ports, curSvc.Spec.Ports) || !reflect.DeepEqual(svc.Spec.Selector, curSvc.Spec.Selector) { diff --git a/pkg/controller/worker.go b/pkg/controller/worker.go index 11f875888..5fc5fe225 100644 --- a/pkg/controller/worker.go +++ b/pkg/controller/worker.go @@ -2551,43 +2551,46 @@ func (ctlr *Controller) processLBServices( isSVCDeleted bool, ) error { - ipamLabel, ok := svc.Annotations[LBServiceIPAMLabelAnnotation] - if !ok { - log.Debugf("Service %v/%v does not have annotation %v, continuing.", + ip, ok1 := svc.Annotations[LBServiceIPAnnotation] + ipamLabel, ok2 := svc.Annotations[LBServiceIPAMLabelAnnotation] + if !ok1 && !ok2 { + log.Debugf("Service %v/%v does not have either of annotation: %v, annotation:%v, continuing.", svc.Namespace, svc.Name, LBServiceIPAMLabelAnnotation, + LBServiceIPAnnotation, ) return nil } - if ctlr.ipamCli == nil { - warning := "[IPAM] IPAM is not enabled, Unable to process Services of Type LoadBalancer" - log.Warningf(warning) - prometheus.ConfigurationWarnings.WithLabelValues(Service, svc.ObjectMeta.Namespace, svc.ObjectMeta.Name, warning).Set(1) - return nil - } - prometheus.ConfigurationWarnings.WithLabelValues(Service, svc.ObjectMeta.Namespace, svc.ObjectMeta.Name, "").Set(0) - svcKey := svc.Namespace + "/" + svc.Name + "_svc" - var ip string - var status int - if isSVCDeleted { - ip = ctlr.releaseIP(ipamLabel, "", svcKey) - } else { - ip, status = ctlr.requestIP(ipamLabel, "", svcKey) - - switch status { - case NotEnabled: - log.Debug("[IPAM] IPAM Custom Resource Not Available") - return nil - case InvalidInput: - log.Debugf("[IPAM] IPAM Invalid IPAM Label: %v for service: %s/%s", ipamLabel, svc.Namespace, svc.Name) - return nil - case NotRequested: - return fmt.Errorf("[IPAM] unable to make IPAM Request, will be re-requested soon") - case Requested: - log.Debugf("[IPAM] IP address requested for service: %s/%s", svc.Namespace, svc.Name) + if !ok1 { + if ctlr.ipamCli == nil { + warning := "[IPAM] IPAM is not enabled, Unable to process Services of Type LoadBalancer" + log.Warningf(warning) + prometheus.ConfigurationWarnings.WithLabelValues(Service, svc.ObjectMeta.Namespace, svc.ObjectMeta.Name, warning).Set(1) return nil } + prometheus.ConfigurationWarnings.WithLabelValues(Service, svc.ObjectMeta.Namespace, svc.ObjectMeta.Name, "").Set(0) + svcKey := svc.Namespace + "/" + svc.Name + "_svc" + var status int + if isSVCDeleted { + ip = ctlr.releaseIP(ipamLabel, "", svcKey) + } else { + ip, status = ctlr.requestIP(ipamLabel, "", svcKey) + + switch status { + case NotEnabled: + log.Debug("[IPAM] IPAM Custom Resource Not Available") + return nil + case InvalidInput: + log.Debugf("[IPAM] IPAM Invalid IPAM Label: %v for service: %s/%s", ipamLabel, svc.Namespace, svc.Name) + return nil + case NotRequested: + return fmt.Errorf("[IPAM] unable to make IPAM Request, will be re-requested soon") + case Requested: + log.Debugf("[IPAM] IP address requested for service: %s/%s", svc.Namespace, svc.Name) + return nil + } + } } if !isSVCDeleted {