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

Use LaunchTemplate versions instead of timestamped LaunchTemplates #10151

Merged
merged 7 commits into from
Nov 11, 2020

Conversation

hakman
Copy link
Member

@hakman hakman commented Nov 2, 2020

Historically, kOps used LaunchConfigurations for configuring AutoScalingGroups with the IG name as prefix and creation timestamp as suffix (nodes-a.k8s.example.com-20200806091534).

Newer versions of kOps added the possibility of using LaunchTemplates for configuring AutoScalingGroups, as some features are not available for when using LaunchConfigurations. Even though LaunchTemplates allow versioning, kOps uses the same naming convention as for LaunchConfigurations, but having to deal with LaunchTemplateVersions also and generating many requests to the AWS API, as seen in #9806.

kOps 1.19 introduces LaunchTemplates as the default AutoScalingGroups configuration method and switching to versions should simplify things:

  • the LaunchTemplate would have a fixed name identical to the IG name
  • ASGs will use the $Latest LaunchTemplate version
  • all versions will be kept (for now) as there AWS limit is 10.000 versions for each LaunchTemplate
  • all previous LaunchTemplates with timestamp prefixed names will be deleted, reducing the clutter in the LaunchTemplate list

CloudFormation output will not be affected by these changes.

Terraform output will change to using name instead of name_prefix (another leftover from the LaunchConfigurations days).

@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 Nov 2, 2020
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: hakman

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 area/provider/aws Issues or PRs related to aws provider label Nov 2, 2020
@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 2, 2020
@hakman hakman force-pushed the launch-template-versions branch 2 times, most recently from bbbc5ba to bf79b86 Compare November 2, 2020 11:11
@hakman
Copy link
Member Author

hakman commented Nov 2, 2020

/hold for feedback

@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 2, 2020
@hakman hakman force-pushed the launch-template-versions branch from bf79b86 to 4328a00 Compare November 2, 2020 13:47
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 2, 2020
@hakman hakman force-pushed the launch-template-versions branch from 4328a00 to dcc7444 Compare November 3, 2020 14:38
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Nov 3, 2020
@hakman
Copy link
Member Author

hakman commented Nov 3, 2020

/test pull-kops-bazel-test

@hakman
Copy link
Member Author

hakman commented Nov 3, 2020

/retest

@hakman hakman force-pushed the launch-template-versions branch from dcc7444 to 992b16d Compare November 4, 2020 10:05
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2020
@hakman hakman force-pushed the launch-template-versions branch from 992b16d to 852c0e2 Compare November 5, 2020 18:11
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 5, 2020
pkg/resources/aws/aws.go Outdated Show resolved Hide resolved
pkg/resources/aws/aws.go Outdated Show resolved Hide resolved
pkg/resources/aws/aws.go Outdated Show resolved Hide resolved
pkg/resources/aws/aws.go Outdated Show resolved Hide resolved
upup/pkg/fi/cloudup/awstasks/autoscalinggroup.go Outdated Show resolved Hide resolved
for _, configuration := range configurations {
removals = append(removals, &deleteLaunchTemplate{lc: configuration})
if strings.HasPrefix(aws.StringValue(configuration.LaunchTemplateName), prefix) {
Copy link
Member

Choose a reason for hiding this comment

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

Why is this necessary? Wouldn't all the old launch templates be deleted as owned by the cluster but unreferenced by an ASG?

Copy link
Member Author

Choose a reason for hiding this comment

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

There can be N previous LTs for each ASG. already unreferenced that should be deleted.
Maybe there's some mechanism that I'm missing.

Copy link
Member

Choose a reason for hiding this comment

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

Looks like I misunderstood the Find / FindDeletions mechanisms. I thought it would look for resources tagged as owned by the cluster and delete them if they're not expected.

}
e.ID = output.LaunchTemplate.LaunchTemplateId
} else {
// TODO: Update the LaunchTemplate tags
Copy link
Member

Choose a reason for hiding this comment

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

I think implementing this might block merging.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm, already implemented it in 852c0e2 and seems to work without issues. Nothing actually reads these tags after creation, they are just used for deleting the LT when needed.

upup/pkg/fi/cloudup/awsup/aws_cloud.go Outdated Show resolved Hide resolved
@hakman hakman force-pushed the launch-template-versions branch from b1537a5 to 705fd35 Compare November 7, 2020 08:20
@hakman hakman requested a review from johngmyers November 7, 2020 08:22
@hakman
Copy link
Member Author

hakman commented Nov 8, 2020

/hold cancel

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Nov 8, 2020
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2020
@hakman hakman force-pushed the launch-template-versions branch from 705fd35 to 1d6a51a Compare November 9, 2020 19:42
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 9, 2020
@kubernetes kubernetes deleted a comment from k8s-ci-robot Nov 10, 2020
@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 Nov 11, 2020
@hakman
Copy link
Member Author

hakman commented Nov 11, 2020

Thanks @johngmyers :)

@k8s-ci-robot k8s-ci-robot merged commit 9b3f13d into kubernetes:master Nov 11, 2020
@k8s-ci-robot k8s-ci-robot added this to the v1.20 milestone Nov 11, 2020
@hakman hakman deleted the launch-template-versions branch November 11, 2020 07:24
k8s-ci-robot added a commit that referenced this pull request Nov 16, 2020
…-upstream-release-1.19

Automated cherry pick of #10151: Use LT versions instead of timestamped LTs
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. area/provider/aws Issues or PRs related to aws provider 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.

3 participants