feat(chart): release 1.2.6 with lb source ranges
Release Chart / release (push) Successful in 5s
deploy / build (push) Successful in 2m29s

This commit is contained in:
2026-08-04 20:30:49 +03:30
parent d2b1a21a07
commit 1a26a28876
5 changed files with 50 additions and 18 deletions
+22 -3
View File
@@ -171,9 +171,10 @@ func (c *Controller) sync(ctx context.Context, key string) error {
}
lb, err := c.lbClient.Allocate(ctx, provisioner.AllocateRequest{
Namespace: namespace,
Name: name,
Ports: ports,
Namespace: namespace,
Name: name,
Ports: ports,
LoadBalancerSourceRanges: serviceLoadBalancerSourceRanges(svc),
})
if err != nil {
return err
@@ -279,6 +280,24 @@ func servicePortsToAllocateRules(svc *corev1.Service) ([]provisioner.AllocatePor
return out, nil
}
func serviceLoadBalancerSourceRanges(svc *corev1.Service) []string {
if svc == nil || len(svc.Spec.LoadBalancerSourceRanges) == 0 {
return nil
}
out := make([]string, 0, len(svc.Spec.LoadBalancerSourceRanges))
for _, item := range svc.Spec.LoadBalancerSourceRanges {
trimmed := strings.TrimSpace(item)
if trimmed == "" {
continue
}
out = append(out, trimmed)
}
if len(out) == 0 {
return nil
}
return out
}
func containsString(items []string, target string) bool {
for _, item := range items {
if item == target {
+17
View File
@@ -45,3 +45,20 @@ func TestServicePortsToAllocateRulesRejectsNoPorts(t *testing.T) {
t.Fatal("expected error for empty ports")
}
}
func TestServiceLoadBalancerSourceRanges(t *testing.T) {
svc := &corev1.Service{
ObjectMeta: metav1.ObjectMeta{Namespace: "default", Name: "web"},
Spec: corev1.ServiceSpec{
LoadBalancerSourceRanges: []string{"203.0.113.0/24", " 198.51.100.8/32 ", ""},
},
}
ranges := serviceLoadBalancerSourceRanges(svc)
if len(ranges) != 2 {
t.Fatalf("ranges count = %d, want 2", len(ranges))
}
if ranges[0] != "203.0.113.0/24" || ranges[1] != "198.51.100.8/32" {
t.Fatalf("unexpected ranges: %#v", ranges)
}
}
+4 -3
View File
@@ -9,9 +9,10 @@ type LoadBalancer struct {
}
type AllocateRequest struct {
Namespace string `json:"namespace"`
Name string `json:"name"`
Ports []AllocatePortRule `json:"ports,omitempty"`
Namespace string `json:"namespace"`
Name string `json:"name"`
Ports []AllocatePortRule `json:"ports,omitempty"`
LoadBalancerSourceRanges []string `json:"loadBalancerSourceRanges,omitempty"`
}
type AllocatePortRule struct {