Skip to content

Commit

Permalink
fixup! fixup! fixup! fixup! fixup! fixup! WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
m1kola committed Mar 4, 2024
1 parent 0e621b2 commit de4233d
Showing 1 changed file with 36 additions and 10 deletions.
46 changes: 36 additions & 10 deletions cmd/core/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ import (
"k8s.io/apimachinery/pkg/selection"
utilruntime "k8s.io/apimachinery/pkg/util/runtime"
clientgoscheme "k8s.io/client-go/kubernetes/scheme"
"k8s.io/client-go/rest"
"k8s.io/kube-aggregator/pkg/apis/apiregistration"
ctrl "sigs.k8s.io/controller-runtime"
"sigs.k8s.io/controller-runtime/pkg/cache"
Expand Down Expand Up @@ -140,17 +141,42 @@ func main() {
URL: *storageURL,
}

cacheOptions := cache.Options{
Scheme: scheme,
ByObject: map[client.Object]cache.ByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultNamespaces: map[string]cache.Config{
systemNamespace: {},
cache.AllNamespaces: {LabelSelector: dependentSelector},
},
}
c, err := cache.New(cfg, cacheOptions)
if err != nil {
setupLog.Error(err, "unable to create cache for the manager")
os.Exit(1)
}

clientOptions := client.Options{
Scheme: scheme,
Cache: &client.CacheOptions{
Reader: c,
},
}
cl, err := client.New(cfg, clientOptions)
if err != nil {
setupLog.Error(err, "unable to create client for the manager")
os.Exit(1)
}

mgr, err := ctrl.NewManager(cfg, ctrl.Options{
Scheme: scheme,
Cache: cache.Options{
ByObject: map[client.Object]cache.ByObject{
&rukpakv1alpha1.BundleDeployment{}: {},
&rukpakv1alpha1.Bundle{}: {},
},
DefaultNamespaces: map[string]cache.Config{
systemNamespace: {},
cache.AllNamespaces: {LabelSelector: dependentSelector},
},
NewCache: func(_ *rest.Config, _ cache.Options) (cache.Cache, error) {
return c, nil
},
NewClient: func(_ *rest.Config, _ client.Options) (client.Client, error) {
return cl, nil
},
Metrics: server.Options{
BindAddress: httpBindAddr,
Expand All @@ -160,7 +186,7 @@ func main() {
// controller-runtime runs when MetricsBindAddress is configured on the
// manager.
"/bundles/": httpLogger(localStorage),
"/uploads/": httpLogger(uploadmgr.NewUploadHandler(mgr.GetClient(), uploadStorageDirectory)),
"/uploads/": httpLogger(uploadmgr.NewUploadHandler(cl, uploadStorageDirectory)),
},
},
HealthProbeBindAddress: probeAddr,
Expand Down

0 comments on commit de4233d

Please sign in to comment.