@@ -415,6 +415,24 @@ func (d *DryRun) GetKubeadmConfigReactor() *testing.SimpleReactor {
415
415
}
416
416
}
417
417
418
+ // GetKubeadmCertsReactor returns a reactor that handles the GET action of the "kubeadm-certs" Secret.
419
+ func (d * DryRun ) GetKubeadmCertsReactor () * testing.SimpleReactor {
420
+ return & testing.SimpleReactor {
421
+ Verb : "get" ,
422
+ Resource : "secrets" ,
423
+ Reaction : func (action testing.Action ) (bool , runtime.Object , error ) {
424
+ a := action .(testing.GetAction )
425
+ if a .GetName () != constants .KubeadmCertsSecret || a .GetNamespace () != metav1 .NamespaceSystem {
426
+ return false , nil , nil
427
+ }
428
+
429
+ obj := getKubeadmCertsSecret ()
430
+ d .LogObject (obj , action .GetResource ().GroupVersion ())
431
+ return true , obj , nil
432
+ },
433
+ }
434
+ }
435
+
418
436
// GetKubeletConfigReactor returns a reactor that handles the GET action of the "kubelet-config"
419
437
// ConfigMap.
420
438
func (d * DryRun ) GetKubeletConfigReactor () * testing.SimpleReactor {
@@ -513,6 +531,17 @@ func getConfigMap(namespace, name string, data map[string]string) *corev1.Config
513
531
}
514
532
}
515
533
534
+ // getSecret returns a fake Secret object.
535
+ func getSecret (namespace , name string , data map [string ][]byte ) * corev1.Secret {
536
+ return & corev1.Secret {
537
+ ObjectMeta : metav1.ObjectMeta {
538
+ Name : name ,
539
+ Namespace : namespace ,
540
+ },
541
+ Data : data ,
542
+ }
543
+ }
544
+
516
545
// getClusterInfoConfigMap returns a fake "cluster-info" ConfigMap.
517
546
func getClusterInfoConfigMap () * corev1.ConfigMap {
518
547
kubeconfig := dedent .Dedent (`apiVersion: v1
@@ -546,6 +575,7 @@ controllerManager:
546
575
extraArgs:
547
576
- name: cluster-signing-duration
548
577
value: 24h
578
+ controlPlaneEndpoint: 192.168.0.101:6443
549
579
dns: {}
550
580
encryptionAlgorithm: RSA-2048
551
581
etcd:
@@ -568,6 +598,23 @@ scheduler: {}
568
598
return getConfigMap (metav1 .NamespaceSystem , constants .KubeadmConfigConfigMap , data )
569
599
}
570
600
601
+ // getKubeadmCertsSecret returns a fake "kubeadm-certs" Secret.
602
+ func getKubeadmCertsSecret () * corev1.Secret {
603
+ // The cert data is empty because the actual content is not relevant for the dryrun test.
604
+ data := map [string ][]byte {
605
+ constants .CACertName : {},
606
+ constants .CAKeyName : {},
607
+ constants .FrontProxyCACertName : {},
608
+ constants .FrontProxyCAKeyName : {},
609
+ constants .ServiceAccountPrivateKeyName : {},
610
+ constants .ServiceAccountPublicKeyName : {},
611
+ strings .ReplaceAll (constants .EtcdCACertName , "/" , "-" ): {},
612
+ strings .ReplaceAll (constants .EtcdCAKeyName , "/" , "-" ): {},
613
+ }
614
+
615
+ return getSecret (metav1 .NamespaceSystem , constants .KubeadmCertsSecret , data )
616
+ }
617
+
571
618
// getKubeletConfigMap returns a fake "kubelet-config" ConfigMap.
572
619
func getKubeletConfigMap () * corev1.ConfigMap {
573
620
configData := `apiVersion: kubelet.config.k8s.io/v1beta1
0 commit comments