Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Automated backport of #3040: Reduce submariner-operator RBAC permissions #3049

Conversation

tpantelis
Copy link
Contributor

Backport of #3040 on release-0.15.

#3040: Reduce submariner-operator RBAC permissions

For details on the backport process, see the backport requests page.

- Remove Role wildcard access to "pods" - only "get" and "list" access is
  needed which is provided by the ClusterRole.
- "services" are created for metrics so reduce Role access accordingly
- The operator does not access "endpoints", "persistentvolumeclaims",
  "events", "replicasets" or "statefulsets" so remove access.
- Reduce access to "deployments", "daemonsets" and "submariner.io" resources
  to only what's needed and remove wildcard access.

Signed-off-by: Tom Pantelis <[email protected]>
@submariner-bot
Copy link
Contributor

🤖 Created branch: z_pr3049/tpantelis/automated-backport-of-#3040-upstream-release-0.15
🚀 Full E2E won't run until the "ready-to-test" label is applied. I will add it automatically once the PR has 2 approvals, or you can add it manually.

@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from 423cfec to adcd4ab Compare May 6, 2024 16:45
@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from adcd4ab to ad6cc22 Compare May 6, 2024 16:59
tpantelis added a commit to tpantelis/submariner-website that referenced this pull request May 6, 2024
@tpantelis tpantelis added the ready-to-test When a PR is ready for full E2E testing label May 6, 2024
@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from ad6cc22 to d8d0855 Compare May 7, 2024 00:34
tpantelis added 7 commits May 6, 2024 21:18
- The following resources are not accessed at all so remove permissions:
  - "services"
  - "endpoints"
  - "events"
  - "configmaps"
  - "deployments"
  - "daemonsets"
  - "replicasets"
  - "statefulsets"
  - "customresourcedefinitions",
  - "operator.openshift.io/dnses"
  - "config.openshift.io/networks"
  - "monitoring.coreos.com/servicemonitors"

- The gateway pod is annotated - it only needs "get" and "update" access

- Remove wildcard access to "submariner.io" resources and specify
  exactly what's needed.

- Reduce "configmaps" access to just "get".

Signed-off-by: Tom Pantelis <[email protected]>
- The following resources are not accessed so remove permissions:
  - "services"
  - "endpoints"
  - "events"
  - "deployments"
  - "daemonsets"
  - "replicasets"
  - "statefulsets"
  - "customresourcedefinitions",
  - "operator.openshift.io/dnses"
  - "monitoring.coreos.com/servicemonitors"

- Reduce access to "pods", "services", "secrets", "configmaps", and
  "endpoints" to "get" and "list"

- Remove wildcard access to "submariner.io" resources and specify exactly
  what's needed.

Signed-off-by: Tom Pantelis <[email protected]>
- The following resources are not accessed at all so remove permissions:
  - "services"
  - "endpoints"
  - "persistentvolumeclaims"
  - "events"
  - "configmaps"
  - "secrets"
  - "deployments"
  - "daemonsets"
  - "replicasets"
  - "statefulsets"
  - "namespaces"
  - "monitoring.coreos.com/servicemonitors"

- Reduce "pods" access to only "get", "list", "watch"

Signed-off-by: Tom Pantelis <[email protected]>
- Remove "update" access to "services", "namespaces" and "endpoints".
- Remove wildcard access to "multicluster.x-k8s.io" resources and specify
  exactly what's needed.

Signed-off-by: Tom Pantelis <[email protected]>
- The following resources are not accessed so remove permissions:
  - "services"
  - "endpoints"
  - "namespaces"

- Reduce "endpointslices" access to "get", "list", and "watch"

Signed-off-by: Tom Pantelis <[email protected]>
We grant namespace read permissions which is only needed to query for
the existence of the "openshift-monitoring" namespace to determine
where to create ServiceMonitors. However we can eliminate this query
and thus the permissions by trying to create ServiceMonitors in the
"openshift-monitoring" namespace and, if the error indicates the
namespace is missing, create in the provided namespace.

Signed-off-by: Tom Pantelis <[email protected]>
This resource type is only used for network settings discovery to query
the "cluster" Network so restrict the RBAC to only "get" access to the
"cluster" resource name.

This applies to both the submariner-operator:

https://github.com/submariner-io/submariner/blob/85fea596f30b0e84d6962c92bb129a6b8bce8028/pkg/routeagent_driver/handlers/ovn/connection.go#L358

and route-agent components:

https://github.com/submariner-io/submariner/blob/85fea596f30b0e84d6962c92bb129a6b8bce8028/pkg/routeagent_driver/handlers/ovn/connection.go#L358

Signed-off-by: Tom Pantelis <[email protected]>
@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from d8d0855 to ebcae2e Compare May 7, 2024 01:18
@tpantelis tpantelis marked this pull request as draft May 7, 2024 01:56
@tpantelis
Copy link
Contributor Author

I'll backport #3050 with this PR - setting as draft for now.

Use "openshiftMonitoringNS" instead of "ns" when first attempting to
create in the former namespace.

Signed-off-by: Tom Pantelis <[email protected]>
CRUD access to Secrets were removed but it turns out we need it in
order to sync Secrets from the broker namespace to the
submariner-operator namespace.

Signed-off-by: Tom Pantelis <[email protected]>
@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from ebcae2e to d637dd4 Compare May 7, 2024 14:06
@tpantelis tpantelis marked this pull request as ready for review May 7, 2024 14:07
@tpantelis tpantelis force-pushed the automated-backport-of-#3040-upstream-release-0.15 branch from d637dd4 to c021745 Compare May 7, 2024 14:29
@tpantelis tpantelis merged commit 3595b4f into submariner-io:release-0.15 May 7, 2024
36 of 38 checks passed
@submariner-bot
Copy link
Contributor

🤖 Closed branches: [z_pr3049/tpantelis/automated-backport-of-#3040-upstream-release-0.15]

tpantelis added a commit to submariner-io/submariner-website that referenced this pull request May 9, 2024
@tpantelis tpantelis deleted the automated-backport-of-#3040-upstream-release-0.15 branch May 21, 2024 18:41
tpantelis added a commit to tpantelis/submariner-website that referenced this pull request Jun 27, 2024
tpantelis added a commit to submariner-io/submariner-website that referenced this pull request Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automated-backport backport-handled ready-to-test When a PR is ready for full E2E testing
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants