Enable client side cache for all resources in single namespace mode
This commit is contained in:
parent
8b36ea90eb
commit
58c213794a
|
|
@ -46,6 +46,20 @@ rules:
|
||||||
verbs:
|
verbs:
|
||||||
- list
|
- list
|
||||||
- watch
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- secrets
|
||||||
|
verbs:
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- configmaps
|
||||||
|
verbs:
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- rbac.authorization.k8s.io
|
- rbac.authorization.k8s.io
|
||||||
resources:
|
resources:
|
||||||
|
|
|
||||||
|
|
@ -107,6 +107,20 @@ rules:
|
||||||
verbs:
|
verbs:
|
||||||
- list
|
- list
|
||||||
- watch
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- secrets
|
||||||
|
verbs:
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
|
- apiGroups:
|
||||||
|
- ""
|
||||||
|
resources:
|
||||||
|
- configmaps
|
||||||
|
verbs:
|
||||||
|
- list
|
||||||
|
- watch
|
||||||
- apiGroups:
|
- apiGroups:
|
||||||
- rbac.authorization.k8s.io
|
- rbac.authorization.k8s.io
|
||||||
resources:
|
resources:
|
||||||
|
|
|
||||||
|
|
@ -911,7 +911,7 @@ func TestTemplate_CreateManagerSingleNamespaceRole(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, "test-arc-gha-rs-controller-single-namespace", managerSingleNamespaceControllerRole.Name)
|
assert.Equal(t, "test-arc-gha-rs-controller-single-namespace", managerSingleNamespaceControllerRole.Name)
|
||||||
assert.Equal(t, namespaceName, managerSingleNamespaceControllerRole.Namespace)
|
assert.Equal(t, namespaceName, managerSingleNamespaceControllerRole.Namespace)
|
||||||
assert.Equal(t, 10, len(managerSingleNamespaceControllerRole.Rules))
|
assert.Equal(t, 12, len(managerSingleNamespaceControllerRole.Rules))
|
||||||
|
|
||||||
output = helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/manager_single_namespace_watch_role.yaml"})
|
output = helm.RenderTemplate(t, options, helmChartPath, releaseName, []string{"templates/manager_single_namespace_watch_role.yaml"})
|
||||||
|
|
||||||
|
|
@ -920,7 +920,7 @@ func TestTemplate_CreateManagerSingleNamespaceRole(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, "test-arc-gha-rs-controller-single-namespace-watch", managerSingleNamespaceWatchRole.Name)
|
assert.Equal(t, "test-arc-gha-rs-controller-single-namespace-watch", managerSingleNamespaceWatchRole.Name)
|
||||||
assert.Equal(t, "demo", managerSingleNamespaceWatchRole.Namespace)
|
assert.Equal(t, "demo", managerSingleNamespaceWatchRole.Namespace)
|
||||||
assert.Equal(t, 14, len(managerSingleNamespaceWatchRole.Rules))
|
assert.Equal(t, 16, len(managerSingleNamespaceWatchRole.Rules))
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestTemplate_ManagerSingleNamespaceRoleBinding(t *testing.T) {
|
func TestTemplate_ManagerSingleNamespaceRoleBinding(t *testing.T) {
|
||||||
|
|
|
||||||
19
main.go
19
main.go
|
|
@ -214,6 +214,16 @@ func main() {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
clientOptions := client.Options{}
|
||||||
|
if watchSingleNamespace == "" {
|
||||||
|
clientOptions.Cache = &client.CacheOptions{
|
||||||
|
DisableFor: []client.Object{
|
||||||
|
&corev1.Secret{},
|
||||||
|
&corev1.ConfigMap{},
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
mgr, err := ctrl.NewManager(ctrl.GetConfigOrDie(), ctrl.Options{
|
||||||
Scheme: scheme,
|
Scheme: scheme,
|
||||||
Metrics: metricsserver.Options{
|
Metrics: metricsserver.Options{
|
||||||
|
|
@ -226,14 +236,7 @@ func main() {
|
||||||
WebhookServer: webhookServer,
|
WebhookServer: webhookServer,
|
||||||
LeaderElection: enableLeaderElection,
|
LeaderElection: enableLeaderElection,
|
||||||
LeaderElectionID: leaderElectionId,
|
LeaderElectionID: leaderElectionId,
|
||||||
Client: client.Options{
|
Client: clientOptions,
|
||||||
Cache: &client.CacheOptions{
|
|
||||||
DisableFor: []client.Object{
|
|
||||||
&corev1.Secret{},
|
|
||||||
&corev1.ConfigMap{},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
},
|
|
||||||
})
|
})
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Error(err, "unable to start manager")
|
log.Error(err, "unable to start manager")
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue