Skip to content

Commit d470da3

Browse files
committed
fix: allows nodeadm template spec to be nullable
1 parent ee324f2 commit d470da3

File tree

5 files changed

+27
-14
lines changed

5 files changed

+27
-14
lines changed

bootstrap/eks/api/v1beta2/nodeadmconfigtemplate_type.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,11 @@ type NodeadmConfigTemplateSpec struct {
2727

2828
// NodeadmConfigTemplateResource defines the Template structure.
2929
type NodeadmConfigTemplateResource struct {
30+
// Spec represents the NodeadmConfig each object created from the template will become.
31+
// We are setting nullable to avoid this issue:
32+
// https://github.com/kubernetes/kubernetes/issues/117447#issuecomment-2127733969
33+
// where we cannot remove all fields with an SSA patch if they were previously set.
34+
// +nullable
3035
Spec NodeadmConfigSpec `json:"spec,omitempty"`
3136
}
3237

bootstrap/eks/controllers/nodeadmconfig_controller.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ func (r *NodeadmConfigReconciler) joinWorker(ctx context.Context, cluster *clust
209209
Mounts: config.Spec.Mounts,
210210
Files: files,
211211
ServiceCIDR: serviceCIDR,
212-
APIServerEndpoint: controlPlane.Spec.ControlPlaneEndpoint.Host,
212+
APIServerEndpoint: cluster.Spec.ControlPlaneEndpoint.Host,
213213
}
214214
if config.Spec.Kubelet != nil {
215215
nodeInput.KubeletFlags = config.Spec.Kubelet.Flags

bootstrap/eks/controllers/nodeadmconfig_controller_reconciler_test.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ func TestNodeadmConfigReconciler_CreateSecret(t *testing.T) {
3939
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
4040
amcp.Spec.ControlPlaneEndpoint = endpoint
4141
cluster := newCluster(amcp.Name)
42+
cluster.Spec.ControlPlaneEndpoint = endpoint
4243
newStatus := cluster.Status
4344
amcpStatus := amcp.Status
4445
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
@@ -77,6 +78,7 @@ func TestNodeadmConfigReconciler_UpdateSecret_ForMachinePool(t *testing.T) {
7778
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
7879
amcp.Spec.ControlPlaneEndpoint = endpoint
7980
cluster := newCluster(amcp.Name)
81+
cluster.Spec.ControlPlaneEndpoint = endpoint
8082
newStatus := cluster.Status
8183
amcpStatus := amcp.Status
8284
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())
@@ -137,6 +139,7 @@ func TestNodeadmConfigReconciler_ResolvesSecretFileReference(t *testing.T) {
137139
endpoint := clusterv1.APIEndpoint{Host: "https://9.9.9.9", Port: 6443}
138140
amcp.Spec.ControlPlaneEndpoint = endpoint
139141
cluster := newCluster(amcp.Name)
142+
cluster.Spec.ControlPlaneEndpoint = endpoint
140143
newStatus := cluster.Status
141144
amcpStatus := amcp.Status
142145
g.Expect(testEnv.Client.Create(ctx, amcp)).To(Succeed())

config/crd/bases/bootstrap.cluster.x-k8s.io_nodeadmconfigs.yaml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,6 @@ spec:
3939
spec:
4040
description: NodeadmConfigSpec defines the desired state of NodeadmConfig.
4141
properties:
42-
PreNodeadmCommands:
43-
description: PreNodeadmCommands specifies extra commands to run before
44-
bootstrapping nodes.
45-
items:
46-
type: string
47-
type: array
4842
containerd:
4943
description: Containerd contains options for containerd.
5044
properties:
@@ -233,6 +227,12 @@ spec:
233227
type: string
234228
type: array
235229
type: object
230+
preNodeadmCommands:
231+
description: PreNodeadmCommands specifies extra commands to run before
232+
bootstrapping nodes.
233+
items:
234+
type: string
235+
type: array
236236
users:
237237
description: Users specifies extra users to add.
238238
items:

config/crd/bases/bootstrap.cluster.x-k8s.io_nodeadmconfigtemplates.yaml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,14 +49,13 @@ spec:
4949
description: NodeadmConfigTemplateResource defines the Template structure.
5050
properties:
5151
spec:
52-
description: NodeadmConfigSpec defines the desired state of NodeadmConfig.
52+
description: |-
53+
Spec represents the NodeadmConfig each object created from the template will become.
54+
We are setting nullable to avoid this issue:
55+
https://github.com/kubernetes/kubernetes/issues/117447#issuecomment-2127733969
56+
where we cannot remove all fields with an SSA patch if they were previously set.
57+
nullable: true
5358
properties:
54-
PreNodeadmCommands:
55-
description: PreNodeadmCommands specifies extra commands to
56-
run before bootstrapping nodes.
57-
items:
58-
type: string
59-
type: array
6059
containerd:
6160
description: Containerd contains options for containerd.
6261
properties:
@@ -252,6 +251,12 @@ spec:
252251
type: string
253252
type: array
254253
type: object
254+
preNodeadmCommands:
255+
description: PreNodeadmCommands specifies extra commands to
256+
run before bootstrapping nodes.
257+
items:
258+
type: string
259+
type: array
255260
users:
256261
description: Users specifies extra users to add.
257262
items:

0 commit comments

Comments
 (0)