Skip to content

Adding additional roles and network policy configs#588

Open
chamalabey wants to merge 6 commits intoopenshift:masterfrom
chamalabey:muo-pko-migration-config-update
Open

Adding additional roles and network policy configs#588
chamalabey wants to merge 6 commits intoopenshift:masterfrom
chamalabey:muo-pko-migration-config-update

Conversation

@chamalabey
Copy link
Contributor

What type of PR is this?

refactor

What this PR does / why we need it?

Moving configuration in SSS template to PKO packaging.

Which Jira/Github issue(s) this PR fixes?

_Fixes #_https://redhat.atlassian.net/browse/SREP-3990

Special notes for your reviewer:

Pre-checks (if applicable):

  • Tested latest changes against a cluster
  • Included documentation changes with PR

@openshift-ci openshift-ci bot requested review from charlesgong and rbhilare March 20, 2026 03:33
@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 20, 2026

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: chamalabey
Once this PR has been reviewed and has the lgtm label, please assign bmeng for approval. For more information see the Code Review Process.

The full list of commands accepted by this bot can be found here.

Details Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@coderabbitai
Copy link

coderabbitai bot commented Mar 20, 2026

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 4ea7ae44-1e57-43a8-89ed-6814eab44fbf

📥 Commits

Reviewing files that changed from the base of the PR and between aa69688 and bb14873.

📒 Files selected for processing (1)
  • deploy_pko/manifest.yaml
🚧 Files skipped from review as they are similar to previous changes (1)
  • deploy_pko/manifest.yaml

Walkthrough

Adds a NetworkPolicy, three Roles and three RoleBindings, inserts a new policies phase into the package manifest, and updates UBI9 minimal base image tags in two Dockerfiles.

Changes

Cohort / File(s) Summary
Network Policy
deploy_pko/NetworkPolicy-muo.yaml
New NetworkPolicy in openshift-deployment-validation-operator with podSelector: {}, policyTypes: [Ingress], allowing ingress only from namespaces labeled kubernetes.io/metadata.name: openshift-managed-upgrade-operator; includes package-operator annotations.
RBAC Roles
deploy_pko/Role-muo-other.yaml
Adds three Role resources: muo-monitoring-interactor (openshift-monitoring) granting read/watch on configmaps/serviceaccounts/secrets/services and routes, plus serviceaccounts/token create; muo-pullsecret-reader (openshift-config) for secrets; muo-dvo-reader (openshift-deployment-validation-operator) for services.
RoleBindings
deploy_pko/RoleBinding-muo-other.yaml
Adds three RoleBinding resources binding those Roles to ServiceAccount/managed-upgrade-operator in openshift-managed-upgrade-operator; includes package-operator annotations; one roleRef explicitly sets apiGroup.
Package manifest
deploy_pko/manifest.yaml
Updated PackageManifest spec.phases[] to insert a new phase with name: policies between existing phases.
Build images
build/Dockerfile, build/Dockerfile.olm-registry
Bumped UBI9 minimal base image tag from 9.7-1773204619 to 9.7-1773939694 in both Dockerfiles; no other changes.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Tip

CodeRabbit can use your project's `golangci-lint` configuration to improve the quality of Go code reviews.

Add a configuration file to your project to customize how CodeRabbit runs golangci-lint.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@deploy_pko/NetworkPolicy-muo.yaml`:
- Around line 10-15: The NetworkPolicy currently allows all pods in the target
namespace (podSelector: {}) to be contacted from any pod in the
openshift-managed-upgrade-operator namespace; tighten it by replacing the empty
top-level podSelector with a specific label selector that matches only the
intended target pods (e.g., app: my-app), add a podSelector under the
ingress->from block (next to namespaceSelector) to restrict source pods in the
openshift-managed-upgrade-operator namespace to only those with the required
labels, and add an explicit ports array under ingress to enumerate only the
required ports/protocols instead of allowing all ports; update the YAML fields
ingress, podSelector, namespaceSelector, and ports accordingly.

In `@deploy_pko/Role-muo-other.yaml`:
- Around line 45-52: The Role currently grants broad access to all secrets via
apiGroups: "" and resources: secrets with verbs get, list, watch; restrict the
muo-pullsecret-reader role to only the named secret by adding resourceNames:
[pull-secret] under the secrets resource and remove unused verbs so verbs
contains only get (no list or watch) to match util/access_token.go which only
reads the pull-secret; update the Role definition in Role-muo-other.yaml
accordingly.
- Around line 29-34: The Role currently allows create on serviceaccounts/token
for any ServiceAccount; restrict token minting by adding a resourceNames stanza
listing only the ServiceAccount(s) that should be allowed (e.g. add
resourceNames: - managed-upgrade-operator under the resources: -
serviceaccounts/token entry in the Role in Role-muo-other.yaml). Locate the
entry that mentions resources: - serviceaccounts/token and modify it to include
the specific service account name(s) (names only, since the Role is namespaced)
to limit token creation to those SAs.

In `@deploy_pko/RoleBinding-muo-other.yaml`:
- Around line 9-12: Add the missing roleRef.apiGroup fields to the RoleBinding
manifests: for the roleRef blocks (e.g., roleRef with kind: Role and name:
muo-monitoring-interactor) add roleRef.apiGroup: rbac.authorization.k8s.io so
the RoleBinding objects validate against rbac.authorization.k8s.io/v1; update
both occurrences (the roleRef at lines shown and the other roleRef block
referencing the same role/name) to include this apiGroup entry.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 20d878b5-20ce-482d-80de-b9ff841edd19

📥 Commits

Reviewing files that changed from the base of the PR and between 350c2fb and 3e1cdd0.

📒 Files selected for processing (3)
  • deploy_pko/NetworkPolicy-muo.yaml
  • deploy_pko/Role-muo-other.yaml
  • deploy_pko/RoleBinding-muo-other.yaml

Comment on lines +10 to +15
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-managed-upgrade-operator
podSelector: {}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

cat deploy_pko/NetworkPolicy-muo.yaml

Repository: openshift/managed-upgrade-operator

Length of output: 557


Ingress rule allows any pod from source namespace on all ports.

Lines 10–15 apply this policy to every pod in the target namespace (podSelector: {}) and allow traffic from any pod in openshift-managed-upgrade-operator on all ports. Tighten the rule by specifying:

  • podSelector within the from clause to restrict which source pods need access
  • podSelector in the policy target to restrict which pods in the target namespace need this ingress
  • Explicit ports array to allow only required ports
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy_pko/NetworkPolicy-muo.yaml` around lines 10 - 15, The NetworkPolicy
currently allows all pods in the target namespace (podSelector: {}) to be
contacted from any pod in the openshift-managed-upgrade-operator namespace;
tighten it by replacing the empty top-level podSelector with a specific label
selector that matches only the intended target pods (e.g., app: my-app), add a
podSelector under the ingress->from block (next to namespaceSelector) to
restrict source pods in the openshift-managed-upgrade-operator namespace to only
those with the required labels, and add an explicit ports array under ingress to
enumerate only the required ports/protocols instead of allowing all ports;
update the YAML fields ingress, podSelector, namespaceSelector, and ports
accordingly.

Comment on lines +29 to +34
- apiGroups:
- ""
resources:
- serviceaccounts/token
verbs:
- create
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

find . -name "Role-muo-other.yaml" -o -name "Role-muo-other.yml"

Repository: openshift/managed-upgrade-operator

Length of output: 110


🏁 Script executed:

git ls-files | grep -i "muo-other"

Repository: openshift/managed-upgrade-operator

Length of output: 146


🏁 Script executed:

git ls-files | grep -i "role.*yaml" | head -20

Repository: openshift/managed-upgrade-operator

Length of output: 857


🏁 Script executed:

cat -n deploy_pko/Role-muo-other.yaml

Repository: openshift/managed-upgrade-operator

Length of output: 1812


🏁 Script executed:

cat -n deploy_pko/RoleBinding-muo-other.yaml

Repository: openshift/managed-upgrade-operator

Length of output: 1708


🏁 Script executed:

rg "serviceaccounts/token" --type yaml

Repository: openshift/managed-upgrade-operator

Length of output: 306


🏁 Script executed:

rg "openshift-monitoring" --type yaml -A 2 -B 2 | head -50

Repository: openshift/managed-upgrade-operator

Length of output: 2929


🏁 Script executed:

rg "managed-upgrade-operator" deploy_pko/ --type yaml -C 3 | grep -A 5 -B 5 "serviceaccounts"

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

rg "token" deploy_pko/Role-muo-other.yaml -B 10 -A 10

Repository: openshift/managed-upgrade-operator

Length of output: 417


🏁 Script executed:

rg "managed-upgrade-operator" . --type yaml | grep -i token

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

find . -name "*.md" -o -name "*.txt" | xargs rg -l "token\|serviceaccount" 2>/dev/null | head -5

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

git log --oneline --all -S "serviceaccounts/token" | head -10

Repository: openshift/managed-upgrade-operator

Length of output: 164


Restrict token minting permission to specific ServiceAccounts using resourceNames.

Lines 29–34 grant create on serviceaccounts/token without resourceNames, allowing the managed-upgrade-operator to mint tokens for any ServiceAccount in the openshift-monitoring namespace. This is a broad permission that increases risk if the operator pod is compromised. Restrict this to only the specific ServiceAccount(s) that require token creation.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy_pko/Role-muo-other.yaml` around lines 29 - 34, The Role currently
allows create on serviceaccounts/token for any ServiceAccount; restrict token
minting by adding a resourceNames stanza listing only the ServiceAccount(s) that
should be allowed (e.g. add resourceNames: - managed-upgrade-operator under the
resources: - serviceaccounts/token entry in the Role in Role-muo-other.yaml).
Locate the entry that mentions resources: - serviceaccounts/token and modify it
to include the specific service account name(s) (names only, since the Role is
namespaced) to limit token creation to those SAs.

Comment on lines +45 to +52
- apiGroups:
- ""
resources:
- secrets
verbs:
- get
- list
- watch
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

# Locate the file in the repository
find . -name "Role-muo-other.yaml" -o -name "*muo-other*"

Repository: openshift/managed-upgrade-operator

Length of output: 150


🏁 Script executed:

# List files in deploy_pko directory to understand structure
ls -la deploy_pko/ 2>/dev/null || echo "Directory not found, searching for it..."
find . -type d -name "deploy_pko" 2>/dev/null

Repository: openshift/managed-upgrade-operator

Length of output: 1389


🏁 Script executed:

# Search for Role or role-related files to understand the structure
fd "\.yaml$|\.yml$" | grep -i "role\|pko" | head -20

Repository: openshift/managed-upgrade-operator

Length of output: 879


🏁 Script executed:

# Read the Role-muo-other.yaml file to see full context
cat -n deploy_pko/Role-muo-other.yaml

Repository: openshift/managed-upgrade-operator

Length of output: 1812


🏁 Script executed:

# Also check the RoleBinding to understand what subjects are bound to this role
cat -n deploy_pko/RoleBinding-muo-other.yaml

Repository: openshift/managed-upgrade-operator

Length of output: 1708


🏁 Script executed:

# Search for any references to "pull-secret" or "pullsecret" in the codebase
rg -i "pull-secret|pullsecret" --type yaml

Repository: openshift/managed-upgrade-operator

Length of output: 1053


🏁 Script executed:

# Look for any code that uses this role or interacts with secrets
rg "muo-other|muo-pullsecret"

Repository: openshift/managed-upgrade-operator

Length of output: 1053


🏁 Script executed:

# Search for code that uses this role or interacts with openshift-config secrets
rg "openshift-config" -A 2 -B 2 --type go --type python | head -50

Repository: openshift/managed-upgrade-operator

Length of output: 108


🏁 Script executed:

# Look for code that references pull-secret or reads secrets
rg -i "pull-secret|openshift-config.*secret" --type go --type python | head -30

Repository: openshift/managed-upgrade-operator

Length of output: 108


🏁 Script executed:

# Check the Go code to understand what secret the operator needs to access
find . -name "*.go" -type f | xargs rg "openshift-config" | grep -i secret

Repository: openshift/managed-upgrade-operator

Length of output: 1999


🏁 Script executed:

# Look for any documentation or comments about why this role needs these verbs
rg "muo-pullsecret-reader|pullsecret" --type go -B 5 -A 5

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

# Check if there's any usage of list or watch on the pull-secret
rg -i "list|watch" util/access_token.go pkg/ocm/builder*.go | grep -i secret

Repository: openshift/managed-upgrade-operator

Length of output: 60


🏁 Script executed:

# Examine the actual usage in access_token.go to confirm it's only "Get"
cat -n util/access_token.go | grep -A 10 -B 10 "pull-secret"

Repository: openshift/managed-upgrade-operator

Length of output: 995


🏁 Script executed:

# Double-check if there are any other usages of list or watch in the openshift-config namespace
rg "List|Watch" util/access_token.go pkg/ocm/builder.go

Repository: openshift/managed-upgrade-operator

Length of output: 60


Restrict muo-pullsecret-reader role to the specific pull-secret resource.

Lines 45–52 grant access to all secrets in openshift-config namespace. The code only reads the pull-secret by name (see util/access_token.go). Restrict this role using resourceNames: [pull-secret] and reduce verbs to [get] only, since list and watch are not used.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@deploy_pko/Role-muo-other.yaml` around lines 45 - 52, The Role currently
grants broad access to all secrets via apiGroups: "" and resources: secrets with
verbs get, list, watch; restrict the muo-pullsecret-reader role to only the
named secret by adding resourceNames: [pull-secret] under the secrets resource
and remove unused verbs so verbs contains only get (no list or watch) to match
util/access_token.go which only reads the pull-secret; update the Role
definition in Role-muo-other.yaml accordingly.

name: allow-from-openshift-managed-upgrade-operator
namespace: openshift-deployment-validation-operator
annotations:
package-operator.run/phase: network
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no such network phase.
Only available phases are crds|namespace|rbac|deploy
You can use deploy here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good. Looks better. However, in this case, you need to update the manifest.yaml as well. Because manifest.yaml only defines 4 phases.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch Tony. I have added policies phase to manifest.

@codecov-commenter
Copy link

codecov-commenter commented Mar 20, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 53.59%. Comparing base (350c2fb) to head (bb14873).

Additional details and impacted files

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #588   +/-   ##
=======================================
  Coverage   53.59%   53.59%           
=======================================
  Files         123      123           
  Lines        6165     6165           
=======================================
  Hits         3304     3304           
  Misses       2668     2668           
  Partials      193      193           
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@chamalabey
Copy link
Contributor Author

/test validate

@chamalabey
Copy link
Contributor Author

/retest

@openshift-ci
Copy link
Contributor

openshift-ci bot commented Mar 23, 2026

@chamalabey: all tests passed!

Full PR test history. Your PR dashboard.

Details

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository. I understand the commands that are listed here.

@tkong-redhat
Copy link
Contributor

Thank you for the update.
Can you please make the name consistency? I see other deployment yaml file are using managed-upgrade-operator not muo.

@tkong-redhat
Copy link
Contributor

Have you tested the new change locally?

@chamalabey
Copy link
Contributor Author

/retest

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants