Skip to content

feat: Allow tagging on per-subnet basis #901

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

Closed

Conversation

ghost
Copy link

@ghost ghost commented Feb 28, 2023

Description

New variables public_subnet_tags_per_subnet, private_subnet_tags_per_subnet, etc. Optional, no effect if not specified. If specified, they are additional tags to apply to each respective public and private subnet.

Extend the ability to allow naming and tagging route tables, EIPs, and NAT Gateways on per-subnet basis as well, add variables for that.

Motivation and Context

Previously, it was only possible to customize arbitrary tags on a per-AZ basis, not a per-subnet basis. You could customize the Name tag on a per-subnet basis but not any other tag.

The VPCs in our environment have several different types of subnets. We would like to tag them differently, e.g. for cost attribution and reference in external Terraform code. Currently this is not possible: subnets can only be disambiguated by VPC, AZ, and visibility.

Breaking Changes

No breaking changes

How Has This Been Tested?

  • I have updated at least one of the examples/* to demonstrate and validate my change(s)
  • I have tested and validated these changes using one or more of the provided examples/* projects
  • I have executed pre-commit run -a on my pull request

This is currently running in production

@ghost ghost force-pushed the rr-tag-subnets-individually branch from 9f2a4d3 to d13247b Compare February 28, 2023 21:17
@ghost
Copy link
Author

ghost commented Feb 28, 2023

Testing in our infrastructure with:

image

Generating expected Terraform plan:

image

@ghost
Copy link
Author

ghost commented Mar 2, 2023

This is now live in our infrastructure. I also added the ability to customize route table tagging.

@ghost ghost force-pushed the rr-tag-subnets-individually branch from d13247b to 62114c4 Compare March 2, 2023 19:41
@ghost
Copy link
Author

ghost commented Mar 3, 2023

I've completed the rollout of the new tagging system throughout our infrastructure, using the code from this pull request in production. No problems uncovered.

@kahirokunn
Copy link

kahirokunn commented Mar 6, 2023

Awesome!
LGTM!

@jseiser
Copy link

jseiser commented Mar 14, 2023

I think this behavior is what we are looking for.

We wanted to be able to have 2 sets of private subnets.

1 for our EKS cluster's worker nodes, and 1 for some other random servers that still survive post EKS migration. So we could just target the server private subnets when deploying those specific EC2 Instances

Copy link

@davepattie davepattie left a comment

Choose a reason for hiding this comment

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

Ahh, I see now that tags per az is no use when you have more than one private subnet per az

@hpschry
Copy link

hpschry commented Apr 26, 2023

I'd love to see this merged, this would address our use case as well: We'll need individual tags per sub-net, e.g. to control the assignment of load balancers to specific sub-nets in an EKS scenario, which is controlled by sub-net tags.

@reoring
Copy link

reoring commented Apr 27, 2023

Once this Pull Request is merged, I will use it right away

Copy link

@KevinBrooke KevinBrooke left a comment

Choose a reason for hiding this comment

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

We have been using this branch in production for 3 weeks without any issues.

@jjdiazgarcia jjdiazgarcia mentioned this pull request May 31, 2023
@davepattie
Copy link

@antonbabenko would you mind taking a look at this PR please, it's a really helpful and thorough addition, thanks

@github-actions
Copy link

github-actions bot commented Jul 2, 2023

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Jul 2, 2023
@kahirokunn
Copy link

keep

@github-actions github-actions bot removed the stale label Jul 3, 2023
@jseiser
Copy link

jseiser commented Jul 12, 2023

@raxod502-plaid

Any chance you can fix the conflicts, id really love to get this one merged in.

@ghost
Copy link
Author

ghost commented Jul 12, 2023

There's not much point in fixing merge conflicts until we get confirmation from a maintainer that they are interested in merging the PR.

@github-actions
Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Aug 12, 2023
@kahirokunn
Copy link

i need this PR.

@github-actions github-actions bot removed the stale label Aug 13, 2023
@rarescosma
Copy link

We're hitting the same needs for our EKS setup at the moment: need to tag secondary subnets differently to tell karpenter to slowly start moving the nodes towards these subnets.

What are the plans for moving this PR forward?

@andrewmiskell
Copy link

I'm running into some of the same issues in our environment as well, needing to tag specific subnets differently due to different uses.

@netomin
Copy link

netomin commented Sep 13, 2023

Hi, hitting the same needs here, it would be great to have this PR to move forward ;)

@kahirokunn
Copy link

I think so!

@bryantbiggs
Copy link
Member

But here, it sounds like you are wanting to name each individual subnet differently

*not just name, but more generically - treat them differently via unique tags

@ghost
Copy link
Author

ghost commented Jun 10, 2024

this pattern is due to the fact that we currently do not support a generic - "create as many different subnet groups of your choosing" - its only those pre-defined subnet group types that we support in this module today

Yes, that is the requirement. If you provided a way to create an arbitrary set of subnet groups then it would not be necessary to parameterize tags within a subnet group.

We aren't treating subnets as pets, we simply have more types of subnets than just "private" and "public" (plus the few other special cases in this module).

So that said - if there were a generic sub-module where users could create various different groups of subnets, does this issue become a moot point?

Yes, exactly.

@andrewmiskell
Copy link

I think a generic submodule to stamp out as many private/public sets of subnets I want each with it's own set of tags would make this whole thing moot, at least in my use-case.

In my case, I need to different sets of public subnets that have different tags. One tagged with Subnet_Type "public" and another tagged with Subnet_Type "sending" (our use case is very particular and somewhat edge case due to the custom software we use). Currently I'm using the redshift subnets feature with enable_public_redshift enabled in order to do this. Having a more generic way to create subnets without have to "repurpose" the pre-defined subnet types would be very helpful.

@erpel
Copy link

erpel commented Jun 10, 2024

So this "what you're trying to do is covered by groups" argument is the first time I understood the resistance. To me the groups always seemed really type based rather than the main differentiation. This has me rethinking how we use the module in some way.

My use case mainly comes from a situation like this:
We have for example 5 subnets that are "private" in type. That's more than one per AZ - which is problematic in some services where only one subnet per AZ is accepted.

Using tags would be how I'd like to set which subnets of the type "private" should be used for EKS control plane (don't hold me to the exact example, I'm going off memory here).
The subnets are otherwise quite the same, the fact that they are separate subnets comes from some organizational history...

@Pursu1tOfHapp1ness

This comment was marked as off-topic.

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Dec 30, 2024
@PLeS207
Copy link

PLeS207 commented Dec 30, 2024

up

@github-actions github-actions bot removed the stale label Dec 31, 2024
@pseudomorph
Copy link

What's the state of this? Is there a path forward here?

@bryantbiggs
Copy link
Member

it requires time and resources - nothing planned at the moment

@Chili-Man
Copy link
Contributor

Chili-Man commented Feb 13, 2025

@bryantbiggs @antonbabenko We have a use case for this particular feature at work as well. As other folks have pointed out here in the comments already, we would like to have several private subnets, with different roles. In particular, we want to have our VPC look like this:

Public Subnets
3 public subnets for AWS load balancers and nat gateways.
The AWS EKS load balancer controller will manage the LBs, so it needs to be tagged with kubernetes.io/role/elb

Private Subnets
3 private subnets specifically for EKS. These need to be tagged with kubernetes.io/role/internal-elb for the LBC.
3 additional general purpose private subnets for workloads running outside of EKS. These must not be tagged with kubernetes.io/role/internal-elb , since we don't want the LBC to deploy in those subnets.

Although we could technically tell LBC which subnets to specifically use at via annotations, coordination and passing of this information from Terraform to the applications we deploy on the EKS cluster is burdensome and additional work, especially when that particular configuration information can be abstracted away from the applications via the subnet discovery tags. If we could have passed the specific default subnets we want the LBC to deploy in via the controller command line flags, then I would have less qualms about this, but unfortunately that is not the case.

From reading through the issue here, I understand that there are potential plans to have a generic subnet submodule that would address all of the concerns here, but since there are no concrete plans for that, I'd like to suggest that during this interim, we reconsider implementing this feature. Specifically, I'd like to propose the following:

Scope the change of adding per subnet tags to only the private and public subnet groups that are created from this module. Looking through all of the comments here, the primary concern is with these two types of subnets, since the other subnet types (e.g. redshift, elasticache, etc) are already specific with a use case in mind. This minimizes the surface area of change, so its less likely to cause issues down the road and easier to maintain. We already have the "private_subnet_names" (and similar) variable that allows to customize each subnet name , which is in a similar vein as this feature request, so I'm having trouble understanding why this change would be rejected. EDIT: Looks like someone already implemented it here as described in the following PR: #1139

I'm happy to open up a new PR for this, but I'd like to gauge appetite on this from the maintainers. Looking at the this repos issues and pr history, its been a feature request for years now, and I don't see why we need to continue waiting for the perfect solution for it to happen.

@ghost
Copy link
Author

ghost commented Mar 11, 2025

PR has not seen movement for 2 years. Closing as unlikely to be merged.

@ghost ghost closed this Mar 11, 2025
@ghost ghost deleted the rr-tag-subnets-individually branch March 11, 2025 06:54
@ghost
Copy link
Author

ghost commented Mar 11, 2025

For what it's worth, this is still running successfully as a load-bearing component of our production infrastructure.

@Chili-Man
Copy link
Contributor

Chili-Man commented Mar 11, 2025

@raxod502-plaid can you please keep it open? Even though there hasn't been much movement on it, doesn't necessarily mean the community doesn't want this feature. If you close the issue, the maintainers are more likely to forget about this

@ghost ghost restored the rr-tag-subnets-individually branch March 11, 2025 17:00
@ghost ghost reopened this Mar 11, 2025
@bogatuadrian
Copy link

bogatuadrian commented Mar 17, 2025

@bryantbiggs @antonbabenko This functionality would be very useful to us as well.

Our use case is that we require different types of private subnets for different types of EKS nodes (due to security considerations), and we need to tag those subnets accordingly, so we can configure Karpenter to scale certain nodes that use their respective subnets.

I also agree with what @Chili-Man said in a previous post. You could consider this change only for the public/private subnets. Some work in that direction has been done here #1139.

Also to address some previous points in this thread:

  1. There are definitely reasons to have different types of private subnets, subnets that wouldn't fall in any of the other categories (intra, database etc.), our use-case, separate security constrains for each subnet, being one (of probably many)
  2. Tags are essential for Karpenter discoverability, but also incredibly useful in a IaC & GitOps workflow where it's easier to reference a resource by tags, rather than by (a generated) ID.

EDIT to add: having a way to add custom subnets to the module could be an improvement, but the main appeal of this module is the out-of-the-box configuration for how a "private" subnet is configured. I just want that "private" configuration, but for 2 groups of subnets that will end up being used in different ways down the line, hence needing custom tagging.

Copy link

This PR has been automatically marked as stale because it has been open 30 days
with no activity. Remove stale label or comment or this PR will be closed in 10 days

@github-actions github-actions bot added the stale label Apr 17, 2025
Copy link

This PR was automatically closed because of stale in 10 days

@github-actions github-actions bot closed this Apr 27, 2025
Copy link

I'm going to lock this pull request because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you have found a problem that seems related to this change, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.