Skip to content

Commit 0230b21

Browse files
committed
Disable node-termination-handler
1 parent 02622b0 commit 0230b21

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

cmd/kops/integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ func TestKarpenter(t *testing.T) {
945945
withOIDCDiscovery().
946946
withDefaults24().
947947
withAddons("karpenter.sh-k8s-1.19").
948-
withServiceAccountRole("aws-node-termination-handler.kube-system", true).
948+
withoutNTH().
949949
withServiceAccountRole("karpenter.kube-system", true)
950950
test.expectTerraformFilenames = append(test.expectTerraformFilenames,
951951
"aws_s3_object_nodeupscript-karpenter-nodes-single-machinetype_content",

pkg/model/components/nodeterminationhandler.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,21 @@ func (b *NodeTerminationHandlerOptionsBuilder) BuildOptions(o *kops.Cluster) err
3939
clusterSpec.CloudProvider.AWS.NodeTerminationHandler = &kops.NodeTerminationHandlerSpec{}
4040
}
4141
nth := clusterSpec.CloudProvider.AWS.NodeTerminationHandler
42+
if nth.Enabled == nil {
43+
if clusterSpec.Karpenter != nil && clusterSpec.Karpenter.Enabled {
44+
// Karpenter manages its own NTH, so we disable the NTH addon.
45+
// https://karpenter.sh/docs/troubleshooting/#aws-node-termination-handler-nth-interactions
46+
nth.Enabled = fi.PtrTo(false)
47+
} else {
48+
nth.Enabled = fi.PtrTo(true)
49+
}
50+
}
51+
if !fi.ValueOf(nth.Enabled) {
52+
return nil
53+
}
4254
if nth.DeleteSQSMsgIfNodeNotFound == nil {
4355
nth.DeleteSQSMsgIfNodeNotFound = fi.PtrTo(false)
4456
}
45-
if nth.Enabled == nil {
46-
nth.Enabled = fi.PtrTo(true)
47-
}
4857
if nth.EnableSpotInterruptionDraining == nil {
4958
nth.EnableSpotInterruptionDraining = fi.PtrTo(true)
5059
}

0 commit comments

Comments
 (0)