Skip to content

Commit 696c24a

Browse files
committed
feat: caching cluster unstructured data
1 parent 628c283 commit 696c24a

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

controllers/kamajicontrolplane_controller_cluster_patch.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ func (r *KamajiControlPlaneReconciler) checkOrPatchVSphereCluster(ctx context.Co
6262
return nil
6363
}
6464

65-
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=kubevirtclusters;packetclusters,verbs=patch
65+
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=kubevirtclusters;packetclusters,verbs=patch;get;list;watch
6666
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=kubevirtclusters/status;packetclusters/status,verbs=patch
6767

6868
func (r *KamajiControlPlaneReconciler) patchGenericCluster(ctx context.Context, cluster capiv1beta1.Cluster, endpoint string, port int64, patchStatus bool) error {
@@ -139,7 +139,7 @@ func (r *KamajiControlPlaneReconciler) checkGenericCluster(ctx context.Context,
139139
return nil
140140
}
141141

142-
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=openstackclusters,verbs=patch
142+
//+kubebuilder:rbac:groups=infrastructure.cluster.x-k8s.io,resources=openstackclusters,verbs=patch;get;list;watch
143143

144144
func (r *KamajiControlPlaneReconciler) patchOpenStackCluster(ctx context.Context, cluster capiv1beta1.Cluster, endpoint string, port int64) error {
145145
osc := unstructured.Unstructured{}

main.go

+7
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ import (
1212
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
1313
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
1414
_ "k8s.io/client-go/plugin/pkg/client/auth"
15+
"k8s.io/client-go/rest"
1516
capiv1beta1 "sigs.k8s.io/cluster-api/api/v1beta1"
1617
ctrl "sigs.k8s.io/controller-runtime"
18+
"sigs.k8s.io/controller-runtime/pkg/client"
1719
"sigs.k8s.io/controller-runtime/pkg/healthz"
1820
"sigs.k8s.io/controller-runtime/pkg/log/zap"
1921
"sigs.k8s.io/controller-runtime/pkg/webhook"
@@ -58,6 +60,11 @@ func main() {
5860
WebhookServer: webhook.NewServer(webhook.Options{
5961
Port: 9443, //nolint:gomnd
6062
}),
63+
NewClient: func(config *rest.Config, options client.Options) (client.Client, error) {
64+
options.Cache.Unstructured = true
65+
66+
return client.New(config, options) //nolint:wrapcheck
67+
},
6168
HealthProbeBindAddress: probeAddr,
6269
LeaderElection: enableLeaderElection,
6370
LeaderElectionID: "kamaji.controlplane.cluster.x-k8s.io",

0 commit comments

Comments
 (0)