Skip to content

Commit

Permalink
feat: Removed skr permission and cache config for remote kyma & Modul…
Browse files Browse the repository at this point in the history
…eTemp… (#2198)

* Removed skr permission  and cache config for remote kyma & ModuleTemplate resources

* Removed e2e test for klm-controller-manager serviceAcount on kyma-system namespace.

* Remove remoteNamespace field as it will be not used for the cache.

---------

Co-authored-by: Benjamin Lindner <[email protected]>
  • Loading branch information
medmes and lindnerby authored Jan 23, 2025
1 parent f025813 commit 3d85fd0
Show file tree
Hide file tree
Showing 16 changed files with 19 additions and 112 deletions.
2 changes: 1 addition & 1 deletion cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func main() {
}

cacheOptions := internal.GetCacheOptions(flagVar.IsKymaManaged, flagVar.IstioNamespace,
flagVar.IstioGatewayNamespace, flagVar.RemoteSyncNamespace)
flagVar.IstioGatewayNamespace)
setupManager(flagVar, cacheOptions, scheme, setupLog)
}

Expand Down
2 changes: 0 additions & 2 deletions config/rbac/namespace_bindings/kustomization.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,4 @@ resources:
- role_binding.yaml
# Comment the following to disable manifest integration
- watcher_certmanager_role.yaml
- skr_role.yaml
- watcher_certmanager_role_binding.yaml
- skr_role_binding.yaml
43 changes: 0 additions & 43 deletions config/rbac/namespace_bindings/skr_role.yaml

This file was deleted.

12 changes: 0 additions & 12 deletions config/rbac/namespace_bindings/skr_role_binding.yaml

This file was deleted.

20 changes: 8 additions & 12 deletions internal/cache_options.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,9 @@ type DefaultCacheOptions struct {
}

type KcpCacheOptions struct {
CacheOptions cache.Options
istioNamespace string
kcpNamespace string
remoteNamespace string
CacheOptions cache.Options
istioNamespace string
kcpNamespace string
}

func (c *DefaultCacheOptions) GetCacheOptions() cache.Options {
Expand All @@ -47,14 +46,12 @@ func (c *KcpCacheOptions) GetCacheOptions() cache.Options {
},
&v1beta2.Kyma{}: {
Namespaces: map[string]cache.Config{
c.remoteNamespace: {},
c.kcpNamespace: {},
c.kcpNamespace: {},
},
},
&v1beta2.ModuleTemplate{}: {
Namespaces: map[string]cache.Config{
c.remoteNamespace: {},
c.kcpNamespace: {},
c.kcpNamespace: {},
},
},
&v1beta2.ModuleReleaseMeta{}: {
Expand Down Expand Up @@ -88,12 +85,11 @@ func (c *KcpCacheOptions) GetCacheOptions() cache.Options {
}
}

func GetCacheOptions(isKymaManaged bool, istioNamespace, kcpNamespace, remoteNamespace string) cache.Options {
func GetCacheOptions(isKymaManaged bool, istioNamespace, kcpNamespace string) cache.Options {
if isKymaManaged {
options := &KcpCacheOptions{
istioNamespace: istioNamespace,
kcpNamespace: kcpNamespace,
remoteNamespace: remoteNamespace,
istioNamespace: istioNamespace,
kcpNamespace: kcpNamespace,
}
return options.GetCacheOptions()
}
Expand Down
32 changes: 0 additions & 32 deletions tests/e2e/rbac_privileges_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -199,38 +199,6 @@ var _ = Describe("RBAC Privileges", func() {
Expect(GetRoleBindingRolePolicyRules(ctx, kcpClient, "klm-controller-manager-watcher-certmanager",
"istio-system",
istioSystemKlmRoleBindings)).To(Equal(istioNamespaceRoleRules))

By("And KLM Service Account has the correct RoleBindings in kyma-system namespace")
remoteNamespaceRoleRules := []apirbacv1.PolicyRule{
{
APIGroups: []string{"operator.kyma-project.io"},
Resources: []string{"kymas"},
Verbs: []string{"list", "watch", "delete", "get", "create", "patch", "update"},
},
{
APIGroups: []string{"operator.kyma-project.io"},
Resources: []string{"kymas/finalizers"},
Verbs: []string{"update"},
},
{
APIGroups: []string{"operator.kyma-project.io"},
Resources: []string{"kymas/status"},
Verbs: []string{"get", "patch", "update", "watch"},
},
{
APIGroups: []string{"operator.kyma-project.io"},
Resources: []string{"moduletemplates"},
Verbs: []string{"list", "watch", "delete"},
},
}
kymaSystemKlmRoleBindings, err := ListKlmRoleBindings(kcpClient, ctx, "klm-controller-manager",
"kyma-system")
Expect(err).ToNot(HaveOccurred())
Expect(kymaSystemKlmRoleBindings.Items).To(HaveLen(1))

Expect(GetRoleBindingRolePolicyRules(ctx, kcpClient,
"klm-controller-manager-skr", "kyma-system",
kymaSystemKlmRoleBindings)).To(Equal(remoteNamespaceRoleRules))
})
})
})
2 changes: 1 addition & 1 deletion tests/integration/controller/eventfilters/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var _ = BeforeSuite(func() {
BindAddress: randomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/kcp/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ var _ = BeforeSuite(func() {
BindAddress: UseRandomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/kyma/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ var _ = BeforeSuite(func() {
BindAddress: randomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ var _ = BeforeSuite(func() {
BindAddress: useRandomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ var _ = BeforeSuite(func() {
BindAddress: useRandomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ var _ = BeforeSuite(func() {
if !found {
metricsBindAddress = ":0"
}
cacheOpts := internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace)
cacheOpts := internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace)
syncPeriod := 2 * time.Second
cacheOpts.SyncPeriod = &syncPeriod

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/manifest/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ var _ = BeforeSuite(func() {
BindAddress: metricsBindAddress,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
},
)
Expect(err).ToNot(HaveOccurred())
Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/moduletemplate/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ var _ = BeforeSuite(func() {
BindAddress: randomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/purge/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ var _ = BeforeSuite(func() {
BindAddress: useRandomPort,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down
2 changes: 1 addition & 1 deletion tests/integration/controller/withwatcher/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ var _ = BeforeSuite(func() {
BindAddress: metricsBindAddress,
},
Scheme: k8sclientscheme.Scheme,
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace, RemoteNamespace),
Cache: internal.GetCacheOptions(false, "istio-system", ControlPlaneNamespace),
})
Expect(err).ToNot(HaveOccurred())

Expand Down

0 comments on commit 3d85fd0

Please sign in to comment.