Skip to content

Commit 5556b02

Browse files
committed
fix: adds ami details for nodeadm configs (#1334)
**What problem does this PR solve?**: adds details required for al 2023 **Which issue(s) this PR fixes**: stacked on #1332 **How Has This Been Tested?**: <!-- Please describe the tests that you ran to verify your changes. Provide output from the tests and any manual steps needed to replicate the tests. --> **Special notes for your reviewer**: <!-- Use this to provide any additional information to the reviewers. This may include: - Best way to review the PR. - Where the author wants the most review attention on. - etc. -->
1 parent 9592e74 commit 5556b02

File tree

4 files changed

+19
-18
lines changed

4 files changed

+19
-18
lines changed

charts/cluster-api-runtime-extensions-nutanix/defaultclusterclasses/eks-cluster-class.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ spec:
3131
bootstrap:
3232
ref:
3333
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
34-
kind: EKSConfigTemplate
35-
name: quick-start-worker-configtemplate
34+
kind: NodeadmConfigTemplate
35+
name: eks-quick-start-worker-configtemplate
3636
infrastructure:
3737
ref:
3838
apiVersion: infrastructure.cluster.x-k8s.io/v1beta2
@@ -73,6 +73,11 @@ metadata:
7373
spec:
7474
template:
7575
spec:
76+
ami:
77+
eksLookupType: AmazonLinux2023
78+
instanceMetadataOptions:
79+
httpPutResponseHopLimit: 2
80+
httpTokens: required
7681
instanceType: PLACEHOLDER
7782
sshKeyName: ""
7883
---

hack/examples/bases/eks/clusterclass/clusterclass.yaml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ spec:
2424
ref:
2525
name: "quick-start-worker-configtemplate"
2626
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
27-
kind: EKSConfigTemplate
27+
kind: NodeadmConfigTemplate
2828
infrastructure:
2929
ref:
3030
name: "quick-start-worker-machinetemplate"
@@ -58,7 +58,12 @@ metadata:
5858
name: "quick-start-worker-machinetemplate"
5959
spec:
6060
template:
61-
spec: {}
61+
spec:
62+
ami:
63+
eksLookupType: AmazonLinux2023
64+
instanceMetadataOptions:
65+
httpTokens: required
66+
httpPutResponseHopLimit: 2
6267
---
6368
apiVersion: bootstrap.cluster.x-k8s.io/v1beta2
6469
kind: NodeadmConfigTemplate

hack/examples/overlays/clusterclasses/eks/kustomizeconfig.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ nameReference:
1616
fieldSpecs:
1717
- kind: ClusterClass
1818
path: spec/controlPlane/ref/name
19-
- kind: EKSConfigTemplate
19+
- kind: NodeadmConfigTemplate
2020
fieldSpecs:
2121
- kind: ClusterClass
2222
path: spec/workers/machineDeployments/template/bootstrap/ref/name

pkg/handlers/generic/mutation/taints/inject_worker.go

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import (
1212
v1 "k8s.io/api/core/v1"
1313
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
1414
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
15-
"k8s.io/apimachinery/pkg/runtime"
15+
"k8s.io/utils/ptr"
1616
bootstrapv1 "sigs.k8s.io/cluster-api/bootstrap/kubeadm/api/v1beta1"
1717
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
1818
ctrl "sigs.k8s.io/controller-runtime"
@@ -115,19 +115,10 @@ func (h *taintsWorkerPatchHandler) Mutate(
115115
"patchedObjectKind", obj.GetObjectKind().GroupVersionKind().String(),
116116
"patchedObjectName", ctrlclient.ObjectKeyFromObject(obj),
117117
).Info("adding taints to worker NodeadmConfig template")
118-
kubeletOptions := obj.Spec.Template.Spec.Kubelet
119-
var runtimeConfigFromNodeadm *runtime.RawExtension
120-
var flags []string
121118
newTaints := toEKSConfigTaints(taintsVar)
122-
if kubeletOptions != nil {
123-
runtimeConfigFromNodeadm = kubeletOptions.Config
124-
flags = kubeletOptions.Flags
125-
}
126-
flags = append(flags, fmt.Sprintf("--register-with-taints=%s", newTaints))
127-
obj.Spec.Template.Spec.Kubelet = &eksbootstrapv1.KubeletOptions{
128-
Flags: flags,
129-
Config: runtimeConfigFromNodeadm,
130-
}
119+
kubeletOptions := ptr.Deref(obj.Spec.Template.Spec.Kubelet, eksbootstrapv1.KubeletOptions{})
120+
kubeletOptions.Flags = append(kubeletOptions.Flags, fmt.Sprintf("--register-with-taints=%s", newTaints))
121+
obj.Spec.Template.Spec.Kubelet = &kubeletOptions
131122
return nil
132123
}); err != nil {
133124
return err

0 commit comments

Comments
 (0)