@@ -162,23 +162,16 @@ const minimumCertificatesExpiryDays = 7
162
162
func (webhook * KubeadmControlPlane ) ValidateUpdate (_ context.Context , oldObj , newObj runtime.Object ) (admission.Warnings , error ) {
163
163
// add a * to indicate everything beneath is ok.
164
164
// For example, {"spec", "*"} will allow any path under "spec" to change.
165
+ // For example, {"spec"} will allow "spec" to also be unset.
165
166
allowedPaths := [][]string {
166
167
// metadata
167
168
{"metadata" , "*" },
168
169
// 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" , "*" },
182
175
{spec , kubeadmConfigSpec , clusterConfiguration , "imageRepository" },
183
176
{spec , kubeadmConfigSpec , clusterConfiguration , featureGates },
184
177
{spec , kubeadmConfigSpec , clusterConfiguration , featureGates , "*" },
@@ -552,7 +545,7 @@ func validateClusterConfiguration(oldClusterConfiguration, newClusterConfigurati
552
545
553
546
// update validations
554
547
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 ) {
556
549
allErrs = append (
557
550
allErrs ,
558
551
field .Forbidden (
@@ -561,16 +554,6 @@ func validateClusterConfiguration(oldClusterConfiguration, newClusterConfigurati
561
554
),
562
555
)
563
556
}
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
- }
574
557
}
575
558
576
559
return allErrs
0 commit comments