@@ -162,23 +162,16 @@ const minimumCertificatesExpiryDays = 7
162162func (webhook * KubeadmControlPlane ) ValidateUpdate (_ context.Context , oldObj , newObj runtime.Object ) (admission.Warnings , error ) {
163163 // add a * to indicate everything beneath is ok.
164164 // For example, {"spec", "*"} will allow any path under "spec" to change.
165+ // For example, {"spec"} will allow "spec" to also be unset.
165166 allowedPaths := [][]string {
166167 // metadata
167168 {"metadata" , "*" },
168169 // spec.kubeadmConfigSpec.clusterConfiguration
169- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "imageRepository" },
170- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "imageTag" },
171- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "extraArgs" },
172- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "extraArgs" , "*" },
173- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "dataDir" },
174- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "peerCertSANs" },
175- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "serverCertSANs" },
176- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "external" , "endpoints" },
177- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "external" , "caFile" },
178- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "external" , "certFile" },
179- {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "external" , "keyFile" },
180- {spec , kubeadmConfigSpec , clusterConfiguration , "dns" , "imageRepository" },
181- {spec , kubeadmConfigSpec , clusterConfiguration , "dns" , "imageTag" },
170+ {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" },
171+ {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "local" , "*" },
172+ {spec , kubeadmConfigSpec , clusterConfiguration , "etcd" , "external" , "*" },
173+ {spec , kubeadmConfigSpec , clusterConfiguration , "dns" },
174+ {spec , kubeadmConfigSpec , clusterConfiguration , "dns" , "*" },
182175 {spec , kubeadmConfigSpec , clusterConfiguration , "imageRepository" },
183176 {spec , kubeadmConfigSpec , clusterConfiguration , featureGates },
184177 {spec , kubeadmConfigSpec , clusterConfiguration , featureGates , "*" },
@@ -552,7 +545,7 @@ func validateClusterConfiguration(oldClusterConfiguration, newClusterConfigurati
552545
553546 // update validations
554547 if oldClusterConfiguration != nil {
555- if newClusterConfiguration .Etcd .External != nil && oldClusterConfiguration .Etcd .Local != nil {
548+ if ( newClusterConfiguration .Etcd .External != nil && oldClusterConfiguration .Etcd .External == nil ) || ( newClusterConfiguration . Etcd . External == nil && oldClusterConfiguration . Etcd . External != nil ) {
556549 allErrs = append (
557550 allErrs ,
558551 field .Forbidden (
@@ -561,16 +554,6 @@ func validateClusterConfiguration(oldClusterConfiguration, newClusterConfigurati
561554 ),
562555 )
563556 }
564-
565- if newClusterConfiguration .Etcd .Local != nil && oldClusterConfiguration .Etcd .External != nil {
566- allErrs = append (
567- allErrs ,
568- field .Forbidden (
569- pathPrefix .Child ("etcd" , "local" ),
570- "cannot change between external and local etcd" ,
571- ),
572- )
573- }
574557 }
575558
576559 return allErrs
0 commit comments