diff --git a/Makefile b/Makefile index 01224a95a2..9fa3f878c2 100644 --- a/Makefile +++ b/Makefile @@ -94,7 +94,6 @@ licenses: download ## Verifies dependency licenses verify: ## Verify code. Includes codegen, docgen, dependencies, linting, formatting, etc go mod tidy go generate ./... - hack/mutation/nodepool.sh hack/validation/kubelet.sh hack/validation/taint.sh hack/validation/requirements.sh diff --git a/hack/mutation/nodepool.sh b/hack/mutation/nodepool.sh deleted file mode 100755 index c893fa34d5..0000000000 --- a/hack/mutation/nodepool.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/usr/bin/env bash -# Remove Resource Field on the spec.template.spec.resources on v1 NodePool API -yq eval 'del(.spec.versions[0].schema.openAPIV3Schema.properties.spec.properties.template.properties.spec.properties.resources)' -i pkg/apis/crds/karpenter.sh_nodepools.yaml \ No newline at end of file diff --git a/kwok/charts/crds/karpenter.sh_nodepools.yaml b/kwok/charts/crds/karpenter.sh_nodepools.yaml index 735bba9397..3926134c7f 100644 --- a/kwok/charts/crds/karpenter.sh_nodepools.yaml +++ b/kwok/charts/crds/karpenter.sh_nodepools.yaml @@ -206,7 +206,10 @@ spec: rule: self.all(x, x != "kubernetes.io/hostname") type: object spec: - description: NodeClaimSpec describes the desired state of the NodeClaim + description: |- + NodeClaimTemplateSpec describes the desired state of the NodeClaim in the Nodepool + NodeClaimTemplateSpec is used in the NodePool's NodeClaimTemplate, with the resource requests omitted since + users are not able to set resource requests in the NodePool. properties: expireAfter: default: 720h diff --git a/pkg/apis/crds/karpenter.sh_nodepools.yaml b/pkg/apis/crds/karpenter.sh_nodepools.yaml index 44b510e230..d3759af925 100644 --- a/pkg/apis/crds/karpenter.sh_nodepools.yaml +++ b/pkg/apis/crds/karpenter.sh_nodepools.yaml @@ -206,7 +206,10 @@ spec: rule: self.all(x, x != "kubernetes.io/hostname") type: object spec: - description: NodeClaimSpec describes the desired state of the NodeClaim + description: |- + NodeClaimTemplateSpec describes the desired state of the NodeClaim in the Nodepool + NodeClaimTemplateSpec is used in the NodePool's NodeClaimTemplate, with the resource requests omitted since + users are not able to set resource requests in the NodePool. properties: expireAfter: default: 720h diff --git a/pkg/apis/v1/nodeclaim_validation.go b/pkg/apis/v1/nodeclaim_validation.go index 63c3384b75..930ba084a9 100644 --- a/pkg/apis/v1/nodeclaim_validation.go +++ b/pkg/apis/v1/nodeclaim_validation.go @@ -60,7 +60,7 @@ type taintKeyEffect struct { Effect v1.TaintEffect } -func (in *NodeClaimSpec) validateTaints() (errs *apis.FieldError) { +func (in *NodeClaimTemplateSpec) validateTaints() (errs *apis.FieldError) { existing := map[taintKeyEffect]struct{}{} errs = errs.Also(validateTaintsField(in.Taints, existing, "taints")) errs = errs.Also(validateTaintsField(in.StartupTaints, existing, "startupTaints")) @@ -104,7 +104,7 @@ func validateTaintsField(taints []v1.Taint, existing map[taintKeyEffect]struct{} // This function is used by the NodeClaim validation webhook to verify the nodepool requirements. // When this function is called, the nodepool's requirements do not include the requirements from labels. // NodeClaim requirements only support well known labels. -func (in *NodeClaimSpec) validateRequirements() (errs *apis.FieldError) { +func (in *NodeClaimTemplateSpec) validateRequirements() (errs *apis.FieldError) { for i, requirement := range in.Requirements { if err := ValidateRequirement(requirement); err != nil { errs = errs.Also(apis.ErrInvalidArrayValue(err, "requirements", i)) diff --git a/pkg/apis/v1/nodepool.go b/pkg/apis/v1/nodepool.go index 641bf5eefa..d467426e37 100644 --- a/pkg/apis/v1/nodepool.go +++ b/pkg/apis/v1/nodepool.go @@ -162,7 +162,77 @@ func (l Limits) ExceededBy(resources v1.ResourceList) error { type NodeClaimTemplate struct { ObjectMeta `json:"metadata,omitempty"` // +required - Spec NodeClaimSpec `json:"spec"` + Spec NodeClaimTemplateSpec `json:"spec"` +} + +// NodeClaimTemplateSpec describes the desired state of the NodeClaim in the Nodepool +// NodeClaimTemplateSpec is used in the NodePool's NodeClaimTemplate, with the resource requests omitted since +// users are not able to set resource requests in the NodePool. +type NodeClaimTemplateSpec struct { + // Taints will be applied to the NodeClaim's node. + // +optional + Taints []v1.Taint `json:"taints,omitempty"` + // StartupTaints are taints that are applied to nodes upon startup which are expected to be removed automatically + // within a short period of time, typically by a DaemonSet that tolerates the taint. These are commonly used by + // daemonsets to allow initialization and enforce startup ordering. StartupTaints are ignored for provisioning + // purposes in that pods are not required to tolerate a StartupTaint in order to have nodes provisioned for them. + // +optional + StartupTaints []v1.Taint `json:"startupTaints,omitempty"` + // Requirements are layered with GetLabels and applied to every node. + // +kubebuilder:validation:XValidation:message="requirements with operator 'In' must have a value defined",rule="self.all(x, x.operator == 'In' ? x.values.size() != 0 : true)" + // +kubebuilder:validation:XValidation:message="requirements operator 'Gt' or 'Lt' must have a single positive integer value",rule="self.all(x, (x.operator == 'Gt' || x.operator == 'Lt') ? (x.values.size() == 1 && int(x.values[0]) >= 0) : true)" + // +kubebuilder:validation:XValidation:message="requirements with 'minValues' must have at least that many values specified in the 'values' field",rule="self.all(x, (x.operator == 'In' && has(x.minValues)) ? x.values.size() >= x.minValues : true)" + // +kubebuilder:validation:MaxItems:=100 + // +required + Requirements []NodeSelectorRequirementWithMinValues `json:"requirements" hash:"ignore"` + // NodeClassRef is a reference to an object that defines provider specific configuration + // +required + NodeClassRef *NodeClassReference `json:"nodeClassRef"` + // TerminationGracePeriod is the maximum duration the controller will wait before forcefully deleting the pods on a node, measured from when deletion is first initiated. + // + // Warning: this feature takes precedence over a Pod's terminationGracePeriodSeconds value, and bypasses any blocked PDBs or the karpenter.sh/do-not-disrupt annotation. + // + // This field is intended to be used by cluster administrators to enforce that nodes can be cycled within a given time period. + // When set, drifted nodes will begin draining even if there are pods blocking eviction. Draining will respect PDBs and the do-not-disrupt annotation until the TGP is reached. + // + // Karpenter will preemptively delete pods so their terminationGracePeriodSeconds align with the node's terminationGracePeriod. + // If a pod would be terminated without being granted its full terminationGracePeriodSeconds prior to the node timeout, + // that pod will be deleted at T = node timeout - pod terminationGracePeriodSeconds. + // + // The feature can also be used to allow maximum time limits for long-running jobs which can delay node termination with preStop hooks. + // If left undefined, the controller will wait indefinitely for pods to be drained. + // +kubebuilder:validation:Pattern=`^([0-9]+(s|m|h))+$` + // +kubebuilder:validation:Type="string" + // +optional + TerminationGracePeriod *metav1.Duration `json:"terminationGracePeriod,omitempty"` + // ExpireAfter is the duration the controller will wait + // before terminating a node, measured from when the node is created. This + // is useful to implement features like eventually consistent node upgrade, + // memory leak protection, and disruption testing. + // +kubebuilder:default:="720h" + // +kubebuilder:validation:Pattern=`^(([0-9]+(s|m|h))+)|(Never)$` + // +kubebuilder:validation:Type="string" + // +kubebuilder:validation:Schemaless + // +optional + ExpireAfter NillableDuration `json:"expireAfter,omitempty"` +} + +// This is used to convert between the NodeClaim's NodeClaimSpec to the Nodepool NodeClaimTemplate's NodeClaimSpec. +func (in *NodeClaimTemplate) ToNodeClaim() *NodeClaim { + return &NodeClaim{ + ObjectMeta: metav1.ObjectMeta{ + Labels: in.ObjectMeta.Labels, + Annotations: in.ObjectMeta.Annotations, + }, + Spec: NodeClaimSpec{ + Taints: in.Spec.Taints, + StartupTaints: in.Spec.StartupTaints, + Requirements: in.Spec.Requirements, + NodeClassRef: in.Spec.NodeClassRef, + TerminationGracePeriod: in.Spec.TerminationGracePeriod, + ExpireAfter: in.Spec.ExpireAfter, + }, + } } type ObjectMeta struct { diff --git a/pkg/apis/v1/nodepool_conversion_test.go b/pkg/apis/v1/nodepool_conversion_test.go index 3431b6f55d..14b3a2f186 100644 --- a/pkg/apis/v1/nodepool_conversion_test.go +++ b/pkg/apis/v1/nodepool_conversion_test.go @@ -48,7 +48,7 @@ var _ = Describe("Convert V1 to V1beta1 NodePool API", func() { v1nodepool = &NodePool{ Spec: NodePoolSpec{ Template: NodeClaimTemplate{ - Spec: NodeClaimSpec{ + Spec: NodeClaimTemplateSpec{ NodeClassRef: &NodeClassReference{ Name: "test", Kind: "test", @@ -293,7 +293,7 @@ var _ = Describe("Convert V1beta1 to V1 NodePool API", func() { v1nodepool = &NodePool{ Spec: NodePoolSpec{ Template: NodeClaimTemplate{ - Spec: NodeClaimSpec{ + Spec: NodeClaimTemplateSpec{ NodeClassRef: &NodeClassReference{ Name: "test", Kind: "test", diff --git a/pkg/apis/v1/nodepool_validation_cel_test.go b/pkg/apis/v1/nodepool_validation_cel_test.go index d066f53c66..0590ede1bb 100644 --- a/pkg/apis/v1/nodepool_validation_cel_test.go +++ b/pkg/apis/v1/nodepool_validation_cel_test.go @@ -44,7 +44,7 @@ var _ = Describe("CEL/Validation", func() { ObjectMeta: metav1.ObjectMeta{Name: strings.ToLower(randomdata.SillyName())}, Spec: NodePoolSpec{ Template: NodeClaimTemplate{ - Spec: NodeClaimSpec{ + Spec: NodeClaimTemplateSpec{ NodeClassRef: &NodeClassReference{ Kind: "NodeClaim", Name: "default", diff --git a/pkg/apis/v1/zz_generated.deepcopy.go b/pkg/apis/v1/zz_generated.deepcopy.go index 89c9d80730..e1d62f319c 100644 --- a/pkg/apis/v1/zz_generated.deepcopy.go +++ b/pkg/apis/v1/zz_generated.deepcopy.go @@ -283,6 +283,53 @@ func (in *NodeClaimTemplate) DeepCopy() *NodeClaimTemplate { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *NodeClaimTemplateSpec) DeepCopyInto(out *NodeClaimTemplateSpec) { + *out = *in + if in.Taints != nil { + in, out := &in.Taints, &out.Taints + *out = make([]corev1.Taint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.StartupTaints != nil { + in, out := &in.StartupTaints, &out.StartupTaints + *out = make([]corev1.Taint, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Requirements != nil { + in, out := &in.Requirements, &out.Requirements + *out = make([]NodeSelectorRequirementWithMinValues, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.NodeClassRef != nil { + in, out := &in.NodeClassRef, &out.NodeClassRef + *out = new(NodeClassReference) + **out = **in + } + if in.TerminationGracePeriod != nil { + in, out := &in.TerminationGracePeriod, &out.TerminationGracePeriod + *out = new(metav1.Duration) + **out = **in + } + in.ExpireAfter.DeepCopyInto(&out.ExpireAfter) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new NodeClaimTemplateSpec. +func (in *NodeClaimTemplateSpec) DeepCopy() *NodeClaimTemplateSpec { + if in == nil { + return nil + } + out := new(NodeClaimTemplateSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *NodeClassReference) DeepCopyInto(out *NodeClassReference) { *out = *in diff --git a/pkg/controllers/disruption/consolidation_test.go b/pkg/controllers/disruption/consolidation_test.go index 077446f1de..3f913a8b5c 100644 --- a/pkg/controllers/disruption/consolidation_test.go +++ b/pkg/controllers/disruption/consolidation_test.go @@ -2973,7 +2973,7 @@ var _ = Describe("Consolidation", func() { }, Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{}, NodeClassRef: &v1.NodeClassReference{ Name: "non-existent", diff --git a/pkg/controllers/disruption/drift_test.go b/pkg/controllers/disruption/drift_test.go index 5985f2ecbe..d8521233cd 100644 --- a/pkg/controllers/disruption/drift_test.go +++ b/pkg/controllers/disruption/drift_test.go @@ -323,7 +323,7 @@ var _ = Describe("Drift", func() { }}, }, Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ ExpireAfter: v1.NillableDuration{Duration: nil}, }, }, diff --git a/pkg/controllers/metrics/nodepool/suite_test.go b/pkg/controllers/metrics/nodepool/suite_test.go index b1d0caf304..bac2169749 100644 --- a/pkg/controllers/metrics/nodepool/suite_test.go +++ b/pkg/controllers/metrics/nodepool/suite_test.go @@ -63,7 +63,7 @@ var _ = Describe("Metrics", func() { nodePool = test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ NodeClassRef: &v1.NodeClassReference{ Name: "default", }, diff --git a/pkg/controllers/nodeclaim/disruption/drift_test.go b/pkg/controllers/nodeclaim/disruption/drift_test.go index b8e43448af..a000680ab7 100644 --- a/pkg/controllers/nodeclaim/disruption/drift_test.go +++ b/pkg/controllers/nodeclaim/disruption/drift_test.go @@ -363,7 +363,7 @@ var _ = Describe("Drift", func() { "keyLabel2": "valueLabel2", }, }, - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: nodePool.Spec.Template.Spec.Requirements, NodeClassRef: &v1.NodeClassReference{ Kind: "fakeKind", @@ -411,13 +411,13 @@ var _ = Describe("Drift", func() { }, Entry("Annoations", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{ObjectMeta: v1.ObjectMeta{Annotations: map[string]string{"keyAnnotationTest": "valueAnnotationTest"}}}}}), Entry("Labels", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{ObjectMeta: v1.ObjectMeta{Labels: map[string]string{"keyLabelTest": "valueLabelTest"}}}}}), - Entry("Taints", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{Taints: []corev1.Taint{{Key: "keytest2taint", Effect: corev1.TaintEffectNoExecute}}}}}}), - Entry("StartupTaints", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{StartupTaints: []corev1.Taint{{Key: "keytest2taint", Effect: corev1.TaintEffectNoExecute}}}}}}), - Entry("NodeClassRef APIVersion", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{NodeClassRef: &v1.NodeClassReference{Group: "testVersion"}}}}}), - Entry("NodeClassRef Name", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{NodeClassRef: &v1.NodeClassReference{Name: "testName"}}}}}), - Entry("NodeClassRef Kind", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{NodeClassRef: &v1.NodeClassReference{Kind: "testKind"}}}}}), - Entry("ExpireAfter", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{ExpireAfter: v1.NillableDuration{Duration: lo.ToPtr(100 * time.Minute)}}}}}), - Entry("TerminationGracePeriod", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimSpec{TerminationGracePeriod: &metav1.Duration{Duration: 100 * time.Minute}}}}}), + Entry("Taints", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{Taints: []corev1.Taint{{Key: "keytest2taint", Effect: corev1.TaintEffectNoExecute}}}}}}), + Entry("StartupTaints", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{StartupTaints: []corev1.Taint{{Key: "keytest2taint", Effect: corev1.TaintEffectNoExecute}}}}}}), + Entry("NodeClassRef APIVersion", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{NodeClassRef: &v1.NodeClassReference{Group: "testVersion"}}}}}), + Entry("NodeClassRef Name", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{NodeClassRef: &v1.NodeClassReference{Name: "testName"}}}}}), + Entry("NodeClassRef Kind", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{NodeClassRef: &v1.NodeClassReference{Kind: "testKind"}}}}}), + Entry("ExpireAfter", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{ExpireAfter: v1.NillableDuration{Duration: lo.ToPtr(100 * time.Minute)}}}}}), + Entry("TerminationGracePeriod", v1.NodePool{Spec: v1.NodePoolSpec{Template: v1.NodeClaimTemplate{Spec: v1.NodeClaimTemplateSpec{TerminationGracePeriod: &metav1.Duration{Duration: 100 * time.Minute}}}}}), ) It("should not return drifted if karpenter.sh/nodepool-hash annotation is not present on the NodePool", func() { nodePool.ObjectMeta.Annotations = map[string]string{} diff --git a/pkg/controllers/nodepool/hash/suite_test.go b/pkg/controllers/nodepool/hash/suite_test.go index ee45b6ccf9..e9b15c193a 100644 --- a/pkg/controllers/nodepool/hash/suite_test.go +++ b/pkg/controllers/nodepool/hash/suite_test.go @@ -75,7 +75,7 @@ var _ = Describe("Static Drift Hash", func() { "keyLabel": "valueLabel", }, }, - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Taints: []corev1.Taint{ { Key: "key", diff --git a/pkg/controllers/provisioning/scheduling/instance_selection_test.go b/pkg/controllers/provisioning/scheduling/instance_selection_test.go index 31d821a3c1..ddc0f8d47a 100644 --- a/pkg/controllers/provisioning/scheduling/instance_selection_test.go +++ b/pkg/controllers/provisioning/scheduling/instance_selection_test.go @@ -50,7 +50,7 @@ var _ = Describe("Instance Type Selection", func() { nodePool = test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ diff --git a/pkg/controllers/provisioning/scheduling/nodeclaimtemplate.go b/pkg/controllers/provisioning/scheduling/nodeclaimtemplate.go index 14fa028c17..73e462076f 100644 --- a/pkg/controllers/provisioning/scheduling/nodeclaimtemplate.go +++ b/pkg/controllers/provisioning/scheduling/nodeclaimtemplate.go @@ -37,7 +37,7 @@ var MaxInstanceTypes = 60 // the fields in NodePool. These structs are maintained separately in order // for fields like Requirements to be able to be stored more efficiently. type NodeClaimTemplate struct { - v1.NodeClaimTemplate + v1.NodeClaim NodePoolName string InstanceTypeOptions cloudprovider.InstanceTypes @@ -46,9 +46,9 @@ type NodeClaimTemplate struct { func NewNodeClaimTemplate(nodePool *v1.NodePool) *NodeClaimTemplate { nct := &NodeClaimTemplate{ - NodeClaimTemplate: nodePool.Spec.Template, - NodePoolName: nodePool.Name, - Requirements: scheduling.NewRequirements(), + NodeClaim: *nodePool.Spec.Template.ToNodeClaim(), + NodePoolName: nodePool.Name, + Requirements: scheduling.NewRequirements(), } nct.Labels = lo.Assign(nct.Labels, map[string]string{v1.NodePoolLabelKey: nodePool.Name}) nct.Requirements.Add(scheduling.NewNodeSelectorRequirementsWithMinValues(nct.Spec.Requirements...).Values()...) diff --git a/pkg/controllers/provisioning/scheduling/scheduling_benchmark_test.go b/pkg/controllers/provisioning/scheduling/scheduling_benchmark_test.go index 349817ce33..1e4ab2540b 100644 --- a/pkg/controllers/provisioning/scheduling/scheduling_benchmark_test.go +++ b/pkg/controllers/provisioning/scheduling/scheduling_benchmark_test.go @@ -144,7 +144,7 @@ func benchmarkScheduler(b *testing.B, instanceCount, podCount int) { nodePoolWithMinValues := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ diff --git a/pkg/controllers/provisioning/scheduling/suite_test.go b/pkg/controllers/provisioning/scheduling/suite_test.go index 0b22b11ded..dab8a6d03d 100644 --- a/pkg/controllers/provisioning/scheduling/suite_test.go +++ b/pkg/controllers/provisioning/scheduling/suite_test.go @@ -126,7 +126,7 @@ var _ = Context("Scheduling", func() { nodePool = test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ diff --git a/pkg/controllers/provisioning/scheduling/topology_test.go b/pkg/controllers/provisioning/scheduling/topology_test.go index e2dfb60b25..ab1ee034b3 100644 --- a/pkg/controllers/provisioning/scheduling/topology_test.go +++ b/pkg/controllers/provisioning/scheduling/topology_test.go @@ -42,7 +42,7 @@ var _ = Describe("Topology", func() { nodePool = test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -969,7 +969,7 @@ var _ = Describe("Topology", func() { spotNodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -993,7 +993,7 @@ var _ = Describe("Topology", func() { onDemandNodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -1060,7 +1060,7 @@ var _ = Describe("Topology", func() { nodePoolB := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -2382,7 +2382,7 @@ var _ = Describe("Taints", func() { nodePool = test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ diff --git a/pkg/controllers/provisioning/suite_test.go b/pkg/controllers/provisioning/suite_test.go index ffd3f07483..c588e28b04 100644 --- a/pkg/controllers/provisioning/suite_test.go +++ b/pkg/controllers/provisioning/suite_test.go @@ -223,7 +223,7 @@ var _ = Describe("Provisioning", func() { ExpectApplied(ctx, env.Client, test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -608,7 +608,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ StartupTaints: []corev1.Taint{{Key: "foo.com/taint", Effect: corev1.TaintEffectNoSchedule}}, }, }, @@ -768,7 +768,7 @@ var _ = Describe("Provisioning", func() { test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Taints: []corev1.Taint{{Key: "foo", Value: "bar", Effect: corev1.TaintEffectNoSchedule}}, }, }, @@ -934,7 +934,7 @@ var _ = Describe("Provisioning", func() { ObjectMeta: v1.ObjectMeta{ Labels: map[string]string{"test-key-1": "test-value-1"}, }, - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ {NodeSelectorRequirement: corev1.NodeSelectorRequirement{Key: "test-key-2", Operator: corev1.NodeSelectorOpIn, Values: []string{"test-value-2"}}}, {NodeSelectorRequirement: corev1.NodeSelectorRequirement{Key: "test-key-3", Operator: corev1.NodeSelectorOpNotIn, Values: []string{"test-value-3"}}}, @@ -1010,7 +1010,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Taints: []corev1.Taint{{Key: "nvidia.com/gpu", Value: "true", Effect: corev1.TaintEffectNoSchedule}}, }, }, @@ -1081,7 +1081,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -1135,7 +1135,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -1174,7 +1174,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{ { NodeSelectorRequirement: corev1.NodeSelectorRequirement{ @@ -1258,7 +1258,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ NodeClassRef: &v1.NodeClassReference{ Group: "cloudprovider.karpenter.sh/v1", Kind: "CloudProvider", @@ -1735,7 +1735,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{{NodeSelectorRequirement: corev1.NodeSelectorRequirement{Key: corev1.LabelTopologyZone, Operator: corev1.NodeSelectorOpIn, Values: []string{"test-zone-1"}}}}, }, }, @@ -1811,7 +1811,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Requirements: []v1.NodeSelectorRequirementWithMinValues{{NodeSelectorRequirement: corev1.NodeSelectorRequirement{Key: corev1.LabelTopologyZone, Operator: corev1.NodeSelectorOpIn, Values: []string{"test-zone-1", "test-zone-2"}}}}, }, }, @@ -1840,7 +1840,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Taints: []corev1.Taint{{Key: "foo", Value: "bar", Effect: corev1.TaintEffectPreferNoSchedule}}, }, }, @@ -1882,7 +1882,7 @@ var _ = Describe("Provisioning", func() { nodePool := test.NodePool(v1.NodePool{ Spec: v1.NodePoolSpec{ Template: v1.NodeClaimTemplate{ - Spec: v1.NodeClaimSpec{ + Spec: v1.NodeClaimTemplateSpec{ Taints: []corev1.Taint{{Key: "foo", Value: "bar", Effect: corev1.TaintEffectPreferNoSchedule}}, }, },