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

Tag Security Group created for AWS ELB with same additional tags as ELB #58767

Merged
merged 2 commits into from
Feb 25, 2018

Conversation

2rs2ts
Copy link
Contributor

@2rs2ts 2rs2ts commented Jan 24, 2018

/sig aws

(I worked on this with @bkochendorfer)

Tags the SG created for the ELB with the same additional tags the ELB gets from the service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags annotation. This is useful for identifying orphaned resources.

We think that reusing the annotation is a simpler and less intrusive approach than adding a new annotation, and most users will want the same set of tags applied.

We weren't sure how to write a test for this because it looks like the fake EC2 code doesn't store the state of the security groups. If new tests are a requirement for merging, we'll need help writing them.

Fixes #53489

AWS Security Groups created for ELBs will now be tagged with the same additional tags as the ELB (i.e. the tags specified by the "service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags" annotation.)

Reuse the
service.beta.kubernetes.io/aws-load-balancer-additional-resource-tags
annotation for these tags.

We think that this is a simpler and less intrusive approach than adding
a new annotation, and most users will want the same set of tags applied.

Signed-off-by: Brett Kochendorfer <brett.kochendorfer@gmail.com>
@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. sig/aws size/M Denotes a PR that changes 30-99 lines, ignoring generated files. needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Jan 24, 2018
@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Jan 24, 2018
@2rs2ts
Copy link
Contributor Author

2rs2ts commented Jan 24, 2018

/assign @zmerlynn

@@ -2815,7 +2815,7 @@ func (c *Cloud) removeSecurityGroupIngress(securityGroupID string, removePermiss
// Makes sure the security group exists.
// For multi-cluster isolation, name must be globally unique, for example derived from the service UUID.
// Returns the security group id or error
func (c *Cloud) ensureSecurityGroup(name string, description string) (string, error) {
func (c *Cloud) ensureSecurityGroup(name string, description string, annotations map[string]string) (string, error) {
Copy link
Member

Choose a reason for hiding this comment

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

Nit: let's call them "tags" not "annotations"? Maybe "extraTags" or "additionalTags" ?

It's would also be nice to apply the tags where we didn't previously create them. I think there's an additionalTags argument to readRepairClusterTags which will do the right thing. If it's complicated we can address this later, but I think it's simple (?)

Copy link
Contributor Author

@2rs2ts 2rs2ts Feb 13, 2018

Choose a reason for hiding this comment

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

Because we are passing in the annotations on the Service and then getting the additional-tags annotation from that map of annotations, that's why we call this argument annotations.

I see in your other comment that you are thinking of passing in that annotation instead though, which I think makes sense. It's been a hot minute since I wrote this with my colleague but I think we wrote it like this in case other annotations might get used someday. If that seems like unnecessary futureproofing, I can just pass the tags annotation.

@@ -2881,7 +2881,7 @@ func (c *Cloud) ensureSecurityGroup(name string, description string) (string, er
return "", fmt.Errorf("created security group, but id was not returned: %s", name)
}

err := c.tagging.createTags(c.ec2, groupID, ResourceLifecycleOwned, nil)
err := c.tagging.createTags(c.ec2, groupID, ResourceLifecycleOwned, getLoadBalancerAdditionalTags(annotations))
Copy link
Member

Choose a reason for hiding this comment

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

Instead of assuming that this is a ELB security group, how about if we pass in getLoadBalancerAdditionalTags(annotations) to ensureSecurityGroup. I suspect we don't call the function anywhere else, but it makes the method less surprising.

@justinsb
Copy link
Member

/assign

/ok-to-test

Seems like the right thing to do, and a good implementation. I had few suggestions - see if you agree with them :-)

@k8s-ci-robot k8s-ci-robot removed the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Feb 13, 2018
@chrislovecnm
Copy link
Contributor

/test pull-kubernetes-e2e-kops-aws

@2rs2ts
Copy link
Contributor Author

2rs2ts commented Feb 16, 2018

I do not understand this CI failure; I can't even see the reason why the build failed

@justinsb
Copy link
Member

/lgtm

Thanks @2rs2ts @bkochendorfer

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Feb 25, 2018
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: 2rs2ts, justinsb

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

The pull request process is described here

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Feb 25, 2018
@justinsb
Copy link
Member

/test pull-kubernetes-unit

Failure seems unrelated

@k8s-github-robot
Copy link

/test all [submit-queue is verifying that this PR is safe to merge]

@k8s-github-robot
Copy link

Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here.

@k8s-github-robot k8s-github-robot merged commit 62c5f21 into kubernetes:master Feb 25, 2018
@2rs2ts 2rs2ts deleted the tag-elb-sgs branch February 27, 2018 00:13
@cdenneen
Copy link

cdenneen commented Apr 5, 2019

@2rs2ts Thanks for doing this but it appears if I add tags (annotations) to an ELB after it's creation... the ELB tags update but the underlying SG don't.
I can update the source-ranges and they will update the SG but the tags appear to only prop on creation but not updates?

Is there anyway to update the tags?

@2rs2ts
Copy link
Contributor Author

2rs2ts commented Apr 5, 2019

@cdenneen we'd probably need to add something to ensureSecurityGroup to make sure the tags are what they are supposed to be, do you want to take a stab at that? I don't think I can work on it until at least a week from now.

@ucodevault
Copy link

@2rs2ts Thanks for your fix to pass the tags from ELB to SG. But as @cdenneen was saying updating the tags on ELB doesn't reflect on SG tags. Was there a fix already done for this too?.

@2rs2ts
Copy link
Contributor Author

2rs2ts commented Dec 10, 2020

@ucodevault I am not sure, I feel like there was but I can't find an issue in my subscriptions about it. Feel free to open an issue about it.

@2rs2ts
Copy link
Contributor Author

2rs2ts commented Dec 10, 2020

Ah, I was thinking of #95247, which isn't related. I think you should definitely open a new issue.

@ucodevault
Copy link

@ucodevault I am not sure, I feel like there was but I can't find an issue in my subscriptions about it. Feel free to open an issue about it.

Thanks for the info. @2rs2ts

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

AWS: Tagging the security group of ELB created for LoadBalancer or Ingress
8 participants