Skip to content

Commit 1827939

Browse files
committed
refactor: move kubeProxy out of KubeadmClusterConfigSpec
1 parent d688d98 commit 1827939

File tree

6 files changed

+67
-50
lines changed

6 files changed

+67
-50
lines changed

api/v1alpha1/clusterconfig_types.go

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,10 @@ type AWSClusterConfigSpec struct {
8383
KubeadmClusterConfigSpec `json:",inline"`
8484
GenericClusterConfigSpec `json:",inline"`
8585

86+
// KubeProxy defines the configuration for kube-proxy.
87+
// +kubebuilder:validation:Optional
88+
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
89+
8690
// +kubebuilder:validation:Optional
8791
Addons *AWSAddons `json:"addons,omitempty"`
8892

@@ -121,6 +125,10 @@ type DockerClusterConfigSpec struct {
121125
KubeadmClusterConfigSpec `json:",inline"`
122126
GenericClusterConfigSpec `json:",inline"`
123127

128+
// KubeProxy defines the configuration for kube-proxy.
129+
// +kubebuilder:validation:Optional
130+
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
131+
124132
// +kubebuilder:validation:Optional
125133
Addons *DockerAddons `json:"addons,omitempty"`
126134

@@ -164,6 +172,10 @@ type NutanixClusterConfigSpec struct {
164172
KubeadmClusterConfigSpec `json:",inline"`
165173
GenericClusterConfigSpec `json:",inline"`
166174

175+
// KubeProxy defines the configuration for kube-proxy.
176+
// +kubebuilder:validation:Optional
177+
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
178+
167179
// +kubebuilder:validation:Optional
168180
Addons *NutanixAddons `json:"addons,omitempty"`
169181

@@ -206,6 +218,10 @@ type EKSClusterConfigSpec struct {
206218

207219
GenericClusterConfigSpec `json:",inline"`
208220

221+
// KubeProxy defines the configuration for kube-proxy.
222+
// +kubebuilder:validation:Optional
223+
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
224+
209225
// +kubebuilder:validation:Optional
210226
Addons *AWSAddons `json:"addons,omitempty"`
211227
}
@@ -243,10 +259,6 @@ type KubeadmClusterConfigSpec struct {
243259
// +kubebuilder:validation:Optional
244260
DNS *DNS `json:"dns,omitempty"`
245261

246-
// KubeProxy defines the configuration for kube-proxy.
247-
// +kubebuilder:validation:Optional
248-
KubeProxy *KubeProxy `json:"kubeProxy,omitempty"`
249-
250262
// MaxParallelImagePullsPerNode defines the maximum number of parallel image pulls performed by each kubelet.
251263
// If not set, the default value of 1 will be used.
252264
// If set to 0, the maximum number of parallel image pulls will be unlimited.

api/v1alpha1/crds/caren.nutanix.com_eksclusterconfigs.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -435,6 +435,22 @@ spec:
435435
type: object
436436
maxItems: 32
437437
type: array
438+
kubeProxy:
439+
description: KubeProxy defines the configuration for kube-proxy.
440+
properties:
441+
mode:
442+
description: |-
443+
Mode specifies the mode for kube-proxy:
444+
- iptables means that kube-proxy is installed in iptables mode.
445+
- nftables means that kube-proxy is installed in nftables mode.
446+
enum:
447+
- iptables
448+
- nftables
449+
type: string
450+
x-kubernetes-validations:
451+
- message: Value cannot be changed after cluster creation
452+
rule: self == oldSelf
453+
type: object
438454
ntp:
439455
description: NTP defines the NTP configuration for the cluster.
440456
properties:

api/v1alpha1/crds/caren.nutanix.com_kubeadmclusterconfigs.yaml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -112,22 +112,6 @@ spec:
112112
type: string
113113
type: object
114114
type: object
115-
kubeProxy:
116-
description: KubeProxy defines the configuration for kube-proxy.
117-
properties:
118-
mode:
119-
description: |-
120-
Mode specifies the mode for kube-proxy:
121-
- iptables means that kube-proxy is installed in iptables mode.
122-
- nftables means that kube-proxy is installed in nftables mode.
123-
enum:
124-
- iptables
125-
- nftables
126-
type: string
127-
x-kubernetes-validations:
128-
- message: Value cannot be changed after cluster creation
129-
rule: self == oldSelf
130-
type: object
131115
kubernetesImageRepository:
132116
description: Sets the Kubernetes image repository used for the KubeadmControlPlane.
133117
maxLength: 2048

api/v1alpha1/zz_generated.deepcopy.go

Lines changed: 20 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/variables/aggregate_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ type ClusterConfigSpec struct {
2525
carenv1.KubeadmClusterConfigSpec `json:",inline"`
2626
carenv1.GenericClusterConfigSpec `json:",inline"`
2727

28+
KubeProxy *carenv1.KubeProxy `json:"kubeProxy,omitempty"`
29+
2830
Addons *Addons `json:"addons,omitempty"`
2931

3032
ControlPlane *ControlPlaneSpec `json:"controlPlane,omitempty"`

pkg/handlers/generic/mutation/kubeproxymode/inject_test.go

Lines changed: 13 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -165,11 +165,9 @@ var _ = Describe("Generate kube proxy mode patches", func() {
165165
Vars: []runtimehooksv1.Variable{
166166
capitest.VariableWithValue(
167167
v1alpha1.ClusterConfigVariableName,
168-
v1alpha1.AWSClusterConfigSpec{
169-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
170-
KubeProxy: &v1alpha1.KubeProxy{
171-
Mode: v1alpha1.KubeProxyModeIPTables,
172-
},
168+
v1alpha1.NutanixClusterConfigSpec{
169+
KubeProxy: &v1alpha1.KubeProxy{
170+
Mode: v1alpha1.KubeProxyModeIPTables,
173171
},
174172
},
175173
),
@@ -215,10 +213,8 @@ mode: iptables
215213
capitest.VariableWithValue(
216214
v1alpha1.ClusterConfigVariableName,
217215
v1alpha1.AWSClusterConfigSpec{
218-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
219-
KubeProxy: &v1alpha1.KubeProxy{
220-
Mode: v1alpha1.KubeProxyModeIPTables,
221-
},
216+
KubeProxy: &v1alpha1.KubeProxy{
217+
Mode: v1alpha1.KubeProxyModeIPTables,
222218
},
223219
},
224220
),
@@ -264,10 +260,8 @@ mode: iptables
264260
capitest.VariableWithValue(
265261
v1alpha1.ClusterConfigVariableName,
266262
v1alpha1.DockerClusterConfigSpec{
267-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
268-
KubeProxy: &v1alpha1.KubeProxy{
269-
Mode: v1alpha1.KubeProxyModeIPTables,
270-
},
263+
KubeProxy: &v1alpha1.KubeProxy{
264+
Mode: v1alpha1.KubeProxyModeIPTables,
271265
},
272266
},
273267
),
@@ -313,10 +307,8 @@ mode: iptables
313307
capitest.VariableWithValue(
314308
v1alpha1.ClusterConfigVariableName,
315309
v1alpha1.NutanixClusterConfigSpec{
316-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
317-
KubeProxy: &v1alpha1.KubeProxy{
318-
Mode: v1alpha1.KubeProxyModeNFTables,
319-
},
310+
KubeProxy: &v1alpha1.KubeProxy{
311+
Mode: v1alpha1.KubeProxyModeNFTables,
320312
},
321313
},
322314
),
@@ -362,10 +354,8 @@ mode: nftables
362354
capitest.VariableWithValue(
363355
v1alpha1.ClusterConfigVariableName,
364356
v1alpha1.AWSClusterConfigSpec{
365-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
366-
KubeProxy: &v1alpha1.KubeProxy{
367-
Mode: v1alpha1.KubeProxyModeNFTables,
368-
},
357+
KubeProxy: &v1alpha1.KubeProxy{
358+
Mode: v1alpha1.KubeProxyModeNFTables,
369359
},
370360
},
371361
),
@@ -411,10 +401,8 @@ mode: nftables
411401
capitest.VariableWithValue(
412402
v1alpha1.ClusterConfigVariableName,
413403
v1alpha1.DockerClusterConfigSpec{
414-
KubeadmClusterConfigSpec: v1alpha1.KubeadmClusterConfigSpec{
415-
KubeProxy: &v1alpha1.KubeProxy{
416-
Mode: v1alpha1.KubeProxyModeNFTables,
417-
},
404+
KubeProxy: &v1alpha1.KubeProxy{
405+
Mode: v1alpha1.KubeProxyModeNFTables,
418406
},
419407
},
420408
),

0 commit comments

Comments
 (0)