Skip to content

Commit c758572

Browse files
committed
wip3
1 parent 0351bbb commit c758572

File tree

8 files changed

+194
-94
lines changed

8 files changed

+194
-94
lines changed

Makefile.gen.app.mk

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ lint-chart: check-env ## Runs ct against the default chart.
2222
rm -rf /tmp/$(APPLICATION)-test
2323
mkdir -p /tmp/$(APPLICATION)-test/helm
2424
cp -a ./helm/$(APPLICATION) /tmp/$(APPLICATION)-test/helm/
25-
architect helm template --dir /tmp/$(APPLICATION)-test/helm/$(APPLICATION)
2625
docker run -it --rm -v /tmp/$(APPLICATION)-test:/wd --workdir=/wd --name ct $(IMAGE) ct lint --validate-maintainers=false --charts="helm/$(APPLICATION)"
2726
rm -rf /tmp/$(APPLICATION)-test
2827

Makefile.gen.go.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ GITSHA1 := $(shell git rev-parse --verify HEAD)
1111
MODULE := $(shell go list -m)
1212
OS := $(shell go env GOOS)
1313
SOURCES := $(shell find . -name '*.go')
14-
VERSION := $(shell architect project version)
14+
1515
ifeq ($(OS), linux)
1616
EXTLDFLAGS := -static
1717
endif

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

controllers/karpentermachinepool_controller.go

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,8 @@ const (
4444
KarpenterNodePoolReadyCondition capi.ConditionType = "KarpenterNodePoolReadyCondition"
4545
// WaitingForBootstrapDataReason used when machine is waiting for bootstrap data to be ready before proceeding.
4646
WaitingForBootstrapDataReason = "WaitingForBootstrapData"
47-
// NodePoolCreatedReason indicates that the NodePool was successfully created
48-
NodePoolCreatedReason = "NodePoolCreated"
4947
// NodePoolCreationFailedReason indicates that the NodePool creation failed
5048
NodePoolCreationFailedReason = "NodePoolCreationFailed"
51-
// EC2NodeClassCreatedReason indicates that the EC2NodeClass was successfully created
52-
EC2NodeClassCreatedReason = "EC2NodeClassCreated"
5349
// EC2NodeClassCreationFailedReason indicates that the EC2NodeClass creation failed
5450
EC2NodeClassCreationFailedReason = "EC2NodeClassCreationFailed"
5551
// VersionSkewBlockedReason indicates that the update was blocked due to version skew policy
@@ -155,6 +151,12 @@ func (r *KarpenterMachinePoolReconciler) Reconcile(ctx context.Context, req reco
155151
}
156152
}
157153

154+
// Create or update Karpenter resources in the workload cluster
155+
if err := r.createOrUpdateKarpenterResources(ctx, logger, cluster, awsCluster, karpenterMachinePool, machinePool, bootstrapSecretValue); err != nil {
156+
logger.Error(err, "failed to create or update Karpenter resources")
157+
return reconcile.Result{}, err
158+
}
159+
158160
bootstrapUserDataHash := fmt.Sprintf("%x", sha256.Sum256(bootstrapSecretValue))
159161
previousHash, annotationHashExists := karpenterMachinePool.Annotations[BootstrapDataHashAnnotation]
160162
if !annotationHashExists || previousHash != bootstrapUserDataHash {
@@ -181,12 +183,6 @@ func (r *KarpenterMachinePoolReconciler) Reconcile(ctx context.Context, req reco
181183
}
182184
}
183185

184-
// Create or update Karpenter resources in the workload cluster
185-
if err := r.createOrUpdateKarpenterResources(ctx, logger, cluster, awsCluster, karpenterMachinePool, machinePool, bootstrapSecretValue); err != nil {
186-
logger.Error(err, "failed to create or update Karpenter resources")
187-
return reconcile.Result{}, err
188-
}
189-
190186
providerIDList, numberOfNodeClaims, err := r.computeProviderIDListFromNodeClaimsInWorkloadCluster(ctx, logger, cluster)
191187
if err != nil {
192188
return reconcile.Result{}, err
@@ -407,7 +403,7 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateKarpenterResources(ctx co
407403
func (r *KarpenterMachinePoolReconciler) createOrUpdateEC2NodeClass(ctx context.Context, logger logr.Logger, workloadClusterClient client.Client, cluster *capi.Cluster, awsCluster *capa.AWSCluster, karpenterMachinePool *v1alpha1.KarpenterMachinePool, bootstrapSecretValue []byte) error {
408404
ec2NodeClassGVR := schema.GroupVersionResource{
409405
Group: "karpenter.k8s.aws",
410-
Version: "v1beta1",
406+
Version: "v1",
411407
Resource: "ec2nodeclasses",
412408
}
413409

@@ -485,7 +481,7 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateEC2NodeClass(ctx context.
485481
func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Context, logger logr.Logger, workloadClusterClient client.Client, karpenterMachinePool *v1alpha1.KarpenterMachinePool) error {
486482
nodePoolGVR := schema.GroupVersionResource{
487483
Group: "karpenter.sh",
488-
Version: "v1beta1",
484+
Version: "v1",
489485
Resource: "nodepools",
490486
}
491487

@@ -503,10 +499,12 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
503499
"template": map[string]interface{}{
504500
"spec": map[string]interface{}{
505501
"nodeClassRef": map[string]interface{}{
506-
"apiVersion": "karpenter.k8s.aws/v1beta1",
502+
"apiVersion": "karpenter.k8s.aws/v1",
503+
"group": "karpenter.k8s.aws",
507504
"kind": "EC2NodeClass",
508505
"name": karpenterMachinePool.Name,
509506
},
507+
"requirements": []interface{}{},
510508
},
511509
},
512510
}
@@ -547,7 +545,8 @@ func (r *KarpenterMachinePoolReconciler) createOrUpdateNodePool(ctx context.Cont
547545
}
548546
requirements = append(requirements, requirement)
549547
}
550-
spec["requirements"] = requirements
548+
549+
spec["template"].(map[string]interface{})["spec"].(map[string]interface{})["requirements"] = requirements
551550
}
552551

553552
if len(karpenterMachinePool.Spec.NodePool.Taints) > 0 {
@@ -602,7 +601,7 @@ func (r *KarpenterMachinePoolReconciler) deleteKarpenterResources(ctx context.Co
602601
// Delete NodePool
603602
nodePoolGVR := schema.GroupVersionResource{
604603
Group: "karpenter.sh",
605-
Version: "v1beta1",
604+
Version: "v1",
606605
Resource: "nodepools",
607606
}
608607

@@ -619,7 +618,7 @@ func (r *KarpenterMachinePoolReconciler) deleteKarpenterResources(ctx context.Co
619618
// Delete EC2NodeClass
620619
ec2NodeClassGVR := schema.GroupVersionResource{
621620
Group: "karpenter.k8s.aws",
622-
Version: "v1beta1",
621+
Version: "v1",
623622
Resource: "ec2nodeclasses",
624623
}
625624

0 commit comments

Comments
 (0)