Skip to content

Commit f3ffab7

Browse files
authored
Merge pull request kubernetes-sigs#6 from varshaprasad96/fix-watch-admin-cluster
Create minimal clusterscoped cache
2 parents 98bf814 + 5ff5897 commit f3ffab7

File tree

3 files changed

+36
-293
lines changed

3 files changed

+36
-293
lines changed

examples/kcp/main.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func (r *reconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Resu
7474
},
7575
}
7676
if err := r.Create(ctx, cm); err != nil {
77-
log.Info("CM creation fialed")
77+
log.Info("CM creation failed", err)
7878
// log.Error(err, "this is fine")
7979
return ctrl.Result{}, nil
8080
}
@@ -88,7 +88,7 @@ func main() {
8888

8989
cfg := ctrl.GetConfigOrDie()
9090
mgr, err := ctrl.NewManager(cfg, ctrl.Options{
91-
NewCache: cache.MultiClusterCacheBuilder([]string{"*"}),
91+
NewCache: cache.MultiClusterMinCache(),
9292
})
9393
if err != nil {
9494
setupLog.Error(err, "unable to start manager")

pkg/cache/clusterscoped_cache.go

Lines changed: 0 additions & 291 deletions
This file was deleted.
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
Copyright 2019 The Kubernetes Authors.
3+
4+
Licensed under the Apache License, Version 2.0 (the "License");
5+
you may not use this file except in compliance with the License.
6+
You may obtain a copy of the License at
7+
8+
http://www.apache.org/licenses/LICENSE-2.0
9+
10+
Unless required by applicable law or agreed to in writing, software
11+
distributed under the License is distributed on an "AS IS" BASIS,
12+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
See the License for the specific language governing permissions and
14+
limitations under the License.
15+
*/
16+
17+
package cache
18+
19+
import "k8s.io/client-go/rest"
20+
21+
func MultiClusterMinCache() NewCacheFunc {
22+
return func(config *rest.Config, opts Options) (Cache, error) {
23+
opts, err := defaultOpts(config, opts)
24+
if err != nil {
25+
return nil, err
26+
}
27+
28+
globalConfig := *config
29+
globalConfig.Host = globalConfig.Host + "/clusters/*"
30+
31+
return New(&globalConfig, opts)
32+
}
33+
34+
}

0 commit comments

Comments
 (0)