Skip to content

Commit

Permalink
feat: add vllm-api-key
Browse files Browse the repository at this point in the history
Signed-off-by: kbvd623 <[email protected]>
  • Loading branch information
JustinDuy committed Mar 4, 2025
1 parent fd56e78 commit f339947
Show file tree
Hide file tree
Showing 10 changed files with 515 additions and 63 deletions.
17 changes: 17 additions & 0 deletions .github/curl-05-secure-vllm.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
VLLM_API_KEY=abc123XYZ987

# Curl and save output
OUTPUT_DIR="output-05-secure-vllm"
[ ! -d "$OUTPUT_DIR" ] && mkdir $OUTPUT_DIR
chmod -R 777 $OUTPUT_DIR

# shellcheck disable=SC2034 # result_model appears unused. Verify it or export it.
# Fetch model list with authentication
curl -s -H "Authorization: Bearer $VLLM_API_KEY" "http://$HOST:$PORT/v1/models" | tee "$OUTPUT_DIR/models-05-secure-vllm.json"

# Run completion query with authentication
curl -s -X POST -H "Authorization: Bearer $VLLM_API_KEY" \
-H "Content-Type: application/json" \
-d '{"model": "facebook/opt-125m", "prompt": "Once upon a time,", "max_tokens": 10}' \
"http://$HOST:$PORT/v1/completions" | tee "$OUTPUT_DIR/query-05-secure-vllm.json"
19 changes: 19 additions & 0 deletions .github/values-05-secure-vllm.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
servingEngineSpec:
runtimeClassName: ""
vllmApiKey: "abc123XYZ987"
modelSpec:
- name: "opt125m"
repository: "vllm/vllm-openai"
tag: "latest"
modelURL: "facebook/opt-125m"

replicaCount: 1

requestCPU: 6
requestMemory: "16Gi"
requestGPU: 1

routerSpec:
repository: "localhost:5000/git-act-router"
imagePullPolicy: "IfNotPresent"
enableRouter: true
36 changes: 35 additions & 1 deletion .github/workflows/functionality-helm-chart.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,41 @@ jobs:
sudo helm uninstall vllm
if: always()
- run: echo "🍏 This job's status is ${{ job.status }}."

Secure-Minimal-Example:
runs-on: self-hosted
steps:
- run: echo "🎉 The job was automatically triggered by a ${{ github.event_name }} event."
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by GitHub!"
- run: echo "🔎 The name of your branch is ${{ github.ref }} and your repository is ${{ github.repository }}."
- name: Check out repository code
uses: actions/checkout@v4
- run: echo "💡 The ${{ github.repository }} repository has been cloned to the runner."
- run: echo "🖥️ The workflow is now ready to test your code on the runner."
- name: Deploy via helm charts
env:
DOCKER_BUILDKIT: 1
run: |
cd ${{ github.workspace }}
sudo docker build -t localhost:5000/git-act-router -f docker/Dockerfile .
sudo docker push localhost:5000/git-act-router
sudo sysctl fs.protected_regular=0
sudo minikube image load localhost:5000/git-act-router
sudo helm install vllm ./helm -f .github/values-05-secure-vllm.yaml
- name: Validate the installation and send query to the stack
run: |
sudo bash .github/port-forward.sh curl-05-secure-vllm
timeout-minutes: 2
- name: Archive functionality results
uses: actions/upload-artifact@v4
with:
name: output-05-secure-vllm
path: |
output-05-secure-vllm/
- name: Helm uninstall
run: |
sudo helm uninstall vllm
if: always()
- run: echo "🍏 This job's status is ${{ job.status }}."
Two-Pods-Minimal-Example:
runs-on: self-hosted
needs: Minimal-Example
Expand Down
16 changes: 16 additions & 0 deletions helm/templates/deployment-router.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,22 @@ spec:
- name: router-container
image: "{{ .Values.routerSpec.repository | default "lmcache/lmstack-router" }}:{{ .Values.routerSpec.tag | default "latest" }}"
imagePullPolicy: "{{ .Values.routerSpec.imagePullPolicy | default "Always" }}"
env:
{{- $vllmApiKey := $.Values.servingEngineSpec.vllmApiKey }}
{{- if $vllmApiKey }}
- name: VLLM_API_KEY
{{- if kindIs "string" $vllmApiKey }}
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: vllmApiKey
{{- else }}
valueFrom:
secretKeyRef:
name: {{ $vllmApiKey.secretName }}
key: {{ $vllmApiKey.secretKey }}
{{- end }}
{{- end }}
args:
- "--host"
- "0.0.0.0"
Expand Down
15 changes: 15 additions & 0 deletions helm/templates/deployment-vllm-multi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,21 @@ spec:
key: {{ $modelSpec.hf_token.secretKey }}
{{- end }}
{{- end }}
{{- $vllmApiKey := $.Values.servingEngineSpec.vllmApiKey }}
{{- if $vllmApiKey }}
- name: VLLM_API_KEY
{{- if kindIs "string" $vllmApiKey }}
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: vllmApiKey
{{- else }}
valueFrom:
secretKeyRef:
name: {{ $vllmApiKey.secretName }}
key: {{ $vllmApiKey.secretKey }}
{{- end }}
{{- end }}
{{- with $modelSpec.env }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
5 changes: 5 additions & 0 deletions helm/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ metadata:
namespace: {{ .Release.Namespace }}
type: Opaque
data:
{{- $vllmApiKey := $.Values.servingEngineSpec.vllmApiKey }}
{{- if and $vllmApiKey (kindIs "string" $vllmApiKey) }}
vllmApiKey: {{ $vllmApiKey | b64enc | quote }}
{{- end }}

{{- range $modelSpec := .Values.servingEngineSpec.modelSpec }}
{{- with $ -}}
{{- if and $modelSpec.hf_token (kindIs "string" $modelSpec.hf_token) }}
Expand Down
Loading

0 comments on commit f339947

Please sign in to comment.