Skip to content
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

[Misc] Fix the mocked app role permission issue #416

Merged
merged 1 commit into from
Nov 21, 2024
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
5 changes: 3 additions & 2 deletions docs/development/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

MODEL_NAME = 'llama2-70b'
DEPLOYMENT_NAME = os.getenv('DEPLOYMENT_NAME', 'llama2-70b')
NAMESPACE = os.getenv('NAMESPACE', 'aibrix-system')
NAMESPACE = os.getenv('POD_NAMESPACE', 'default')
DEFAULT_REPLICAS = int(os.getenv('DEFAULT_REPLICAS', '1'))

models = [
Expand Down Expand Up @@ -193,7 +193,8 @@ def metrics():
resp = apps_v1.read_namespaced_deployment(DEPLOYMENT_NAME, NAMESPACE)
replicas = resp.spec.replicas if resp.spec.replicas is not None else 1
except Exception as e:
print(f"Failed to get deployment information: {DEPLOYMENT_NAME=} {NAMESPACE=} {e=}, set replicas to {DEFAULT_REPLICAS}")
print(f"Failed to get deployment information: {DEPLOYMENT_NAME=} {NAMESPACE=} error={str(e)}")
print(f"Due to the failure, replicas {DEFAULT_REPLICAS} will be used to calculate metrics")
replicas = DEFAULT_REPLICAS

# a reasonable mock total value
Expand Down
21 changes: 11 additions & 10 deletions docs/development/app/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ spec:
adapter.model.aibrix.ai/enabled: "true"
model.aibrix.ai/name: "llama2-70b"
spec:
serviceAccountName: mocked-app-sa
containers:
- name: llmengine
- name: llm-engine
image: aibrix/vllm-mock:nightly
ports:
- containerPort: 8000
Expand Down Expand Up @@ -57,13 +58,13 @@ spec:
apiVersion: v1
kind: ServiceAccount
metadata:
name: pod-autoscaler
name: mocked-app-sa
namespace: default
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: pod-reader
name: mocked-app-pod-reader-role
namespace: default
rules:
- apiGroups: [""]
Expand All @@ -73,22 +74,22 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: read-pods
name: mocked-app-pod-reader-role-binding
namespace: default
subjects:
- kind: ServiceAccount
name: pod-autoscaler
name: mocked-app-sa
namespace: default
roleRef:
kind: Role
name: pod-reader
name: mocked-app-pod-reader-role
apiGroup: rbac.authorization.k8s.io
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: deployment-reader
name: mocked-app-deployment-reader-role
rules:
- apiGroups: ["apps"]
resources: ["deployments"]
Expand All @@ -97,15 +98,15 @@ rules:
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: deployment-reader-binding
name: mocked-app-deployment-reader-role-binding
namespace: default
subjects:
- kind: ServiceAccount
name: pod-autoscaler
name: mocked-app-sa
namespace: default
roleRef:
kind: Role
name: deployment-reader
name: mocked-app-deployment-reader-role
apiGroup: rbac.authorization.k8s.io
# ---
# for test-purpose, if need to create HTTPRoute object manually
Expand Down
Loading