Skip to content
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

Build private & public subnet in every AZ #590

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

mselim00
Copy link
Contributor

@mselim00 mselim00 commented Feb 27, 2025

Issue #, if available:

Description of changes:
Updates the infrastructure stack to include a private and public subnet in every availability zone in the region. Various capacity constraints make selecting two random availability zones, like we were doing before, too restrictive. For example, if a instance type is only offered in 2 out of 5 availability zones in a region, then those are also currently our odds of even including a subnet in the necessary AZ to try to launch the capacity.

There's enough different scenarios to consider that we shouldn't try to pre-process like we were doing before with capacity reservations, to try to ensure that the particular AZ we need is included. That strategy also opens up weird failure modes. Since the infrastructure stack is created before cluster creation (which can take several minutes), a terminating instance in an ASG would not be counted for the subnet selection, but then we might try to target it if it is available by the time we start creating nodegroups.

Unfortunately cloudformation currently has no native support for loops so I made this a go template, which we're already using for all other stacks at this point.

At this point, I've only tested directly creating the stack to confirm that all resources are valid and unique where needed. I'll do some runs of a couple e2e scenarios before merging.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

var (
//go:embed unmanaged-nodegroup.yaml.template
unmanagedNodegroupTemplate string
UnmanagedNodegroup = template.Must(template.New("unmanagedNodegroup").Parse(unmanagedNodegroupTemplate))

// for addition in a template
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: This comment could be more descriptive about the components being added together.

- NatGatewayEIP2
- SubnetPublic02
- VPCGatewayAttachment
{{ range $index, $cidr := .PublicCIDRs }}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think a comment here describing the subnet creation logic would be helpful. For example, something like

# Create public subnets, one per AZ
# Each subnet gets a CIDR block from the calculated public CIDR ranges

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants