Skip to content

Commit

Permalink
Cache Pods for KCP
Browse files Browse the repository at this point in the history
  • Loading branch information
fabriziopandini committed Nov 20, 2024
1 parent 781d1e4 commit 4e9cb6f
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions controlplane/kubeadm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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,
Expand All @@ -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{},
},
Expand Down

0 comments on commit 4e9cb6f

Please sign in to comment.