-
Notifications
You must be signed in to change notification settings - Fork 402
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
[Feature] Watch CR in multiple namespaces with namespaced RBAC resources #1106
Changes from all commits
5fd1446
6e27ff4
853026b
b04ce3d
41fedd0
28cb9b9
d4f183c
ecba427
f209400
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,8 +2,7 @@ | |
kind: Role | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
labels: | ||
{{ include "kuberay-operator.labels" . | indent 4 }} | ||
labels: {{ include "kuberay-operator.labels" . | nindent 4 }} | ||
name: {{ include "kuberay-operator.fullname" . }}-leader-election | ||
rules: | ||
- apiGroups: | ||
|
@@ -32,4 +31,13 @@ rules: | |
- events | ||
verbs: | ||
- create | ||
- apiGroups: | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Necessary for leader election. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For my education, how did you notice that this was necessary? (Did some test fail?) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I attempted to skip the installation of |
||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- update | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,240 @@ | ||
# Install Role for namespaces listed in watchNamespace. | ||
# This should be consistent with `role.yaml`, except for the `kind` field. | ||
{{- if and .Values.rbacEnable .Values.singleNamespaceInstall }} | ||
{{- $watchNamespaces := default (list .Release.Namespace) .Values.watchNamespace }} | ||
{{- range $namespace := $watchNamespaces }} | ||
--- | ||
kind: Role | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm wondering if we could add thescenario: More specifically, when
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Originally, I intended to achieve this by updating |
||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
labels: {{ include "kuberay-operator.labels" $ | nindent 4 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In a |
||
name: {{ include "kuberay-operator.fullname" $ }} | ||
namespace: {{ $namespace }} | ||
rules: | ||
- apiGroups: | ||
- coordination.k8s.io | ||
resources: | ||
- leases | ||
verbs: | ||
- create | ||
- get | ||
- list | ||
- update | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- events | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- pods/status | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- serviceaccounts | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- services | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- "" | ||
resources: | ||
- services/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- ingresses | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- networking.k8s.io | ||
resources: | ||
- ingressclasses | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- networking.k8s.io | ||
resources: | ||
- ingresses | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayclusters | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayclusters/finalizers | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayclusters/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayjobs | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayjobs/finalizers | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayjobs/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayservices | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- patch | ||
- update | ||
- watch | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayservices/finalizers | ||
verbs: | ||
- update | ||
- apiGroups: | ||
- ray.io | ||
resources: | ||
- rayservices/status | ||
verbs: | ||
- get | ||
- patch | ||
- update | ||
- apiGroups: | ||
- rbac.authorization.k8s.io | ||
resources: | ||
- rolebindings | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- rbac.authorization.k8s.io | ||
resources: | ||
- roles | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- update | ||
- watch | ||
{{- if $.Values.batchScheduler.enabled }} | ||
- apiGroups: | ||
- scheduling.volcano.sh | ||
resources: | ||
- podgroups | ||
verbs: | ||
- create | ||
- delete | ||
- get | ||
- list | ||
- update | ||
- watch | ||
- apiGroups: | ||
- apiextensions.k8s.io | ||
resources: | ||
- customresourcedefinitions | ||
verbs: | ||
- get | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# Install RoleBinding for namespaces listed in watchNamespace. | ||
# This should be consistent with `rolebinding.yaml`, except for the `kind` field. | ||
{{- if and .Values.rbacEnable .Values.singleNamespaceInstall }} | ||
{{- $watchNamespaces := default (list .Release.Namespace) .Values.watchNamespace }} | ||
{{- range $namespace := $watchNamespaces }} | ||
--- | ||
kind: RoleBinding | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
labels: {{ include "kuberay-operator.labels" $ | nindent 4 }} | ||
name: {{ include "kuberay-operator.fullname" $ }} | ||
namespace: {{ $namespace }} | ||
subjects: | ||
- kind: ServiceAccount | ||
name: {{ $.Values.serviceAccount.name }} | ||
namespace: {{ $.Release.Namespace }} | ||
roleRef: | ||
kind: Role | ||
name: {{ include "kuberay-operator.fullname" $ }} | ||
apiGroup: rbac.authorization.k8s.io | ||
{{- end }} | ||
{{- end }} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,10 @@ | ||
# permissions for end users to edit rayjobs. | ||
{{- if .Values.rbacEnable }} | ||
{{- if and .Values.rbacEnable (not .Values.singleNamespaceInstall) }} | ||
|
||
{{- if .Values.singleNamespaceInstall }} | ||
kind: Role | ||
{{- else }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the effect of this change? It looks like now we don't create these roles if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (Is it because we're replacing these roles with the new There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
The permissions of this file are a subset of those in |
||
kind: ClusterRole | ||
{{- end }} | ||
apiVersion: rbac.authorization.k8s.io/v1 | ||
metadata: | ||
labels: | ||
{{ include "kuberay-operator.labels" . | indent 4 }} | ||
labels: {{ include "kuberay-operator.labels" . | nindent 4 }} | ||
name: rayjob-editor-role | ||
rules: | ||
- apiGroups: | ||
|
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.
Case 1: If
singleNamespaceInstall
is set to true andwatchNamespace
is not specified, the KubeRay operator will only watch the namespace where the operator is deployed.Case 2: If
watchNamespace
is specified, the KubeRay operator will watch all namespaces listed in the variable. In this case, we concatenate all namespaces into a string separated by commas. Then, the string will be parsed bystrings.Split(watchNamespace, ",")
in main.go.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.
Based on this, it looks like
singleNamespaceInstall
andwatchNamespace
are existing fields in KubeRay. The new behavior for both is clearly explained by Cases 1-4. The old behavior forsingleNamespaceInstall
is also described. But I think the old behavior ofwatchNamespace
is missing from the PR description, do you mind adding it? (Maybe the only change is that it now supports multiple namespaces?)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.
Just to double check, are commas
,
forbidden characters in namespaces?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 behavior is described by the comments in
values.yaml
. The comments are deleted by this PR.The flag
--watch-namespace
is a list of namespaces, separated by commas. It will be parsed bywatchNamespaces := strings.Split(watchNamespace, ",")
inmain.go
.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.
Right, but if a namespace is allowed to have a comma in it then breaking by commas won't work. Anyways I checked and it looks like namespaces can only have alphanumeric characters, so it's fine.
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.
Oh, I understand now. I missed that part. Thank you for pointing it out!