Skip to content

Commit f1f9e85

Browse files
committed
Add validation for enabling with node-termination-handler
Signed-off-by: Ciprian Hacman <[email protected]>
1 parent f7614ca commit f1f9e85

File tree

3 files changed

+9
-9
lines changed

3 files changed

+9
-9
lines changed

pkg/apis/kops/validation/validation.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1898,6 +1898,9 @@ func validateMetricsServer(cluster *kops.Cluster, spec *kops.MetricsServerConfig
18981898
}
18991899

19001900
func validateNodeTerminationHandler(cluster *kops.Cluster, spec *kops.NodeTerminationHandlerSpec, fldPath *field.Path) (allErrs field.ErrorList) {
1901+
if (spec.Enabled == nil || *spec.Enabled == true) && cluster.Spec.Karpenter != nil && cluster.Spec.Karpenter.Enabled {
1902+
allErrs = append(allErrs, field.Forbidden(fldPath, "nodeTerminationHandler cannot be used in conjunction with Karpenter"))
1903+
}
19011904
if spec.IsQueueMode() {
19021905
if spec.EnableSpotInterruptionDraining != nil && !*spec.EnableSpotInterruptionDraining {
19031906
allErrs = append(allErrs, field.Forbidden(fldPath.Child("enableSpotInterruptionDraining"), "spot interruption draining cannot be disabled in Queue Processor mode"))

pkg/model/components/nodeterminationhandler.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -35,18 +35,17 @@ func (b *NodeTerminationHandlerOptionsBuilder) BuildOptions(o *kops.Cluster) err
3535
if clusterSpec.CloudProvider.AWS == nil {
3636
return nil
3737
}
38+
if clusterSpec.Karpenter != nil && clusterSpec.Karpenter.Enabled {
39+
// Karpenter manages its own NTH, so we disable the NTH addon.
40+
// https://karpenter.sh/docs/troubleshooting/#aws-node-termination-handler-nth-interactions
41+
return nil
42+
}
3843
if clusterSpec.CloudProvider.AWS.NodeTerminationHandler == nil {
3944
clusterSpec.CloudProvider.AWS.NodeTerminationHandler = &kops.NodeTerminationHandlerSpec{}
4045
}
4146
nth := clusterSpec.CloudProvider.AWS.NodeTerminationHandler
4247
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-
}
48+
nth.Enabled = fi.PtrTo(true)
5049
}
5150
if !fi.ValueOf(nth.Enabled) {
5251
return nil

tests/integration/update_cluster/karpenter/data/aws_s3_object_cluster-completed.spec_content

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,6 @@ spec:
184184
networkCIDR: 172.20.0.0/16
185185
networking:
186186
cni: {}
187-
nodeTerminationHandler:
188-
enabled: false
189187
nonMasqueradeCIDR: 100.64.0.0/10
190188
podCIDR: 100.96.0.0/11
191189
secretStore: memfs://clusters.example.com/minimal.example.com/secrets

0 commit comments

Comments
 (0)