-
Notifications
You must be signed in to change notification settings - Fork 363
WIP: Add support for dual stack load balancers #1313
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 10 commits
70fa363
ffbb4b8
dc32a61
d2315dd
de00cc6
713764e
73d10dc
4cd75f4
5652364
4d5b485
d81c9a2
188d6c0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -234,6 +234,16 @@ const ServiceAnnotationLoadBalancerEIPAllocations = "service.beta.kubernetes.io/ | |||||
| // static IP addresses for the NLB. Only supported on elbv2 (NLB) | ||||||
| const ServiceAnnotationLoadBalancerPrivateIPv4Addresses = "service.beta.kubernetes.io/aws-load-balancer-private-ipv4-addresses" | ||||||
|
|
||||||
| // ServiceAnnotationLoadBalancerIPAddressType is the annotation used on the service | ||||||
| // to specify the IP address type for the load balancer. Supported values are "ipv4" and "dualstack". | ||||||
| // Defaults to "ipv4". Only supported on NLB. | ||||||
| const ServiceAnnotationLoadBalancerIPAddressType = "service.beta.kubernetes.io/aws-load-balancer-ip-address-type" | ||||||
|
|
||||||
| // ServiceAnnotationLoadBalancerTargetGroupIPAddressType is the annotation used on the service | ||||||
| // to specify the IP address type for the target groups. Supported values are "ipv4" and "ipv6". | ||||||
| // Defaults to "ipv4". Only supported on NLB. | ||||||
| const ServiceAnnotationLoadBalancerTargetGroupIPAddressType = "service.beta.kubernetes.io/aws-load-balancer-target-group-ip-address-type" | ||||||
|
|
||||||
|
Comment on lines
+237
to
+246
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please also update the service controller documentation: https://github.com/kubernetes/cloud-provider-aws/blob/master/docs/service_controller.md |
||||||
| // ServiceAnnotationLoadBalancerTargetNodeLabels is the annotation used on the service | ||||||
| // to specify a comma-separated list of key-value pairs which will be used to select | ||||||
| // the target nodes for the load balancer | ||||||
|
|
@@ -1296,6 +1306,20 @@ func ipPermissionExists(newPermission, existing *ec2types.IpPermission, compareG | |||||
| } | ||||||
| } | ||||||
|
|
||||||
| // Check IPv6 ranges | ||||||
| for j := range newPermission.Ipv6Ranges { | ||||||
| found := false | ||||||
| for k := range existing.Ipv6Ranges { | ||||||
| if isEqualStringPointer(newPermission.Ipv6Ranges[j].CidrIpv6, existing.Ipv6Ranges[k].CidrIpv6) { | ||||||
| found = true | ||||||
| break | ||||||
| } | ||||||
| } | ||||||
| if !found { | ||||||
| return false | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| for _, leftPair := range newPermission.UserIdGroupPairs { | ||||||
| found := false | ||||||
| for _, rightPair := range existing.UserIdGroupPairs { | ||||||
|
|
@@ -2116,7 +2140,16 @@ func (c *Cloud) getSubnetCidrs(ctx context.Context, subnetIDs []string) ([]strin | |||||
|
|
||||||
| cidrs := make([]string, 0, len(subnets)) | ||||||
| for _, subnet := range subnets { | ||||||
| // Add IPv4 CIDR | ||||||
| cidrs = append(cidrs, aws.ToString(subnet.CidrBlock)) | ||||||
|
|
||||||
| // Add IPv6 CIDRs if present | ||||||
| for _, ipv6Association := range subnet.Ipv6CidrBlockAssociationSet { | ||||||
| if ipv6Association.Ipv6CidrBlockState != nil && | ||||||
| ipv6Association.Ipv6CidrBlockState.State == ec2types.SubnetCidrBlockStateCodeAssociated { | ||||||
| cidrs = append(cidrs, aws.ToString(ipv6Association.Ipv6CidrBlock)) | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
| return cidrs, nil | ||||||
| } | ||||||
|
|
@@ -2430,11 +2463,6 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS | |||||
| loadBalancerName := c.GetLoadBalancerName(ctx, clusterName, apiService) | ||||||
| serviceName := types.NamespacedName{Namespace: apiService.Namespace, Name: apiService.Name} | ||||||
|
|
||||||
| instanceIDs := []string{} | ||||||
| for id := range instances { | ||||||
| instanceIDs = append(instanceIDs, string(id)) | ||||||
| } | ||||||
|
|
||||||
| securityGroups, err := c.ensureNLBSecurityGroup(ctx, | ||||||
| loadBalancerName, | ||||||
| clusterName, | ||||||
|
|
@@ -2447,11 +2475,12 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS | |||||
| serviceName, | ||||||
| loadBalancerName, | ||||||
| v2Mappings, | ||||||
| instanceIDs, | ||||||
| instances, | ||||||
| discoveredSubnetIDs, | ||||||
| internalELB, | ||||||
| annotations, | ||||||
| securityGroups, | ||||||
| apiService, | ||||||
| ) | ||||||
| if err != nil { | ||||||
| return nil, err | ||||||
|
|
@@ -2483,6 +2512,12 @@ func (c *Cloud) EnsureLoadBalancer(ctx context.Context, clusterName string, apiS | |||||
| } | ||||||
| if len(sourceRangeCidrs) == 0 { | ||||||
| sourceRangeCidrs = append(sourceRangeCidrs, "0.0.0.0/0") | ||||||
|
|
||||||
| // For dual-stack or IPv6 load balancers, also add IPv6 default route | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. route or rule?
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Route. "0.0.0.0/0" and "::/0" act as a gateway of last resort, directing unmatched traffic to a specific next-hop or upstream router. |
||||||
| lbIPAddressType := c.getLBIPAddressType(apiService) | ||||||
| if lbIPAddressType == elbv2types.IpAddressTypeDualstack { | ||||||
| sourceRangeCidrs = append(sourceRangeCidrs, "::/0") | ||||||
| } | ||||||
| } | ||||||
|
|
||||||
| err = c.updateInstanceSecurityGroupsForNLB(ctx, loadBalancerName, instances, subnetCidrs, sourceRangeCidrs, v2Mappings) | ||||||
|
|
||||||
Uh oh!
There was an error while loading. Please reload this page.