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

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
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 Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ help: ## Display this help.
##@ Development

.PHONY: manifests
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
manifests: controller-gen ## Generate WebhookConfiguration, RBAC and CustomResourceDefinition objects.
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases

.PHONY: generate
Expand Down
35 changes: 29 additions & 6 deletions config/charts/inferencepool/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +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: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups:
- authentication.k8s.io
resources:
Expand All @@ -37,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" . }}
---
apiVersion: v1
kind: ServiceAccount
metadata:
Expand Down
53 changes: 39 additions & 14 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,20 +181,38 @@ 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: [ "inferencepools", "inferencemodels" ]
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.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 @@ -200,16 +225,16 @@ rules:
- subjectaccessreviews
verbs:
- create
---
---
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 @@ -384,14 +384,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
51 changes: 38 additions & 13 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,20 +178,38 @@ 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: [ "inferencepools", "inferencemodels" ]
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: [""]
resources: ["pods"]
verbs: ["get", "watch", "list"]
- apiGroups:
- authentication.k8s.io
resources:
Expand All @@ -201,12 +226,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 @@ -43,7 +43,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 @@ -52,7 +52,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