Skip to content

Commit c9d30f2

Browse files
authored
Merge pull request #1831 from kishorj/main-hc-rule
Add health check SG rule from VPC if preserve client IP is configured
2 parents 9006bfc + 614380a commit c9d30f2

File tree

3 files changed

+88
-2
lines changed

3 files changed

+88
-2
lines changed

pkg/service/model_build_target_group.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -370,7 +370,7 @@ func (t *defaultModelBuildTask) buildTargetGroupBindingNetworking(ctx context.Co
370370
},
371371
},
372372
}
373-
if tgProtocol == corev1.ProtocolUDP || (hcPort.String() != healthCheckPortTrafficPort && hcPort.IntValue() != tgPort.IntValue()) {
373+
if preserveClientIP || tgProtocol == corev1.ProtocolUDP || (hcPort.String() != healthCheckPortTrafficPort && hcPort.IntValue() != tgPort.IntValue()) {
374374
var healthCheckPorts []elbv2api.NetworkingPort
375375
networkingProtocolTCP := elbv2api.NetworkingProtocolTCP
376376
networkingHealthCheckPort := hcPort

pkg/service/model_build_target_group_test.go

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -519,6 +519,26 @@ func Test_defaultModelBuilderTask_buildTargetGroupBindingNetworking(t *testing.T
519519
},
520520
},
521521
},
522+
{
523+
From: []elbv2.NetworkingPeer{
524+
{
525+
IPBlock: &elbv2api.IPBlock{
526+
CIDR: "172.16.0.0/19",
527+
},
528+
},
529+
{
530+
IPBlock: &elbv2api.IPBlock{
531+
CIDR: "1.2.3.4/19",
532+
},
533+
},
534+
},
535+
Ports: []elbv2api.NetworkingPort{
536+
{
537+
Protocol: &networkingProtocolTCP,
538+
Port: &port80,
539+
},
540+
},
541+
},
522542
},
523543
},
524544
},
@@ -645,6 +665,72 @@ func Test_defaultModelBuilderTask_buildTargetGroupBindingNetworking(t *testing.T
645665
},
646666
},
647667
},
668+
{
669+
name: "tcp-service with preserve Client IP, hc is traffic port, source range specified ",
670+
svc: &corev1.Service{
671+
Spec: corev1.ServiceSpec{
672+
LoadBalancerSourceRanges: []string{"10.0.0.0/16", "1.2.3.4/24"},
673+
},
674+
},
675+
tgPort: port80,
676+
hcPort: port80,
677+
subnets: []*ec2.Subnet{
678+
{
679+
CidrBlock: aws.String("172.16.0.0/19"),
680+
SubnetId: aws.String("sn-1"),
681+
},
682+
{
683+
CidrBlock: aws.String("1.2.3.4/19"),
684+
SubnetId: aws.String("sn-2"),
685+
},
686+
},
687+
tgProtocol: corev1.ProtocolTCP,
688+
preserveClientIP: true,
689+
want: &elbv2.TargetGroupBindingNetworking{
690+
Ingress: []elbv2.NetworkingIngressRule{
691+
{
692+
From: []elbv2.NetworkingPeer{
693+
{
694+
IPBlock: &elbv2api.IPBlock{
695+
CIDR: "10.0.0.0/16",
696+
},
697+
},
698+
{
699+
IPBlock: &elbv2api.IPBlock{
700+
CIDR: "1.2.3.4/24",
701+
},
702+
},
703+
},
704+
Ports: []elbv2api.NetworkingPort{
705+
{
706+
Protocol: &networkingProtocolTCP,
707+
Port: &port80,
708+
},
709+
},
710+
},
711+
{
712+
From: []elbv2.NetworkingPeer{
713+
{
714+
IPBlock: &elbv2api.IPBlock{
715+
CIDR: "172.16.0.0/19",
716+
},
717+
},
718+
{
719+
IPBlock: &elbv2api.IPBlock{
720+
CIDR: "1.2.3.4/19",
721+
},
722+
},
723+
},
724+
Ports: []elbv2api.NetworkingPort{
725+
{
726+
Protocol: &networkingProtocolTCP,
727+
Port: &port80,
728+
},
729+
},
730+
},
731+
},
732+
},
733+
},
648734
}
649735
for _, tt := range tests {
650736
t.Run(tt.name, func(t *testing.T) {

test/framework/utils/poll.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,5 @@ const (
88
PollIntervalLong = 30 * time.Second
99
PollTimeoutShort = 1 * time.Minute
1010
PollTimeoutMedium = 5 * time.Minute
11-
PollTimeoutLong = 10 * time.Minute
11+
PollTimeoutLong = 15 * time.Minute
1212
)

0 commit comments

Comments
 (0)