Skip to content

Commit

Permalink
[Misc] Fix the mocked app role permission issue (#416)
Browse files Browse the repository at this point in the history
  • Loading branch information
Jeffwan authored Nov 21, 2024
1 parent 0bddbca commit 2c35db1
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
5 changes: 3 additions & 2 deletions docs/development/app/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,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 @@ -214,7 +214,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

0 comments on commit 2c35db1

Please sign in to comment.