Skip to content

Commit eee43de

Browse files
authored
add annotation for real address (kubernetes#2097)
1 parent c397cab commit eee43de

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/openstack/loadbalancer.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ const (
9393
ServiceAnnotationLoadBalancerHealthMonitorTimeout = "loadbalancer.openstack.org/health-monitor-timeout"
9494
ServiceAnnotationLoadBalancerHealthMonitorMaxRetries = "loadbalancer.openstack.org/health-monitor-max-retries"
9595
ServiceAnnotationLoadBalancerLoadbalancerHostname = "loadbalancer.openstack.org/hostname"
96+
ServiceAnnotationLoadBalancerAddress = "loadbalancer.openstack.org/load-balancer-address"
9697
// revive:disable:var-naming
9798
ServiceAnnotationTlsContainerRef = "loadbalancer.openstack.org/default-tls-container-ref"
9899
// revive:enable:var-naming
@@ -1799,11 +1800,13 @@ func (sp *servicePatcher) Patch(ctx context.Context, err error) error {
17991800
return utilerrors.NewAggregate([]error{err, perr})
18001801
}
18011802

1802-
func (lbaas *LbaasV2) updateServiceAnnotation(service *corev1.Service, annotName, annotValue string) {
1803+
func (lbaas *LbaasV2) updateServiceAnnotations(service *corev1.Service, annotations map[string]string) {
18031804
if service.ObjectMeta.Annotations == nil {
18041805
service.ObjectMeta.Annotations = map[string]string{}
18051806
}
1806-
service.ObjectMeta.Annotations[annotName] = annotValue
1807+
for key, value := range annotations {
1808+
service.ObjectMeta.Annotations[key] = value
1809+
}
18071810
}
18081811

18091812
// createLoadBalancerStatus creates the loadbalancer status from the different possible sources
@@ -1958,7 +1961,11 @@ func (lbaas *LbaasV2) ensureOctaviaLoadBalancer(ctx context.Context, clusterName
19581961
}
19591962

19601963
// Add annotation to Service and add LB name to load balancer tags.
1961-
lbaas.updateServiceAnnotation(service, ServiceAnnotationLoadBalancerID, loadbalancer.ID)
1964+
annotationUpdate := map[string]string{
1965+
ServiceAnnotationLoadBalancerID: loadbalancer.ID,
1966+
ServiceAnnotationLoadBalancerAddress: addr,
1967+
}
1968+
lbaas.updateServiceAnnotations(service, annotationUpdate)
19621969
if svcConf.supportLBTags {
19631970
lbTags := loadbalancer.Tags
19641971
if !cpoutil.Contains(lbTags, lbName) {

0 commit comments

Comments
 (0)