Skip to content

fix: split EPP RBAC into cluster and namespaced scoped permission #1071

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

Merged
merged 2 commits into from
Jul 31, 2025
Merged
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
38 changes: 29 additions & 9 deletions config/charts/inferencepool/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,6 @@ metadata:
labels:
{{- include "gateway-api-inference-extension.labels" . | nindent 4 }}
rules:
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencemodels", "inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: ["inference.networking.k8s.io"]
resources: ["inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups:
- authentication.k8s.io
resources:
Expand All @@ -40,6 +31,35 @@ roleRef:
kind: ClusterRole
name: {{ include "gateway-api-inference-extension.name" . }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ include "gateway-api-inference-extension.name" . }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "gateway-api-inference-extension.labels" . | nindent 4 }}
rules:
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencemodels", "inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ include "gateway-api-inference-extension.name" . }}
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ include "gateway-api-inference-extension.name" . }}
namespace: {{ .Release.Namespace }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ include "gateway-api-inference-extension.name" . }}
---
Copy link
Contributor

Choose a reason for hiding this comment

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

just making sure, was the helm chart tested and verified it's working?

Copy link
Member Author

Choose a reason for hiding this comment

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

I tested it again and encountered some issues. Opened #1274 to fix them.

apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
57 changes: 41 additions & 16 deletions config/manifests/inferencepool-resources.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@ spec:
appProtocol: http2
type: ClusterIP
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vllm-llama3-8b-instruct-epp
namespace: default
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -46,6 +52,7 @@ spec:
labels:
app: vllm-llama3-8b-instruct-epp
spec:
serviceAccountName: vllm-llama3-8b-instruct-epp
# Conservatively, this timeout should mirror the longest grace period of the pods within the pool
terminationGracePeriodSeconds: 130
containers:
Expand Down Expand Up @@ -174,23 +181,41 @@ data:
weight: 1
- pluginRef: max-score-picker
---
kind: ClusterRole
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read
namespace: default
rules:
- apiGroups: [ "inference.networking.x-k8s.io" ]
resources: [ "inferencemodels", "inferencepools" ]
verbs: [ "get", "watch", "list" ]
- apiGroups: [ "inference.networking.k8s.io" ]
resources: [ "inferencepools" ]
verbs: [ "get", "watch", "list" ]
- apiGroups: [ "" ]
resources: [ "pods" ]
verbs: [ "get", "watch", "list" ]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read-binding
namespace: default
subjects:
- kind: ServiceAccount
name: vllm-llama3-8b-instruct-epp
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: pod-read
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: auth-reviewer
rules:
- apiGroups: ["inference.networking.k8s.io"]
resources: ["inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencemodels"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups:
- authentication.k8s.io
resources:
Expand All @@ -207,12 +232,12 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read-binding
name: auth-reviewer-binding
subjects:
- kind: ServiceAccount
name: default
name: vllm-llama3-8b-instruct-epp
namespace: default
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: pod-read
name: auth-reviewer
19 changes: 17 additions & 2 deletions test/e2e/epp/e2e_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -392,14 +392,29 @@ func createInferExt(k8sClient client.Client, filePath string) {
ginkgo.By("Creating inference extension resources from manifest: " + filePath)
createObjsFromYaml(k8sClient, outManifests)

// Wait for the serviceaccount to exist.
testutils.EventuallyExists(ctx, func() error {
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: inferExtName}, &corev1.ServiceAccount{})
}, existsTimeout, interval)

// Wait for the role to exist.
testutils.EventuallyExists(ctx, func() error {
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: "pod-read"}, &rbacv1.Role{})
}, existsTimeout, interval)

// Wait for the rolebinding to exist.
testutils.EventuallyExists(ctx, func() error {
return k8sClient.Get(ctx, types.NamespacedName{Namespace: nsName, Name: "pod-read-binding"}, &rbacv1.RoleBinding{})
}, existsTimeout, interval)

// Wait for the clusterrole to exist.
testutils.EventuallyExists(ctx, func() error {
return k8sClient.Get(ctx, types.NamespacedName{Name: "pod-read"}, &rbacv1.ClusterRole{})
return k8sClient.Get(ctx, types.NamespacedName{Name: "auth-reviewer"}, &rbacv1.ClusterRole{})
}, existsTimeout, interval)

// Wait for the clusterrolebinding to exist.
testutils.EventuallyExists(ctx, func() error {
return k8sClient.Get(ctx, types.NamespacedName{Name: "pod-read-binding"}, &rbacv1.ClusterRoleBinding{})
return k8sClient.Get(ctx, types.NamespacedName{Name: "auth-reviewer-binding"}, &rbacv1.ClusterRoleBinding{})
}, existsTimeout, interval)

// Wait for the deployment to exist.
Expand Down
57 changes: 41 additions & 16 deletions test/testdata/inferencepool-e2e.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ spec:
appProtocol: http2
type: ClusterIP
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: vllm-llama3-8b-instruct-epp
namespace: $E2E_NS
---
apiVersion: apps/v1
kind: Deployment
metadata:
Expand All @@ -43,6 +49,7 @@ spec:
labels:
app: vllm-llama3-8b-instruct-epp
spec:
serviceAccountName: vllm-llama3-8b-instruct-epp
# Conservatively, this timeout should mirror the longest grace period of the pods within the pool
terminationGracePeriodSeconds: 130
containers:
Expand Down Expand Up @@ -171,23 +178,41 @@ data:
weight: 1
- pluginRef: max-score-picker
---
kind: ClusterRole
kind: Role
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read
namespace: $E2E_NS
rules:
- apiGroups: [ "inference.networking.x-k8s.io" ]
resources: [ "inferencemodels", "inferencepools" ]
verbs: [ "get", "watch", "list" ]
- apiGroups: [ "inference.networking.k8s.io" ]
resources: [ "inferencepools" ]
verbs: [ "get", "watch", "list" ]
- apiGroups: [ "" ]
resources: [ "pods" ]
verbs: [ "get", "watch", "list" ]
---
kind: RoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read-binding
namespace: $E2E_NS
subjects:
- kind: ServiceAccount
name: vllm-llama3-8b-instruct-epp
namespace: $E2E_NS
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: pod-read
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: auth-reviewer
rules:
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: ["inference.networking.x-k8s.io"]
resources: ["inferencemodels"]
verbs: ["get", "watch", "list"]
- apiGroups: ["inference.networking.k8s.io"]
resources: ["inferencepools"]
verbs: ["get", "watch", "list"]
- apiGroups: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups:
- authentication.k8s.io
resources:
Expand All @@ -204,12 +229,12 @@ rules:
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: pod-read-binding
name: auth-reviewer-binding
subjects:
- kind: ServiceAccount
name: default
name: vllm-llama3-8b-instruct-epp
namespace: $E2E_NS
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: pod-read
name: auth-reviewer
4 changes: 2 additions & 2 deletions test/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ import (
func DeleteClusterResources(ctx context.Context, cli client.Client) error {
binding := &rbacv1.ClusterRoleBinding{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-read-binding",
Name: "auth-reviewer-binding",
},
}
err := cli.Delete(ctx, binding, client.PropagationPolicy(metav1.DeletePropagationForeground))
Expand All @@ -54,7 +54,7 @@ func DeleteClusterResources(ctx context.Context, cli client.Client) error {
}
role := &rbacv1.ClusterRole{
ObjectMeta: metav1.ObjectMeta{
Name: "pod-read",
Name: "auth-reviewer",
},
}
err = cli.Delete(ctx, role, client.PropagationPolicy(metav1.DeletePropagationForeground))
Expand Down