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

[Fix] Add rolebinding namespace on namespace less ServiceAccount #314

Merged
merged 2 commits into from
Jan 14, 2025

Conversation

jt-dd
Copy link
Contributor

@jt-dd jt-dd commented Jan 14, 2025

In some cases, k8s ServiceAccount were added without namespace, which is not possible as they have to be bound to a namespace.

The error comes from the fact that rolebinding can be set on a namespace less service account (will bound automatically bound to the rolebinding one by default).

k describe rolebindings rb-test --namespace test                                                        
Name:         rb-test
Labels:       app=test-app
              chart_name=test-chart
              chart_version=0.1
              service=test-svc
              team=test-team
Annotations:  helm.sh/hook: post-install,post-upgrade
Role:
  Kind:  Role
  Name:  rb-test
Subjects:
  Kind            Name                Namespace
  ----            ----                ---------
  ServiceAccount  rb-test 

So if encountering this usecase, we add the namespace manually to rolebinding subjects and identity (serviceAccount) entries.

@jt-dd jt-dd marked this pull request as ready for review January 14, 2025 16:57
@jt-dd jt-dd requested a review from a team as a code owner January 14, 2025 16:57
Copy link
Contributor

@edznux-dd edznux-dd left a comment

Choose a reason for hiding this comment

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

I believe it would be a good thing to add that edge case in the test suite to avoid regression.

LGTM otherwise

@jt-dd
Copy link
Contributor Author

jt-dd commented Jan 14, 2025

I believe it would be a good thing to add that edge case in the test suite to avoid regression.

I modify the cluster config to test this behavior to avoid any regression in the future.

@jt-dd jt-dd merged commit dd25721 into main Jan 14, 2025
8 checks passed
@jt-dd jt-dd deleted the jt-dd/fix-PermissionDiscover-serviceAccount-matching branch January 14, 2025 18:09
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.

2 participants