-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Fully support generation of K8s RBAC resources #31797
Conversation
🙈 The PR is closed and the preview is expired. |
There was an old abandoned pull request: #21595 that was related this. I will come back with a detailed review later today. |
This comment has been minimized.
This comment has been minimized.
The configuration feels more verbose than it needs to. To deal with the listed issues all we have to do is allow customization of the actual permission the application has.
So what do we need?
Note: I don't intend to veto those changes, as it is a step forward over what we have and honestly last time I did in #21595 resulted in 18 months of doing nothing, but I am leaving this comment just to express my view. |
Probably, it's more verbose than it needs to be, but it also gives much more freedom to generate complex RBAC resources (for example: for operator generation). So, it's up to the user to generate as many resources as they desire. |
@iocanel are you ok with the changes part of this pull request as they are? I don't think we lose anything if we allow users generating as many RBAC resources as they need. |
We do loose simplicity and ease of use. Anyway, this is clearly an improvement over what we have so yeah I am ok with it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be documented.
+1 |
PR updated with updates on the documentation. |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The implementation overall looks good with some minor improvements that have been marked on the documentation. These are changes I'd like us to introduce to make things slightly less verbose (but without altering the nature of the pull request).
Also added some change requests on the structure of documentation, so that it's less intimidating and easier to digest.
quarkus.kubernetes.rbac.role-bindings.my-role-binding.cluster-wide=false | ||
|
||
# Use the service account "my-service-account" in the application | ||
quarkus.kubernetes.service-account=my-service-account <3> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am wondering if this could be inferred.
We could possibly generated namespace when a namespace has been defined for the deployment or is referred by the rules.
The only challenge is what happens, if we want to refer to an externally created ServiceAccount
. However, this is not our job and on top of that what we generate should be standalone.
TLDR: This should be optional.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would actually avoid the "inferred" configuration, so it should be up to the user to use one service account or another.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should always use the application service account, unless explicitly specified.
There is absolutely no reason specifying 2 full lines of configuration for something that should be the application service account for most of the cases.
@iocanel I've updated the changes you suggested and making fully optional to configure the role binding:
Also, I've created a logic that detects the cluster-wide flag when configuring the role binding. Please, have another round to review again the changes. |
01ba465
to
e253425
Compare
This comment has been minimized.
This comment has been minimized.
@iocanel PR updated with:
|
Why do we have this change? edit: I mean why do we change the behavior of |
The behavior change is that regardless of the value in However, when using the extension |
This is something I totally agree! |
I would approach it the other way around given that the So, here's how I think that it should work:
|
PR updated again by avoiding the breaking change between kubernetes-config and kubernetes-client extensions, this will keep working as before. The only think to note in the migration guide is:
|
fa406aa
to
adc7c1d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
These changes address a long-time issue in regards of K8s RBAC resources (see related issues). These changes allow to generate custom Roles, ClusterRoles, ServiceAccount, and RoleBindings. Plus, it allows the Kubernetes Client and Kubernetes Config extensions to configure the role binding to generate. Fix quarkusio#16612 Fix quarkusio#19286 Fix quarkusio#15422
Failing Jobs - Building ea9425b
Full information is available in the Build summary check run. Failures⚙️ JVM Tests - JDK 11 #- Failing: integration-tests/opentelemetry-jdbc-instrumentation
📦 integration-tests/opentelemetry-jdbc-instrumentation✖
|
The failure is unrelated. Merging. |
I'm currently experimenting with cluster role generation through the .properties config but, I can't get my head around how to specify the core API group for the cluster role. Because if I just left it blank the API group fields don't get generated at all and I get this: apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: conductor-role
rules:
resources:
- pods
- namespaces
verbs:
- get
- watch
- list
- create
- update
- patch
- delete If I specify this '' as per official K8s documentation I get this: apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: conductor-role
rules:
- apiGroups:
- ''''''
resources:
- pods
- namespaces
verbs:
- get
- watch
- list
- create
- update
- patch And if I try "" then I get this: apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: conductor-role
rules:
- apiGroups:
- '""'
resources:
- pods
- namespaces
verbs:
- get
- watch
- list
- create
- update
- patch I also tried just not specifying it at all but that resulted (Same error occurs for example 1 as well) in k8s error:
|
Thanks for spotting. This is indeed an issue. I've reported it in #32519. |
Also, I have noticed something which I don't know if it's intended or not but I have been testing cluster role generation in kubernetes config it generated RoleBinging instead of ClusterRoleBinding, and because of that when I was using the k8s client it didn't seem like I had the role bound because I didn't have access to resources which I should have if that role was assigned. Edit: After reading k8s documentation I came to the conclusion that this isn't probably a bug. Since you can bind via RoleBinging but it will make that role available for that specific namespace. But since I have been trying to create a new namespace that probably counts as accessing a new namespace so RoleBinging doesn't cover that. |
These changes address a long-time issue regarding K8s RBAC resources (see related issues).
These changes allow generating the Roles, ClusterRoles, ServiceAccount, and RoleBindings resources. Plus, it will enable the Kubernetes Client and Kubernetes Config extensions to configure the role binding to generate.
Fix #16612
Fix #19286
Fix #15422