mirror of https://github.com/kubernetes/kops.git
Merge pull request #10567 from rifelpet/nlb-listener-order
Fix NLB listener -> target group association for TF & CF
This commit is contained in:
commit
09bf333433
|
|
@ -1206,7 +1206,7 @@
|
|||
{
|
||||
"Type": "forward",
|
||||
"TargetGroupArn": {
|
||||
"Ref": "AWSElasticLoadBalancingV2TargetGrouptcpcomplexexamplecomvpjolq"
|
||||
"Ref": "AWSElasticLoadBalancingV2TargetGrouptlscomplexexamplecom5nursn"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
@ -1225,7 +1225,7 @@
|
|||
{
|
||||
"Type": "forward",
|
||||
"TargetGroupArn": {
|
||||
"Ref": "AWSElasticLoadBalancingV2TargetGrouptlscomplexexamplecom5nursn"
|
||||
"Ref": "AWSElasticLoadBalancingV2TargetGrouptcpcomplexexamplecomvpjolq"
|
||||
}
|
||||
}
|
||||
],
|
||||
|
|
|
|||
|
|
@ -460,7 +460,7 @@ resource "aws_launch_template" "nodes-complex-example-com" {
|
|||
resource "aws_lb_listener" "api-complex-example-com-443" {
|
||||
certificate_arn = "arn:aws:acm:us-test-1:000000000000:certificate/123456789012-1234-1234-1234-12345678"
|
||||
default_action {
|
||||
target_group_arn = aws_lb_target_group.tcp-complex-example-com-vpjolq.id
|
||||
target_group_arn = aws_lb_target_group.tls-complex-example-com-5nursn.id
|
||||
type = "forward"
|
||||
}
|
||||
load_balancer_arn = aws_lb.api-complex-example-com.id
|
||||
|
|
@ -471,7 +471,7 @@ resource "aws_lb_listener" "api-complex-example-com-443" {
|
|||
|
||||
resource "aws_lb_listener" "api-complex-example-com-8443" {
|
||||
default_action {
|
||||
target_group_arn = aws_lb_target_group.tls-complex-example-com-5nursn.id
|
||||
target_group_arn = aws_lb_target_group.tcp-complex-example-com-vpjolq.id
|
||||
type = "forward"
|
||||
}
|
||||
load_balancer_arn = aws_lb.api-complex-example-com.id
|
||||
|
|
|
|||
|
|
@ -722,14 +722,24 @@ func (_ *NetworkLoadBalancer) RenderTerraform(t *terraform.TerraformTarget, a, e
|
|||
return err
|
||||
}
|
||||
|
||||
for i, listener := range e.Listeners {
|
||||
for _, listener := range e.Listeners {
|
||||
var listenerTG *TargetGroup
|
||||
for _, tg := range e.TargetGroups {
|
||||
if aws.StringValue(tg.Name) == listener.TargetGroupName {
|
||||
listenerTG = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
if listenerTG == nil {
|
||||
return fmt.Errorf("target group not found for NLB listener %+v", e)
|
||||
}
|
||||
listenerTF := &terraformNetworkLoadBalancerListener{
|
||||
LoadBalancer: e.TerraformLink(),
|
||||
Port: int64(listener.Port),
|
||||
DefaultAction: []terraformNetworkLoadBalancerListenerAction{
|
||||
{
|
||||
Type: elbv2.ActionTypeEnumForward,
|
||||
TargetGroupARN: e.TargetGroups[i].TerraformLink(),
|
||||
TargetGroupARN: listenerTG.TerraformLink(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
@ -805,14 +815,24 @@ func (_ *NetworkLoadBalancer) RenderCloudformation(t *cloudformation.Cloudformat
|
|||
return err
|
||||
}
|
||||
|
||||
for i, listener := range e.Listeners {
|
||||
for _, listener := range e.Listeners {
|
||||
var listenerTG *TargetGroup
|
||||
for _, tg := range e.TargetGroups {
|
||||
if aws.StringValue(tg.Name) == listener.TargetGroupName {
|
||||
listenerTG = tg
|
||||
break
|
||||
}
|
||||
}
|
||||
if listenerTG == nil {
|
||||
return fmt.Errorf("target group not found for NLB listener %+v", e)
|
||||
}
|
||||
listenerCF := &cloudformationNetworkLoadBalancerListener{
|
||||
LoadBalancerARN: e.CloudformationLink(),
|
||||
Port: int64(listener.Port),
|
||||
DefaultActions: []cloudformationNetworkLoadBalancerListenerAction{
|
||||
{
|
||||
Type: elbv2.ActionTypeEnumForward,
|
||||
TargetGroupARN: e.TargetGroups[i].CloudformationLink(),
|
||||
TargetGroupARN: listenerTG.CloudformationLink(),
|
||||
},
|
||||
},
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue