Skip to content

Commit 2d2371f

Browse files
authored
Merge pull request #4800 from giantswarm/pr-eks-cni-subnet
✨ Filter CNI subnets when creating EKS NodeGroup
2 parents 4f24769 + 355b6d8 commit 2d2371f

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

api/v1beta2/network_types.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,17 @@ func (s Subnets) FilterPrivate() (res Subnets) {
715715
return
716716
}
717717

718+
// FilterNonCni returns the subnets that are NOT intended for usage with the CNI pod network
719+
// (i.e. do NOT have the `sigs.k8s.io/cluster-api-provider-aws/association=secondary` tag).
720+
func (s Subnets) FilterNonCni() (res Subnets) {
721+
for _, x := range s {
722+
if x.Tags[NameAWSSubnetAssociation] != SecondarySubnetTagValue {
723+
res = append(res, x)
724+
}
725+
}
726+
return
727+
}
728+
718729
// FilterPublic returns a slice containing all subnets marked as public.
719730
func (s Subnets) FilterPublic() (res Subnets) {
720731
for _, x := range s {

pkg/cloud/scope/shared.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ func (p *defaultSubnetPlacementStrategy) getSubnetsForAZs(azs []string, controlP
122122
subnets = subnets.FilterPublic()
123123
case expinfrav1.AZSubnetTypePrivate:
124124
subnets = subnets.FilterPrivate()
125+
subnets = subnets.FilterNonCni()
125126
}
126127
}
127128
if len(subnets) == 0 {

pkg/cloud/scope/shared_test.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ func TestSubnetPlacement(t *testing.T) {
182182
AvailabilityZone: "eu-west-1c",
183183
IsPublic: false,
184184
},
185+
infrav1.SubnetSpec{
186+
ID: "subnet-az6",
187+
AvailabilityZone: "eu-west-1c",
188+
IsPublic: false,
189+
Tags: infrav1.Tags{
190+
infrav1.NameAWSSubnetAssociation: infrav1.SecondarySubnetTagValue,
191+
},
192+
},
185193
},
186194
logger: logger.NewLogger(klog.Background()),
187195
expectedSubnetIDs: []string{"subnet-az3"},

0 commit comments

Comments
 (0)