Skip to content

Commit 28834c2

Browse files
committed
Add support for shared subnets
This currently requires that security groups be defined in the ingress annotation
1 parent 42f0de3 commit 28834c2

File tree

1 file changed

+17
-14
lines changed

1 file changed

+17
-14
lines changed

internal/alb/lb/loadbalancer.go

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,11 @@ type loadBalancerConfig struct {
6262
Name string
6363
Tags map[string]string
6464

65-
Type *string
66-
Scheme *string
67-
IpAddressType *string
68-
Subnets []string
65+
Type *string
66+
Scheme *string
67+
IpAddressType *string
68+
SecurityGroups []string
69+
Subnets []string
6970
}
7071

7172
type defaultController struct {
@@ -184,12 +185,13 @@ func (controller *defaultController) ensureLBInstance(ctx context.Context, lbCon
184185
func (controller *defaultController) newLBInstance(ctx context.Context, lbConfig *loadBalancerConfig) (*elbv2.LoadBalancer, error) {
185186
albctx.GetLogger(ctx).Infof("creating LoadBalancer %v", lbConfig.Name)
186187
resp, err := controller.cloud.CreateLoadBalancerWithContext(ctx, &elbv2.CreateLoadBalancerInput{
187-
Name: aws.String(lbConfig.Name),
188-
Type: lbConfig.Type,
189-
Scheme: lbConfig.Scheme,
190-
IpAddressType: lbConfig.IpAddressType,
191-
Subnets: aws.StringSlice(lbConfig.Subnets),
192-
Tags: tags.ConvertToELBV2(lbConfig.Tags),
188+
Name: aws.String(lbConfig.Name),
189+
Type: lbConfig.Type,
190+
Scheme: lbConfig.Scheme,
191+
IpAddressType: lbConfig.IpAddressType,
192+
SecurityGroups: aws.StringSlice(lbConfig.SecurityGroups),
193+
Subnets: aws.StringSlice(lbConfig.Subnets),
194+
Tags: tags.ConvertToELBV2(lbConfig.Tags),
193195
})
194196
if err != nil {
195197
albctx.GetLogger(ctx).Errorf("failed to create LoadBalancer %v due to %v", lbConfig.Name, err)
@@ -309,10 +311,11 @@ func (controller *defaultController) buildLBConfig(ctx context.Context, ingress
309311
Name: controller.nameTagGen.NameLB(ingress.Namespace, ingress.Name),
310312
Tags: lbTags,
311313

312-
Type: aws.String(elbv2.LoadBalancerTypeEnumApplication),
313-
Scheme: ingressAnnos.LoadBalancer.Scheme,
314-
IpAddressType: ingressAnnos.LoadBalancer.IPAddressType,
315-
Subnets: subnets,
314+
Type: aws.String(elbv2.LoadBalancerTypeEnumApplication),
315+
Scheme: ingressAnnos.LoadBalancer.Scheme,
316+
IpAddressType: ingressAnnos.LoadBalancer.IPAddressType,
317+
SecurityGroups: ingressAnnos.LoadBalancer.SecurityGroups,
318+
Subnets: subnets,
316319
}, nil
317320
}
318321

0 commit comments

Comments
 (0)