Skip to content

Commit df65ac9

Browse files
committed
✨ Allow to disable KubeProxy and CoreDNS
See #12288
1 parent 393485e commit df65ac9

File tree

12 files changed

+190
-32
lines changed

12 files changed

+190
-32
lines changed

api/bootstrap/kubeadm/v1beta1/kubeadm_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ type ClusterConfiguration struct {
159159
// +kubebuilder:validation:MinLength=1
160160
// +kubebuilder:validation:MaxLength=63
161161
ClusterName string `json:"clusterName,omitempty"`
162+
163+
// Proxy defines the options for the proxy add-on installed in the cluster.
164+
Proxy Proxy `json:"proxy,omitempty"`
162165
}
163166

164167
// ControlPlaneComponent holds settings common to control plane component of the cluster.
@@ -201,6 +204,15 @@ type APIServer struct {
201204
type DNS struct {
202205
// ImageMeta allows to customize the image used for the DNS component
203206
ImageMeta `json:",inline"`
207+
208+
// Disabled specifies whether to disable this addon in the cluster
209+
Disabled bool `json:"disabled,omitempty"`
210+
}
211+
212+
// Proxy defines the proxy addon that should be used in the cluster
213+
type Proxy struct {
214+
// Disabled specifies whether to disable this addon in the cluster
215+
Disabled bool `json:"disabled,omitempty"`
204216
}
205217

206218
// ImageMeta allows to customize the image used for components that are not

api/bootstrap/kubeadm/v1beta1/zz_generated.conversion.go

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

api/bootstrap/kubeadm/v1beta2/kubeadm_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,9 @@ type ClusterConfiguration struct {
164164
// featureGates enabled by the user.
165165
// +optional
166166
FeatureGates map[string]bool `json:"featureGates,omitempty"`
167+
168+
// Proxy defines the options for the proxy add-on installed in the cluster.
169+
Proxy Proxy `json:"proxy,omitempty"`
167170
}
168171

169172
// ControlPlaneComponent holds settings common to control plane component of the cluster.
@@ -209,6 +212,15 @@ type APIServer struct {
209212
type DNS struct {
210213
// ImageMeta allows to customize the image used for the DNS component
211214
ImageMeta `json:",inline"`
215+
216+
// Disabled specifies whether to disable this addon in the cluster
217+
Disabled bool `json:"disabled,omitempty"`
218+
}
219+
220+
// Proxy defines the proxy addon that should be used in the cluster
221+
type Proxy struct {
222+
// Disabled specifies whether to disable this addon in the cluster
223+
Disabled bool `json:"disabled,omitempty"`
212224
}
213225

214226
// ImageMeta allows to customize the image used for components that are not

api/bootstrap/kubeadm/v1beta2/zz_generated.deepcopy.go

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

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigs.yaml

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

bootstrap/kubeadm/config/crd/bases/bootstrap.cluster.x-k8s.io_kubeadmconfigtemplates.yaml

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

bootstrap/kubeadm/types/upstreamv1beta3/conversion.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,16 @@ func (dst *JoinConfiguration) ConvertFrom(srcRaw conversion.Hub) error {
5959

6060
// Custom conversion from this API, kubeadm v1beta3, to the hub version, CABPK v1beta1.
6161

62+
func Convert_v1beta2_ClusterConfiguration_To_upstreamv1beta3_ClusterConfiguration(in *bootstrapv1.ClusterConfiguration, out *ClusterConfiguration, s apimachineryconversion.Scope) error {
63+
// v1beta3 has no ClusterConfiguration.Proxy
64+
return autoConvert_v1beta2_ClusterConfiguration_To_upstreamv1beta3_ClusterConfiguration(in, out, s)
65+
}
66+
67+
func Convert_v1beta2_DNS_To_upstreamv1beta3_DNS(in *bootstrapv1.DNS, out *DNS, s apimachineryconversion.Scope) error {
68+
// v1beta3 has no ClusterConfiguration.DNS.Disabled
69+
return autoConvert_v1beta2_DNS_To_upstreamv1beta3_DNS(in, out, s)
70+
}
71+
6272
func Convert_upstreamv1beta3_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in *ClusterConfiguration, out *bootstrapv1.ClusterConfiguration, s apimachineryconversion.Scope) error {
6373
return autoConvert_upstreamv1beta3_ClusterConfiguration_To_v1beta2_ClusterConfiguration(in, out, s)
6474
}

bootstrap/kubeadm/types/upstreamv1beta3/zz_generated.conversion.go

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

bootstrap/kubeadm/types/upstreamv1beta4/zz_generated.conversion.go

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

bootstrap/kubeadm/types/utils_test.go

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,38 @@ func TestMarshalClusterConfigurationForVersion(t *testing.T) {
188188
"scheduler: {}\n",
189189
wantErr: false,
190190
},
191+
{
192+
name: "Allow to disable DNS or Proxy",
193+
args: args{
194+
capiObj: &bootstrapv1.ClusterConfiguration{
195+
DNS: bootstrapv1.DNS{
196+
Disabled: true,
197+
},
198+
Proxy: bootstrapv1.Proxy{
199+
Disabled: true,
200+
},
201+
},
202+
version: semver.MustParse("1.31.0"),
203+
},
204+
want: "apiServer: {}\n" +
205+
"apiVersion: kubeadm.k8s.io/v1beta4\n" +
206+
"clusterName: mycluster\n" +
207+
"controlPlaneEndpoint: myControlPlaneEndpoint:6443\n" +
208+
"controllerManager: {}\n" +
209+
"dns:\n" +
210+
" disabled: true\n" +
211+
"etcd: {}\n" +
212+
"kind: ClusterConfiguration\n" +
213+
"kubernetesVersion: v1.31.0\n" +
214+
"networking:\n" +
215+
" dnsDomain: myDNSDomain\n" +
216+
" podSubnet: myPodSubnet\n" +
217+
" serviceSubnet: myServiceSubnet\n" +
218+
"proxy:\n" +
219+
" disabled: true\n" +
220+
"scheduler: {}\n",
221+
wantErr: false,
222+
},
191223
}
192224
for _, tt := range tests {
193225
t.Run(tt.name, func(t *testing.T) {

0 commit comments

Comments
 (0)