Skip to content

Fix Egress Only Internet Gateway lookup when there are multiple in the account#18104

Open
rlees85 wants to merge 1 commit intokubernetes:masterfrom
rlees85:eigw-fix
Open

Fix Egress Only Internet Gateway lookup when there are multiple in the account#18104
rlees85 wants to merge 1 commit intokubernetes:masterfrom
rlees85:eigw-fix

Conversation

@rlees85
Copy link
Copy Markdown
Contributor

@rlees85 rlees85 commented Mar 20, 2026

This is a possible fix for: #18088

With this approach, we still do not need to specify the Egress Only Internet Gateway ID in existing, shared VPCs which I think is probably more desirable than having to declare it.

make test seems happy with it. I've removed the attachment.vpc-id from the mocks because the AWS API does not support it so the mocks should also not support it.

I'm not a developer and my domain knowledge of KOPS is rusty to say the least so any optimisations to what has been submitted is welcome.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Mar 20, 2026
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

Hi @rlees85. Thanks for your PR.

I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work.

Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Mar 20, 2026
@k8s-ci-robot k8s-ci-robot requested a review from hakman March 20, 2026 14:49
@k8s-ci-robot k8s-ci-robot added the area/provider/aws Issues or PRs related to aws provider label Mar 20, 2026
@k8s-ci-robot k8s-ci-robot requested a review from olemarkus March 20, 2026 14:49
@k8s-ci-robot
Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign zetaab for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

other Egress Only Internet Gateways exist in the AWS account

Signed-off-by: Rich <git0@bitservices.io>

func findEgressOnlyInternetGateway(ctx context.Context, cloud awsup.AWSCloud, request *ec2.DescribeEgressOnlyInternetGatewaysInput) (*ec2types.EgressOnlyInternetGateway, error) {
func findEgressOnlyInternetGateway(ctx context.Context, cloud awsup.AWSCloud, request *ec2.DescribeEgressOnlyInternetGatewaysInput, vpcId string) (*ec2types.EgressOnlyInternetGateway, error) {
response, err := cloud.EC2().DescribeEgressOnlyInternetGateways(ctx, request)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The gateway should be tagged with "kubernetes.io/cluster/<cluster-name>" = "shared", I believe that is the expectation for any kOps resource. Filters should be able to work with it with tag-key:

tag-key - The key of a tag assigned to the resource. Use this filter to find all resources assigned a tag with a specific key, regardless of the tag value.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will experiment with that way of doing it. I know you can get away without tagging a lot of resources (internet gateway, possibly others) but if the intention is that all resources (not just VPC, subnet) are tagged I will see if I can make it work by looking up with the tag name

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

The intention was to have everything tagged, but AWS took a while to add tags and filters to everything...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Ah fair enough. Looking through the docs and code it looks like KOPS will add the tags for you "kubernetes.io/cluster/<cluster-name>" = "shared" if they do not already exist. It just so happens I use Terraform to pre-tag to stop endless diffs.

So having to "pre-tag" the egress only Internet gateway would be a significant change in behaviour to how VPC, subnet, everything else is currently handled.

If we don't "pre-tag" I am still not sure how Kops is going to find the correct egress only Internet gateway without either a manual VPC filter (as per this PR) or having to specify the egress only Internet gateway ID in the KOPS manifest (and command line parameter for those that do not use KOPS with a manifest).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/provider/aws Issues or PRs related to aws provider cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants