@@ -158,6 +158,56 @@ var _ = Describe("Generate kube proxy mode patches", func() {
158158 },
159159 },
160160 },
161+ }, {
162+ patchTest : capitest.PatchTestDef {
163+ Name : "kube proxy iptables mode with Nutanix" ,
164+ Vars : []runtimehooksv1.Variable {
165+ capitest .VariableWithValue (
166+ v1alpha1 .ClusterConfigVariableName ,
167+ v1alpha1.AWSClusterConfigSpec {
168+ GenericClusterConfigSpec : v1alpha1.GenericClusterConfigSpec {
169+ KubeProxy : & v1alpha1.KubeProxy {
170+ Mode : v1alpha1 .KubeProxyModeIPTables ,
171+ },
172+ },
173+ },
174+ ),
175+ },
176+ RequestItem : request .NewKubeadmControlPlaneTemplateRequestItem ("" ),
177+ ExpectedPatchMatchers : []capitest.JSONPatchMatcher {{
178+ Operation : "add" ,
179+ Path : "/spec/template/spec/kubeadmConfigSpec/files" ,
180+ ValueMatcher : gomega .ConsistOf (
181+ gomega .SatisfyAll (
182+ gomega .HaveKeyWithValue ("path" , "/etc/kubernetes/kubeproxy-config.yaml" ),
183+ gomega .HaveKeyWithValue ("owner" , "root:root" ),
184+ gomega .HaveKeyWithValue ("permissions" , "0644" ),
185+ gomega .HaveKeyWithValue ("content" , `
186+ ---
187+ apiVersion: kubeproxy.config.k8s.io/v1alpha1
188+ kind: KubeProxyConfiguration
189+ mode: iptables
190+ ` ,
191+ ),
192+ ),
193+ ),
194+ }, {
195+ Operation : "add" ,
196+ Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
197+ ValueMatcher : gomega .ConsistOf (
198+ `/bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: iptables/" /run/kubeadm/kubeadm.yaml) || (cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
199+ ),
200+ }},
201+ },
202+ cluster : & clusterv1.Cluster {
203+ ObjectMeta : metav1.ObjectMeta {
204+ Name : "test-cluster" ,
205+ Namespace : request .Namespace ,
206+ Labels : map [string ]string {
207+ clusterv1 .ProviderNameLabel : "nutanix" ,
208+ },
209+ },
210+ },
161211 }, {
162212 patchTest : capitest.PatchTestDef {
163213 Name : "kube proxy iptables mode with AWS" ,
@@ -195,7 +245,7 @@ mode: iptables
195245 Operation : "add" ,
196246 Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
197247 ValueMatcher : gomega .ConsistOf (
198- " /bin/sh -ec 'cat /etc/kubernetes/kubeproxy-config.yaml >> /run/kubeadm/kubeadm.yaml'" ,
248+ ` /bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: iptables/" /run/kubeadm/kubeadm.yaml) || ( cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
199249 ),
200250 }},
201251 },
@@ -233,6 +283,9 @@ mode: iptables
233283 gomega .HaveKeyWithValue ("owner" , "root:root" ),
234284 gomega .HaveKeyWithValue ("permissions" , "0644" ),
235285 gomega .HaveKeyWithValue ("content" , `
286+ ---
287+ apiVersion: kubeproxy.config.k8s.io/v1alpha1
288+ kind: KubeProxyConfiguration
236289mode: iptables
237290` ,
238291 ),
@@ -242,7 +295,7 @@ mode: iptables
242295 Operation : "add" ,
243296 Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
244297 ValueMatcher : gomega .ConsistOf (
245- " /bin/sh -ec 'cat /etc/kubernetes/kubeproxy-config.yaml >> /run/kubeadm/kubeadm.yaml'" ,
298+ ` /bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: iptables/" /run/kubeadm/kubeadm.yaml) || ( cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
246299 ),
247300 }},
248301 },
@@ -292,7 +345,7 @@ mode: nftables
292345 Operation : "add" ,
293346 Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
294347 ValueMatcher : gomega .ConsistOf (
295- " /bin/sh -ec 'cat /etc/kubernetes/kubeproxy-config.yaml >> /run/kubeadm/kubeadm.yaml'" ,
348+ ` /bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: nftables/" /run/kubeadm/kubeadm.yaml) || ( cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
296349 ),
297350 }},
298351 },
@@ -342,7 +395,7 @@ mode: nftables
342395 Operation : "add" ,
343396 Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
344397 ValueMatcher : gomega .ConsistOf (
345- " /bin/sh -ec 'cat /etc/kubernetes/kubeproxy-config.yaml >> /run/kubeadm/kubeadm.yaml'" ,
398+ ` /bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: nftables/" /run/kubeadm/kubeadm.yaml) || ( cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
346399 ),
347400 }},
348401 },
@@ -380,6 +433,9 @@ mode: nftables
380433 gomega .HaveKeyWithValue ("owner" , "root:root" ),
381434 gomega .HaveKeyWithValue ("permissions" , "0644" ),
382435 gomega .HaveKeyWithValue ("content" , `
436+ ---
437+ apiVersion: kubeproxy.config.k8s.io/v1alpha1
438+ kind: KubeProxyConfiguration
383439mode: nftables
384440` ,
385441 ),
@@ -389,7 +445,7 @@ mode: nftables
389445 Operation : "add" ,
390446 Path : "/spec/template/spec/kubeadmConfigSpec/preKubeadmCommands" ,
391447 ValueMatcher : gomega .ConsistOf (
392- " /bin/sh -ec 'cat /etc/kubernetes/kubeproxy-config.yaml >> /run/kubeadm/kubeadm.yaml'" ,
448+ ` /bin/sh -ec '(grep -q "^kind: KubeProxyConfiguration$" /run/kubeadm/kubeadm.yaml && sed -i -e "s/^\(kind: KubeProxyConfiguration\)$/\1\nmode: nftables/" /run/kubeadm/kubeadm.yaml) || ( cat /etc/kubernetes/kubeproxy-config.yaml >>/run/kubeadm/kubeadm.yaml)'` , //nolint:lll // Just a long command.
393449 ),
394450 }},
395451 },
0 commit comments