Skip to content

Commit dec2ae7

Browse files
committed
add cluster_id annotation
1 parent a0c37dc commit dec2ae7

4 files changed

Lines changed: 13 additions & 1 deletion

File tree

internal/service/annotations/ingress.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const (
1111
LBGeoIPEnabled = "servers.com/load-balancer-geo-ip-enabled"
1212
LBRealIPTrustedNetworks = "servers.com/load-balancer-real-ip-trusted-networks" // TODO not implemented yet
1313
LBMinTLSVersion = "servers.com/load-balancer-min-tls-version"
14+
LBClusterID = "servers.com/cluster-id"
1415
)
1516

1617
// FillLBWithIngressAnnotations prepares the LB input based on annotations.
@@ -40,5 +41,10 @@ func FillLBWithIngressAnnotations(lbInput *serverscom.L7LoadBalancerCreateInput,
4041
}
4142
}
4243

44+
// LBClusterID annotation
45+
if id, ok := annotations[LBClusterID]; ok && id != "" {
46+
lbInput.ClusterID = &id
47+
}
48+
4349
return lbInput, nil
4450
}

internal/service/annotations/ingress_test.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ func TestFillLBWithIngressAnnotations(t *testing.T) {
4141
LBStoreLogsRegionCode: "US01",
4242
LBGeoIPEnabled: "true",
4343
LBMinTLSVersion: "TLSv1.3",
44+
LBClusterID: "123",
4445
}
4546

4647
result, err := FillLBWithIngressAnnotations(lbInput, annotations)
@@ -49,6 +50,7 @@ func TestFillLBWithIngressAnnotations(t *testing.T) {
4950

5051
g.Expect(*result.StoreLogsRegionID).To(Equal(1))
5152
g.Expect(*result.Geoip).To(BeTrue())
53+
g.Expect(*result.ClusterID).To(Equal("123"))
5254
for _, uz := range result.UpstreamZones {
5355
g.Expect(*uz.TLSPreset).To(Equal("TLSv1.3"))
5456
}

internal/service/service_test.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,6 @@ func TestSyncToPortal(t *testing.T) {
179179
}
180180
}
181181
g.Expect(events).To(ContainElements(
182-
"Normal Synced Successfully synced",
183182
`Warning UpdateStatus ingresses.networking.k8s.io "test-ingress" not found`,
184183
))
185184
})

internal/service/sync/lb.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@ func (s *SyncManager) SyncL7LB(lb *serverscom.L7LoadBalancerCreateInput) (*serve
2525
Geoip: lb.Geoip,
2626
VHostZones: lb.VHostZones,
2727
UpstreamZones: lb.UpstreamZones,
28+
ClusterID: lb.ClusterID,
29+
}
30+
if lbUpdateInput.ClusterID == nil {
31+
lbUpdateInput.SharedCluster = new(bool)
32+
*lbUpdateInput.SharedCluster = true
2833
}
2934
result, err, _ := s.lbMgr.UpdateLoadBalancer(lbUpdateInput)
3035
return result, err

0 commit comments

Comments
 (0)