@@ -76,9 +76,10 @@ type InitLocker interface {
76
76
77
77
// KubeadmConfigReconciler reconciles a KubeadmConfig object.
78
78
type KubeadmConfigReconciler struct {
79
- Client client.Client
80
- Tracker * remote.ClusterCacheTracker
81
- KubeadmInitLock InitLocker
79
+ Client client.Client
80
+ SecretCachingClient client.Client
81
+ Tracker * remote.ClusterCacheTracker
82
+ KubeadmInitLock InitLocker
82
83
83
84
// WatchFilterValue is the label value used to filter events prior to reconciliation.
84
85
WatchFilterValue string
@@ -453,13 +454,15 @@ func (r *KubeadmConfigReconciler) handleClusterNotInitialized(ctx context.Contex
453
454
// Otherwise rely on certificates generated by the ControlPlane controller.
454
455
// Note: A cluster does not have a ControlPlane reference when using standalone CP machines.
455
456
if scope .Cluster .Spec .ControlPlaneRef == nil {
456
- err = certificates .LookupOrGenerate (
457
+ err = certificates .LookupOrGenerateCached (
457
458
ctx ,
459
+ r .SecretCachingClient ,
458
460
r .Client ,
459
461
util .ObjectKey (scope .Cluster ),
460
462
* metav1 .NewControllerRef (scope .Config , bootstrapv1 .GroupVersion .WithKind ("KubeadmConfig" )))
461
463
} else {
462
- err = certificates .Lookup (ctx ,
464
+ err = certificates .LookupCached (ctx ,
465
+ r .SecretCachingClient ,
463
466
r .Client ,
464
467
util .ObjectKey (scope .Cluster ))
465
468
}
@@ -531,8 +534,9 @@ func (r *KubeadmConfigReconciler) joinWorker(ctx context.Context, scope *Scope)
531
534
scope .Info ("Creating BootstrapData for the worker node" )
532
535
533
536
certificates := secret .NewCertificatesForWorker (scope .Config .Spec .JoinConfiguration .CACertPath )
534
- err := certificates .Lookup (
537
+ err := certificates .LookupCached (
535
538
ctx ,
539
+ r .SecretCachingClient ,
536
540
r .Client ,
537
541
util .ObjectKey (scope .Cluster ),
538
542
)
@@ -645,8 +649,9 @@ func (r *KubeadmConfigReconciler) joinControlplane(ctx context.Context, scope *S
645
649
}
646
650
647
651
certificates := secret .NewControlPlaneJoinCerts (scope .Config .Spec .ClusterConfiguration )
648
- err := certificates .Lookup (
652
+ err := certificates .LookupCached (
649
653
ctx ,
654
+ r .SecretCachingClient ,
650
655
r .Client ,
651
656
util .ObjectKey (scope .Cluster ),
652
657
)
@@ -1055,7 +1060,7 @@ func (r *KubeadmConfigReconciler) storeBootstrapData(ctx context.Context, scope
1055
1060
// Ensure the bootstrap secret has the KubeadmConfig as a controller OwnerReference.
1056
1061
func (r * KubeadmConfigReconciler ) ensureBootstrapSecretOwnersRef (ctx context.Context , scope * Scope ) error {
1057
1062
secret := & corev1.Secret {}
1058
- err := r .Client .Get (ctx , client.ObjectKey {Namespace : scope .Config .Namespace , Name : scope .Config .Name }, secret )
1063
+ err := r .SecretCachingClient .Get (ctx , client.ObjectKey {Namespace : scope .Config .Namespace , Name : scope .Config .Name }, secret )
1059
1064
if err != nil {
1060
1065
// If the secret has not been created yet return early.
1061
1066
if apierrors .IsNotFound (err ) {
0 commit comments