@@ -13,6 +13,7 @@ import (
13
13
apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1"
14
14
runtimehooksv1 "sigs.k8s.io/cluster-api/exp/runtime/hooks/api/v1alpha1"
15
15
16
+ eksbootstrapv1 "github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/external/sigs.k8s.io/cluster-api-provider-aws/v2/bootstrap/eks/api/v1beta2"
16
17
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/api/v1alpha1"
17
18
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/capi/clustertopology/handlers/mutation"
18
19
"github.com/nutanix-cloud-native/cluster-api-runtime-extensions-nutanix/common/pkg/testutils/capitest"
@@ -59,7 +60,7 @@ var _ = Describe("Generate taints patches for Worker", func() {
59
60
}},
60
61
},
61
62
{
62
- Name : "taints for workers set for EKSConfigTemplate " ,
63
+ Name : "taints for workers set for NodeadmConfigTemplate " ,
63
64
Vars : []runtimehooksv1.Variable {
64
65
capitest .VariableWithValue (
65
66
v1alpha1 .WorkerConfigVariableName ,
@@ -77,15 +78,88 @@ var _ = Describe("Generate taints patches for Worker", func() {
77
78
},
78
79
),
79
80
},
80
- RequestItem : testutils .NewEKSConfigTemplateRequestItem ("" ),
81
+ RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" ),
81
82
ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
82
83
Operation : "add" ,
83
- Path : "/spec/template/spec/kubeletExtraArgs " ,
84
+ Path : "/spec/template/spec/kubelet " ,
84
85
ValueMatcher : gomega .HaveKeyWithValue (
85
- "register-with-taints" , "key=value:NoExecute" ,
86
+ "flags" ,
87
+ gomega .ContainElement ("--register-with-taints=key=value:NoExecute" ),
86
88
),
87
89
}},
88
90
},
91
+ {
92
+ Name : "taints for workers set for NodeadmConfigTemplate with existing flags argument" ,
93
+ Vars : []runtimehooksv1.Variable {
94
+ capitest .VariableWithValue (
95
+ v1alpha1 .WorkerConfigVariableName ,
96
+ []v1alpha1.Taint {{
97
+ Key : "key" ,
98
+ Effect : v1alpha1 .TaintEffectNoExecute ,
99
+ Value : "value" ,
100
+ }},
101
+ VariableName ,
102
+ ),
103
+ capitest .VariableWithValue (
104
+ "builtin" ,
105
+ apiextensionsv1.JSON {
106
+ Raw : []byte (`{"machineDeployment": {"class": "a-worker"}}` ),
107
+ },
108
+ ),
109
+ },
110
+ RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" , eksbootstrapv1.NodeadmConfigTemplateSpec {
111
+ Template : eksbootstrapv1.NodeadmConfigTemplateResource {
112
+ Spec : eksbootstrapv1.NodeadmConfigSpec {
113
+ Kubelet : & eksbootstrapv1.KubeletOptions {
114
+ Flags : []string {
115
+ "--max-pods=110" ,
116
+ },
117
+ },
118
+ },
119
+ },
120
+ }),
121
+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
122
+ Operation : "add" ,
123
+ Path : "/spec/template/spec/kubelet/flags/1" ,
124
+ ValueMatcher : gomega .Equal ("--register-with-taints=key=value:NoExecute" ),
125
+ }},
126
+ },
127
+ {
128
+ Name : "taints for workers set for NodeadmConfigTemplate with existing flags with register-with-taints " ,
129
+ Vars : []runtimehooksv1.Variable {
130
+ capitest .VariableWithValue (
131
+ v1alpha1 .WorkerConfigVariableName ,
132
+ []v1alpha1.Taint {{
133
+ Key : "key" ,
134
+ Effect : v1alpha1 .TaintEffectNoExecute ,
135
+ Value : "value" ,
136
+ }},
137
+ VariableName ,
138
+ ),
139
+ capitest .VariableWithValue (
140
+ "builtin" ,
141
+ apiextensionsv1.JSON {
142
+ Raw : []byte (`{"machineDeployment": {"class": "a-worker"}}` ),
143
+ },
144
+ ),
145
+ },
146
+ RequestItem : testutils .NewNodeadmConfigTemplateRequestItem ("" , eksbootstrapv1.NodeadmConfigTemplateSpec {
147
+ Template : eksbootstrapv1.NodeadmConfigTemplateResource {
148
+ Spec : eksbootstrapv1.NodeadmConfigSpec {
149
+ Kubelet : & eksbootstrapv1.KubeletOptions {
150
+ Flags : []string {
151
+ "--register-with-taints=key1=value1:NoSchedule" ,
152
+ },
153
+ },
154
+ },
155
+ },
156
+ }),
157
+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
158
+ Operation : "add" ,
159
+ Path : "/spec/template/spec/kubelet/flags/1" ,
160
+ ValueMatcher : gomega .Equal ("--register-with-taints=key=value:NoExecute" ),
161
+ }},
162
+ },
89
163
}
90
164
91
165
// create test node for each case
0 commit comments