Skip to content

Commit ec34185

Browse files
authored
Add support for ALB IPv6 target groups (#2284)
* Add support for ALB IPv6 target groups * Update CRDs * resolve VPC ENI for pods with IPv6 addresses * fix formatting * refactor based on PR comments
1 parent e8ab832 commit ec34185

27 files changed

+1853
-40
lines changed

Dockerfile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ COPY go.mod go.mod
77
COPY go.sum go.sum
88
# cache deps before building and copying source so that we don't need to re-download as much
99
# and so that source changes don't invalidate our downloaded layer
10-
RUN GOPROXY=direct go mod download
10+
RUN --mount=type=bind,target=. \
11+
--mount=type=cache,target=/root/.cache/go-build \
12+
GOPROXY=direct go mod download
1113

1214
FROM base AS build
1315
ARG TARGETOS

apis/elbv2/v1beta1/targetgroupbinding_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,15 @@ const (
3333
TargetTypeIP TargetType = "ip"
3434
)
3535

36+
// +kubebuilder:validation:Enum=ipv4;ipv6
37+
// TargetGroupIPAddressType is the IP Address type of your ELBV2 TargetGroup.
38+
type TargetGroupIPAddressType string
39+
40+
const (
41+
TargetGroupIPAddressTypeIPv4 TargetGroupIPAddressType = "ipv4"
42+
TargetGroupIPAddressTypeIPv6 TargetGroupIPAddressType = "ipv6"
43+
)
44+
3645
// ServiceReference defines reference to a Kubernetes Service and its ServicePort.
3746
type ServiceReference struct {
3847
// Name is the name of the Service.
@@ -132,6 +141,10 @@ type TargetGroupBindingSpec struct {
132141
// node selector for instance type target groups to only register certain nodes
133142
// +optional
134143
NodeSelector *metav1.LabelSelector `json:"nodeSelector,omitempty"`
144+
145+
// ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
146+
// +optional
147+
IPAddressType *TargetGroupIPAddressType `json:"ipAddressType,omitempty"`
135148
}
136149

137150
// TargetGroupBindingStatus defines the observed state of TargetGroupBinding

apis/elbv2/v1beta1/zz_generated.deepcopy.go

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

config/crd/bases/elbv2.k8s.aws_targetgroupbindings.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,12 @@ spec:
188188
spec:
189189
description: TargetGroupBindingSpec defines the desired state of TargetGroupBinding
190190
properties:
191+
ipAddressType:
192+
description: ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
193+
enum:
194+
- ipv4
195+
- ipv6
196+
type: string
191197
networking:
192198
description: networking defines the networking rules to allow ELBV2 LoadBalancer to access targets in TargetGroup.
193199
properties:

docs/install/iam_policy.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ec2:DescribeAvailabilityZones",
2020
"ec2:DescribeInternetGateways",
2121
"ec2:DescribeVpcs",
22+
"ec2:DescribeVpcPeeringConnections",
2223
"ec2:DescribeSubnets",
2324
"ec2:DescribeSecurityGroups",
2425
"ec2:DescribeInstances",

docs/install/iam_policy_cn.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ec2:DescribeAvailabilityZones",
2020
"ec2:DescribeInternetGateways",
2121
"ec2:DescribeVpcs",
22+
"ec2:DescribeVpcPeeringConnections",
2223
"ec2:DescribeSubnets",
2324
"ec2:DescribeSecurityGroups",
2425
"ec2:DescribeInstances",

docs/install/iam_policy_us-gov.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"ec2:DescribeAvailabilityZones",
2020
"ec2:DescribeInternetGateways",
2121
"ec2:DescribeVpcs",
22+
"ec2:DescribeVpcPeeringConnections",
2223
"ec2:DescribeSubnets",
2324
"ec2:DescribeSecurityGroups",
2425
"ec2:DescribeInstances",

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.16
44

55
require (
66
github.com/Masterminds/sprig/v3 v3.2.2 // indirect
7-
github.com/aws/aws-sdk-go v1.40.7
7+
github.com/aws/aws-sdk-go v1.41.0
88
github.com/fatih/color v1.7.0 // indirect
99
github.com/gavv/httpexpect/v2 v2.3.1 // indirect
1010
github.com/go-logr/logr v0.4.0

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -135,6 +135,8 @@ github.com/aws/aws-sdk-go v1.38.67 h1:OCeXMKiiM8X7HAKPCE5yD+t+sEsRaj8EwDs2tlgvX2
135135
github.com/aws/aws-sdk-go v1.38.67/go.mod h1:hcU610XS61/+aQV88ixoOzUoG7v3b31pl2zKMmprdro=
136136
github.com/aws/aws-sdk-go v1.40.7 h1:dD5+UZxedqHeE4WakJHEhTsEARYlq8kHkYEf89R1tEo=
137137
github.com/aws/aws-sdk-go v1.40.7/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
138+
github.com/aws/aws-sdk-go v1.41.0 h1:XUzHLFWQVhmFtmKTodnAo5QdooPQfpVfilCxIV3aLoE=
139+
github.com/aws/aws-sdk-go v1.41.0/go.mod h1:585smgzpB/KqRA+K3y/NL/oYRqQvpNJYvLm+LY1U59Q=
138140
github.com/aws/aws-sdk-go-v2 v0.18.0 h1:qZ+woO4SamnH/eEbjM2IDLhRNwIwND/RQyVlBLp3Jqg=
139141
github.com/aws/aws-sdk-go-v2 v0.18.0/go.mod h1:JWVYvqSMppoMJC0x5wdwiImzgXTI9FuZwxzkQq9wy+g=
140142
github.com/beorn7/perks v0.0.0-20160804104726-4c0e84591b9a/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q=

helm/aws-load-balancer-controller/crds/crds.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,22 @@ spec:
6161
- ipv4
6262
- dualstack
6363
type: string
64+
loadBalancerAttributes:
65+
description: LoadBalancerAttributes define the custom attributes to LoadBalancers for all Ingress that that belong to IngressClass with this IngressClassParams.
66+
items:
67+
description: Attributes defines custom attributes on resources.
68+
properties:
69+
key:
70+
description: The key of the attribute.
71+
type: string
72+
value:
73+
description: The value of the attribute.
74+
type: string
75+
required:
76+
- key
77+
- value
78+
type: object
79+
type: array
6480
namespaceSelector:
6581
description: NamespaceSelector restrict the namespaces of Ingresses that are allowed to specify the IngressClass with this IngressClassParams. * if absent or present but empty, it selects all namespaces.
6682
properties:
@@ -313,6 +329,12 @@ spec:
313329
spec:
314330
description: TargetGroupBindingSpec defines the desired state of TargetGroupBinding
315331
properties:
332+
ipAddressType:
333+
description: ipAddressType specifies whether the target group is of type IPv4 or IPv6. If unspecified, it will be automatically inferred.
334+
enum:
335+
- ipv4
336+
- ipv6
337+
type: string
316338
networking:
317339
description: networking defines the networking rules to allow ELBV2 LoadBalancer to access targets in TargetGroup.
318340
properties:

main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func main() {
145145
mgr.GetClient(), ctrl.Log.WithName("pod-readiness-gate-injector"))
146146
corewebhook.NewPodMutator(podReadinessGateInjector).SetupWithManager(mgr)
147147
elbv2webhook.NewTargetGroupBindingMutator(cloud.ELBV2(), ctrl.Log).SetupWithManager(mgr)
148-
elbv2webhook.NewTargetGroupBindingValidator(mgr.GetClient(), ctrl.Log).SetupWithManager(mgr)
148+
elbv2webhook.NewTargetGroupBindingValidator(mgr.GetClient(), cloud.ELBV2(), ctrl.Log).SetupWithManager(mgr)
149149
networkingwebhook.NewIngressValidator(mgr.GetClient(), controllerCFG.IngressConfig, ctrl.Log).SetupWithManager(mgr)
150150
//+kubebuilder:scaffold:builder
151151

0 commit comments

Comments
 (0)