Skip to content

Commit

Permalink
Filter CNI subnets when creating EKS NodeGroup
Browse files Browse the repository at this point in the history
  • Loading branch information
mnitchev committed Feb 13, 2024
1 parent c857879 commit 1b3377f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
13 changes: 10 additions & 3 deletions api/v1beta2/network_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,9 +102,7 @@ type TargetGroupHealthCheck struct {
// TargetGroupAttribute defines attribute key values for V2 Load Balancer Attributes.
type TargetGroupAttribute string

var (
TargetGroupAttributeEnablePreserveClientIP = "preserve_client_ip.enabled"
)
var TargetGroupAttributeEnablePreserveClientIP = "preserve_client_ip.enabled"

// LoadBalancerAttribute defines a set of attributes for a V2 load balancer.
type LoadBalancerAttribute string
Expand Down Expand Up @@ -480,6 +478,15 @@ func (s Subnets) FilterPrivate() (res Subnets) {
return
}

func (s Subnets) FilterPrimary() (res Subnets) {
for _, x := range s {
if x.Tags[NameAWSSubnetAssociation] != SecondarySubnetTagValue {
res = append(res, x)
}
}
return
}

// FilterPublic returns a slice containing all subnets marked as public.
func (s Subnets) FilterPublic() (res Subnets) {
for _, x := range s {
Expand Down
1 change: 1 addition & 0 deletions pkg/cloud/scope/shared.go
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ func (p *defaultSubnetPlacementStrategy) getSubnetsForAZs(azs []string, controlP
subnets = subnets.FilterPublic()
case expinfrav1.AZSubnetTypePrivate:
subnets = subnets.FilterPrivate()
subnets = subnets.FilterPrimary()
}
}
if len(subnets) == 0 {
Expand Down

0 comments on commit 1b3377f

Please sign in to comment.