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

Add "owned" tag for volumes and instances created with launch templates #8660

Merged
merged 1 commit into from
Mar 2, 2020

Conversation

hakman
Copy link
Member

@hakman hakman commented Mar 1, 2020

Using launch templates for instance groups make adds the kops & k8s tags to instances and root volumes.

For volumes, the cluster delete function checks if the resource is "shared" or "owned", otherwise it displays the following warning:

W0229 23:33:33.176831    8549 aws.go:2148] (new) cluster tag not found on volume:vol-038ab86f6fcd93336

kops/pkg/resources/aws/aws.go

Lines 2134 to 2136 in 632b426

// HasSharedTag looks for the shared tag indicating that the cluster does not own the resource
func HasSharedTag(description string, tags []*ec2.Tag, clusterName string) bool {
tagKey := "kubernetes.io/cluster/" + clusterName

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 1, 2020
@hakman
Copy link
Member Author

hakman commented Mar 1, 2020

/cc @rifelpet

@johngmyers
Copy link
Member

For volumes, the cluster delete function checks if the cluster is "shared" or "owned", otherwise

Perhaps you meant that it checks if the resource is "shared" or "owned"?

@hakman
Copy link
Member Author

hakman commented Mar 1, 2020

Perhaps you meant that it checks if the resource is "shared" or "owned"?

Yes. Updated. Thanks.

@@ -101,6 +101,8 @@ func (b *AutoscalingGroupModelBuilder) buildLaunchTemplateTask(c *fi.ModelBuilde
if err != nil {
return nil, fmt.Errorf("error building cloud tags: %v", err)
}
// TODO: move this to CloudTagsForInstanceGroup when LaunchConfigurations are removed
tags["kubernetes.io/cluster/"+b.ClusterName()] = "owned"
Copy link
Member

Choose a reason for hiding this comment

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

Perhaps call b.CloudTags("", false) ?

What would be the downside to moving that to CloudTagsFroInstanceGroup before LaunchConfigurations are removed? Why don't instances/volumes created by LaunchConfigurations throw the warning?

Copy link
Member Author

Choose a reason for hiding this comment

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

What would be the downside to moving that to CloudTagsFroInstanceGroup before LaunchConfigurations are removed?

I don't know if it would affect any current workflow if this tag is applied at ASG level. Launch templates are still experimental in Kops and shouldn't be an issue.

Why don't instances/volumes created by LaunchConfigurations throw the warning?

Instances created with launch configurations don't tag root volumes at all. Because of this, the volumes are not tracked as part of the cluster by the delete function. They are still deleted automatically when the instance is deleted.

May also be a possibility to not track root volumes at all with the deleted function, even if they have the other tags.

Copy link
Member

@johngmyers johngmyers Mar 1, 2020

Choose a reason for hiding this comment

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

I like the idea of being consistent in what tags we apply.

I could see the KubernetesCluster tag being useful for cost control and leaving it out lacks consistency, so I think we should call CloudTags rather than setting kubernetes.io/cluster/ directly.

For consistency, I'm in favor of moving things into CloudTagsForInstanceGroup sooner. Perhaps we should have CloudTagsForInstanceGroup call CloudTags. I don't know what the consequence of adding the ownership tags to the CloudTags template function would be, though.

Copy link
Member Author

Choose a reason for hiding this comment

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

I actually tried this as the first iteration, but the changes in tests were bigger than I expected.
I don't think should affect any workflow, but preferred not to change so much.

@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 1, 2020
pkg/model/context.go Outdated Show resolved Hide resolved
@johngmyers
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Mar 2, 2020
@rifelpet
Copy link
Member

rifelpet commented Mar 2, 2020

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman, rifelpet

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 Mar 2, 2020
@k8s-ci-robot k8s-ci-robot merged commit 0624935 into kubernetes:master Mar 2, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.18 milestone Mar 2, 2020
@hakman
Copy link
Member Author

hakman commented Mar 2, 2020

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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants