-
Notifications
You must be signed in to change notification settings - Fork 448
Feat(helm): Modify the existing serviceAccount for use by router and lora-controller #1005
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
base: main
Are you sure you want to change the base?
Changes from all commits
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 |
|---|---|---|
| @@ -1,4 +1,4 @@ | ||
| {{- if .Values.routerSpec.enableRouter -}} | ||
| {{- if and .Values.routerSpec.enableRouter (not .Values.routerSpec.serviceAccountName) -}} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: Role | ||
| metadata: | ||
|
|
@@ -14,7 +14,7 @@ rules: | |
| verbs: ["get", "watch", "list", "patch"] | ||
| {{- end }} | ||
|
|
||
| {{- if .Values.loraController.enableLoraController }} | ||
| {{- if and .Values.loraController.enableLoraController (not .Values.loraController.serviceAccountName) }} | ||
|
Contributor
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. Similarly for the {{- if .Values.loraController.enableLoraController }} |
||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRole | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,20 +1,20 @@ | ||
| {{- if .Values.routerSpec.enableRouter -}} | ||
| {{- if and .Values.routerSpec.enableRouter (not .Values.routerSpec.serviceAccountName) -}} | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: RoleBinding | ||
| metadata: | ||
| name: {{ .Release.Name }}-deployment-access-binding | ||
| namespace: {{ .Release.Namespace }} | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ .Release.Name }}-router-service-account | ||
| name: {{ printf "%s-router-service-account" .Release.Name }} | ||
| namespace: {{ .Release.Namespace }} | ||
| roleRef: | ||
| kind: Role | ||
| name: {{ .Release.Name }}-reader | ||
| apiGroup: rbac.authorization.k8s.io | ||
| {{- end }} | ||
|
Comment on lines
+1
to
15
Contributor
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. To support using a custom {{- if .Values.routerSpec.enableRouter -}}
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-deployment-access-binding
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ .Values.routerSpec.serviceAccountName | default (printf "%s-router-service-account" .Release.Name) }}
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-reader
apiGroup: rbac.authorization.k8s.io
{{- end }} |
||
|
|
||
| {{- if .Values.loraController.enableLoraController }} | ||
| {{- if and .Values.loraController.enableLoraController (not .Values.loraController.serviceAccountName) }} | ||
|
Contributor
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. |
||
| --- | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| kind: ClusterRoleBinding | ||
|
|
@@ -29,7 +29,7 @@ roleRef: | |
| name: {{ .Release.Name }}-lora-controller | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ .Release.Name }}-lora-controller | ||
| name: {{ printf "%s-lora-controller" .Release.Name }} | ||
| namespace: {{ .Release.Namespace }} | ||
|
Comment on lines
30
to
33
Contributor
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. |
||
|
|
||
| --- | ||
|
|
@@ -46,6 +46,6 @@ roleRef: | |
| name: {{ .Release.Name }}-leader-election-role | ||
| subjects: | ||
| - kind: ServiceAccount | ||
| name: {{ .Release.Name }}-lora-controller | ||
| name: {{ printf "%s-lora-controller" .Release.Name }} | ||
| namespace: {{ .Release.Namespace }} | ||
|
Comment on lines
47
to
50
Contributor
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. |
||
| {{- end }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| suite: test Role and RoleBinding creation with serviceAccountName | ||
| templates: | ||
| - role.yaml | ||
| - rolebinding.yaml | ||
| tests: | ||
| - it: should create Role and RoleBinding when serviceAccountName is not set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: "" | ||
| asserts: | ||
| - containsDocument: | ||
| kind: Role | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| name: vllm-reader | ||
| template: role.yaml | ||
| - containsDocument: | ||
| kind: RoleBinding | ||
| apiVersion: rbac.authorization.k8s.io/v1 | ||
| name: vllm-deployment-access-binding | ||
| template: rolebinding.yaml | ||
|
|
||
| - it: should NOT create Role and RoleBinding when custom serviceAccountName is set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: my-existing-sa | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
Comment on lines
+25
to
+34
Contributor
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. Since we want to keep the - it: should create Role and RoleBinding with custom serviceAccountName when specified
release:
name: vllm
set:
routerSpec:
enableRouter: true
serviceAccountName: my-existing-sa
asserts:
- containsDocument:
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
name: vllm-reader
template: role.yaml
- containsDocument:
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
name: vllm-deployment-access-binding
template: rolebinding.yaml
- equal:
path: subjects[0].name
value: my-existing-sa
documentIndex: 0
template: rolebinding.yaml |
||
|
|
||
| - it: should NOT create Role and RoleBinding when router is disabled | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: should create ClusterRole and ClusterRoleBinding when lora serviceAccountName is not set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: "" | ||
| asserts: | ||
| - equal: | ||
| path: metadata.name | ||
| value: vllm-lora-controller | ||
| documentIndex: 0 | ||
| template: role.yaml | ||
| - equal: | ||
| path: metadata.name | ||
| value: vllm-lora-controller | ||
| documentIndex: 0 | ||
| template: rolebinding.yaml | ||
|
|
||
| - it: should NOT create ClusterRole and ClusterRoleBinding when lora serviceAccountName is set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: my-existing-lora-sa | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
Comment on lines
+65
to
+76
Contributor
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. Update this test to assert that the - it: should create ClusterRole and ClusterRoleBinding with custom serviceAccountName when specified
release:
name: vllm
set:
routerSpec:
enableRouter: false
loraController:
enableLoraController: true
serviceAccountName: my-existing-lora-sa
asserts:
- equal:
path: metadata.name
value: vllm-lora-controller
documentIndex: 0
template: role.yaml
- equal:
path: metadata.name
value: vllm-lora-controller
documentIndex: 0
template: rolebinding.yaml
- equal:
path: subjects[0].name
value: my-existing-lora-sa
documentIndex: 0
template: rolebinding.yaml |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,121 @@ | ||
| suite: test ServiceAccount creation | ||
| templates: | ||
| - serviceaccount.yaml | ||
| tests: | ||
| # Router ServiceAccount tests | ||
| - it: should create router ServiceAccount when serviceAccountName is not set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: "" | ||
| loraController: | ||
| enableLoraController: false | ||
| asserts: | ||
| - containsDocument: | ||
| kind: ServiceAccount | ||
| apiVersion: v1 | ||
| name: vllm-router-service-account | ||
|
|
||
| - it: should NOT create router ServiceAccount when serviceAccountName is specified | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: my-existing-sa | ||
| loraController: | ||
| enableLoraController: false | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: should NOT create router ServiceAccount when router is disabled | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| loraController: | ||
| enableLoraController: false | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| # Lora Controller ServiceAccount tests | ||
| - it: should create lora-controller ServiceAccount when serviceAccountName is not set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: "" | ||
| asserts: | ||
| - containsDocument: | ||
| kind: ServiceAccount | ||
| apiVersion: v1 | ||
| name: vllm-lora-controller | ||
|
|
||
| - it: should NOT create lora-controller ServiceAccount when serviceAccountName is specified | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: false | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: my-existing-lora-sa | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 0 | ||
|
|
||
| - it: should create both ServiceAccounts when both are enabled and no custom names set | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: "" | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: "" | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 2 | ||
|
|
||
| - it: should create only lora-controller ServiceAccount when router uses custom name | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: my-existing-router-sa | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: "" | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 1 | ||
| - containsDocument: | ||
| kind: ServiceAccount | ||
| apiVersion: v1 | ||
| name: vllm-lora-controller | ||
|
|
||
| - it: should create only router ServiceAccount when lora-controller uses custom name | ||
| release: | ||
| name: vllm | ||
| set: | ||
| routerSpec: | ||
| enableRouter: true | ||
| serviceAccountName: "" | ||
| loraController: | ||
| enableLoraController: true | ||
| serviceAccountName: my-existing-lora-sa | ||
| asserts: | ||
| - hasDocuments: | ||
| count: 1 | ||
| - containsDocument: | ||
| kind: ServiceAccount | ||
| apiVersion: v1 | ||
| name: vllm-router-service-account |
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.
Decoupling
ServiceAccountcreation fromRole/ClusterRolecreation is a standard Helm best practice. In many enterprise environments, theServiceAccountis pre-created externally (e.g., to associate it with AWS IRSA or GCP Workload Identity), but the Helm chart is still expected to manage and create the application-specific RBAC roles and bindings.By skipping
Rolecreation whenserviceAccountNameis set, users are forced to manually define and maintain these complex RBAC rules externally, which is error-prone and hard to maintain during chart upgrades.Instead, we should always create the
RoleandRoleBindingresources when the component is enabled, but bind them to the customserviceAccountNameif provided.{{- if .Values.routerSpec.enableRouter -}}