Skip to content

Commit

Permalink
fix: No longer include cluster name in launch template name, since th…
Browse files Browse the repository at this point in the history
…e character sets are not compatible (aws#3701)
  • Loading branch information
ellistarn authored Apr 6, 2023
1 parent 7989e1f commit 43b4f4e
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
8 changes: 4 additions & 4 deletions pkg/providers/launchtemplate/launchtemplate.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ import (
)

const (
launchTemplateNameFormat = "Karpenter-%s-%s"
launchTemplateNameFormat = "karpenter.k8s.aws/%s"
karpenterManagedTagKey = "karpenter.k8s.aws/cluster"
)

Expand Down Expand Up @@ -132,7 +132,7 @@ func launchTemplateName(options *amifamily.LaunchTemplate) string {
if err != nil {
panic(fmt.Sprintf("hashing launch template, %s", err))
}
return fmt.Sprintf(launchTemplateNameFormat, options.ClusterName, fmt.Sprint(hash))
return fmt.Sprintf(launchTemplateNameFormat, fmt.Sprint(hash))
}

func (p *Provider) createAMIOptions(ctx context.Context, machine *v1alpha5.Machine, nodeTemplate *v1alpha1.AWSNodeTemplate, labels map[string]string) (*amifamily.Options, error) {
Expand Down Expand Up @@ -301,10 +301,10 @@ func (p *Provider) cachedEvictedFunc(ctx context.Context) func(string, interface
}
launchTemplate := lt.(*ec2.LaunchTemplate)
if _, err := p.ec2api.DeleteLaunchTemplate(&ec2.DeleteLaunchTemplateInput{LaunchTemplateId: launchTemplate.LaunchTemplateId}); err != nil {
logging.FromContext(ctx).Errorf("Unable to delete launch template, %v", err)
logging.FromContext(ctx).With("launch-template", launchTemplate.LaunchTemplateName).Errorf("Unable to delete launch template, %v", err)
return
}
logging.FromContext(ctx).Debugf("deleted launch template")
logging.FromContext(ctx).With("launch-template", launchTemplate.LaunchTemplateName).Debugf("deleted launch template")
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
helm uninstall karpenter --namespace karpenter
aws cloudformation delete-stack --stack-name "Karpenter-${CLUSTER_NAME}"
aws ec2 describe-launch-templates \
| jq -r ".LaunchTemplates[].LaunchTemplateName" \
| grep -i "Karpenter-${CLUSTER_NAME}" \
| xargs -I{} aws ec2 delete-launch-template --launch-template-name {}
aws ec2 describe-launch-templates --filters Name=tag:karpenter.k8s.aws/cluster,Values=${CLUSTER_NAME} |
jq -r ".LaunchTemplates[].LaunchTemplateName" |
xargs -I{} aws ec2 delete-launch-template --launch-template-name {}
eksctl delete cluster --name "${CLUSTER_NAME}"

0 comments on commit 43b4f4e

Please sign in to comment.