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

Dont list and terminate ASG-managed EC2 instances #16222

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion pkg/resources/aws/aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterInfo resources.ClusterInfo) (
listFunctions := []listFn{
// EC2
ListAutoScalingGroups,
ListInstances,
ListKeypairs,
ListSecurityGroups,
ListVolumes,
Expand All @@ -88,6 +87,12 @@ func ListResourcesAWS(cloud awsup.AWSCloud, clusterInfo resources.ClusterInfo) (
ListEventBridgeRules,
}

if clusterInfo.UsesKarpenter {
// ASG deletion cascades to their instances
// Only karpenter-enabled clusters have instances not in ASGs
listFunctions = append(listFunctions, ListInstances)
}

if !dns.IsGossipClusterName(clusterName) && !clusterUsesNoneDNS {
// Route 53
listFunctions = append(listFunctions, ListRoute53Records)
Expand Down
5 changes: 3 additions & 2 deletions pkg/resources/clusterinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ limitations under the License.
package resources

type ClusterInfo struct {
Name string
UsesNoneDNS bool
Name string
UsesNoneDNS bool
UsesKarpenter bool
// Azure specific
AzureResourceGroupName string
AzureResourceGroupShared bool
Expand Down
5 changes: 3 additions & 2 deletions pkg/resources/ops/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ import (
// ListResources collects the resources from the specified cloud
func ListResources(cloud fi.Cloud, cluster *kops.Cluster) (map[string]*resources.Resource, error) {
clusterInfo := resources.ClusterInfo{
Name: cluster.Name,
UsesNoneDNS: cluster.UsesNoneDNS(),
Name: cluster.Name,
UsesNoneDNS: cluster.UsesNoneDNS(),
UsesKarpenter: cluster.Spec.Karpenter != nil && cluster.Spec.Karpenter.Enabled,
}

switch cloud.ProviderID() {
Expand Down
Loading