Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion helm/templates/deployment-lora-controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ spec:
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ .Release.Name }}-lora-controller
serviceAccountName: {{ .Values.loraController.serviceAccountName | default (printf "%s-lora-controller" .Release.Name) }}
securityContext:
{{- toYaml .Values.loraController.podSecurityContext | nindent 8 }}
{{- if $.Values.sharedPvcStorage.enabled }}
Expand Down
2 changes: 1 addition & 1 deletion helm/templates/deployment-router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ spec:
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
serviceAccountName: {{ .Release.Name }}-router-service-account
serviceAccountName: {{ .Values.routerSpec.serviceAccountName | default (printf "%s-router-service-account" .Release.Name) }}
{{- if .Values.routerSpec.priorityClassName }}
priorityClassName: {{ .Values.routerSpec.priorityClassName | quote }}
{{- end }}
Expand Down
4 changes: 2 additions & 2 deletions helm/templates/role.yaml
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) -}}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Decoupling ServiceAccount creation from Role/ClusterRole creation is a standard Helm best practice. In many enterprise environments, the ServiceAccount is 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 Role creation when serviceAccountName is 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 Role and RoleBinding resources when the component is enabled, but bind them to the custom serviceAccountName if provided.

{{- if .Values.routerSpec.enableRouter -}}

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
Expand All @@ -14,7 +14,7 @@ rules:
verbs: ["get", "watch", "list", "patch"]
{{- end }}

{{- if .Values.loraController.enableLoraController }}
{{- if and .Values.loraController.enableLoraController (not .Values.loraController.serviceAccountName) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Similarly for the lora-controller, we should not skip the ClusterRole creation when a custom serviceAccountName is provided. This ensures that the required permissions are still managed by the chart while using the externally provisioned service account.

{{- if .Values.loraController.enableLoraController }}

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down
10 changes: 5 additions & 5 deletions helm/templates/rolebinding.yaml
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

To support using a custom serviceAccountName while still letting the chart manage the RoleBinding, we should keep the RoleBinding enabled and dynamically set the subject's name to the custom service account if provided.

{{- 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) }}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Keep the ClusterRoleBinding enabled even when a custom serviceAccountName is provided.

{{- if .Values.loraController.enableLoraController }}

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
Expand All @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Bind the ClusterRoleBinding to the custom serviceAccountName if specified.

subjects:
- kind: ServiceAccount
  name: {{ .Values.loraController.serviceAccountName | default (printf "%s-lora-controller" .Release.Name) }}
  namespace: {{ .Release.Namespace }}


---
Expand All @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Bind the leader election ClusterRoleBinding to the custom serviceAccountName if specified.

subjects:
- kind: ServiceAccount
  name: {{ .Values.loraController.serviceAccountName | default (printf "%s-lora-controller" .Release.Name) }}
  namespace: {{ .Release.Namespace }}

{{- end }}
4 changes: 2 additions & 2 deletions helm/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
{{- if .Values.routerSpec.enableRouter -}}
{{- if and .Values.routerSpec.enableRouter (not .Values.routerSpec.serviceAccountName) -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: "{{ .Release.Name }}-router-service-account"
namespace: {{ .Release.Namespace }}
{{- end }}

{{- if .Values.loraController.enableLoraController }}
{{- if and .Values.loraController.enableLoraController (not .Values.loraController.serviceAccountName) }}
---
apiVersion: v1
kind: ServiceAccount
Expand Down
23 changes: 23 additions & 0 deletions helm/tests/deployment-lora-controller_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -217,3 +217,26 @@ tests:
- name: vllm-shared-pvc-storage
persistentVolumeClaim:
claimName: "vllm-shared-pvc-storage-claim"

- it: should use generated service account name by default
release:
name: vllm
set:
loraController:
enableLoraController: true
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: vllm-lora-controller

- it: should use custom serviceAccountName when specified
release:
name: vllm
set:
loraController:
enableLoraController: true
serviceAccountName: my-existing-sa
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: my-existing-sa
23 changes: 23 additions & 0 deletions helm/tests/deployment-router_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -233,3 +233,26 @@ tests:
secretKeyRef:
name: custom-secret
key: custom-apikey

- it: should use generated service account name by default
release:
name: vllm
set:
routerSpec:
enableRouter: true
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: vllm-router-service-account

- it: should use custom serviceAccountName when specified
release:
name: vllm
set:
routerSpec:
enableRouter: true
serviceAccountName: my-existing-sa
asserts:
- equal:
path: spec.template.spec.serviceAccountName
value: my-existing-sa
76 changes: 76 additions & 0 deletions helm/tests/serviceaccount_rbac_test.yaml
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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Since we want to keep the Role and RoleBinding creation enabled and bind them to the custom service account, we should update this test to assert that they are created and bound to the custom service account name.

  - 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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

medium

Update this test to assert that the ClusterRole and ClusterRoleBinding are created and bound to the custom my-existing-lora-sa service account.

  - 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

121 changes: 121 additions & 0 deletions helm/tests/serviceaccount_test.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
8 changes: 8 additions & 0 deletions helm/values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -427,6 +427,10 @@
"description": "lora controller resources",
"type": "object"
},
"serviceAccountName": {
"description": "The name of an existing service account to use for the lora controller deployment.",
"type": "string"
},
"tolerations": {
"description": "Tolerations",
"type": "array"
Expand Down Expand Up @@ -884,6 +888,10 @@
"description": "Pod-level security context configuration. https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.32/#podsecuritycontext-v1-core",
"type": "object"
},
"serviceAccountName": {
"description": "The name of an existing service account to use for the router deployment.",
"type": "string"
},
"serviceAnnotations": {
"description": "Service annotations if you use a LoadBalancer or NodePort service type",
"type": "object"
Expand Down
8 changes: 8 additions & 0 deletions helm/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,10 @@ routerSpec:
# -- image pull policy for the router pod
imagePullPolicy: "Always" # @schema enum:[Always,IfNotPresent,Never]

# -- The name of an existing service account to use for the router deployment.
# -- If set, no ServiceAccount will be created and this name will be used directly.
serviceAccountName: ""

# -- Hugging Face token configuration
hf_token: ""

Expand Down Expand Up @@ -874,6 +878,10 @@ loraController:
# -- kubernetes cluster domain
kubernetesClusterDomain: "cluster.local"

# -- The name of an existing service account to use for the lora controller deployment.
# -- If set, no ServiceAccount will be created and this name will be used directly.
serviceAccountName: ""

# -- Number of lora controller replicas
replicaCount: 1

Expand Down
Loading