diff --git a/controlplane/kubeadm/main.go b/controlplane/kubeadm/main.go index c54a651820f2..241d13470ef6 100644 --- a/controlplane/kubeadm/main.go +++ b/controlplane/kubeadm/main.go @@ -30,6 +30,7 @@ import ( appsv1 "k8s.io/api/apps/v1" corev1 "k8s.io/api/core/v1" apiextensionsv1 "k8s.io/apiextensions-apiserver/pkg/apis/apiextensions/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/labels" "k8s.io/apimachinery/pkg/runtime" "k8s.io/apimachinery/pkg/selection" @@ -341,9 +342,24 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { os.Exit(1) } + req1, _ := labels.NewRequirement("tier", selection.Equals, []string{"control-plane"}) + req2, _ := labels.NewRequirement("component", selection.In, []string{"kube-apiserver", "kube-controller-manager", "kube-scheduler", "etcd"}) + podSelector := labels.NewSelector().Add(*req1, *req2) + clusterCache, err := clustercache.SetupWithManager(ctx, mgr, clustercache.Options{ SecretClient: secretCachingClient, - Cache: clustercache.CacheOptions{}, + Cache: clustercache.CacheOptions{ + // Only cache kubeadm static pods + ByObject: map[client.Object]cache.ByObject{ + &corev1.Pod{}: { + Namespaces: map[string]cache.Config{ + metav1.NamespaceSystem: { + LabelSelector: podSelector, + }, + }, + }, + }, + }, Client: clustercache.ClientOptions{ QPS: clusterCacheClientQPS, Burst: clusterCacheClientBurst, @@ -352,7 +368,6 @@ func setupReconcilers(ctx context.Context, mgr ctrl.Manager) { DisableFor: []client.Object{ &corev1.ConfigMap{}, &corev1.Secret{}, - &corev1.Pod{}, &appsv1.Deployment{}, &appsv1.DaemonSet{}, },