|
| 1 | +apiVersion: apps/v1 |
| 2 | +kind: Deployment |
| 3 | +metadata: |
| 4 | + name: semantic-router |
| 5 | + namespace: vllm-semantic-router-system |
| 6 | + labels: |
| 7 | + app: semantic-router |
| 8 | +spec: |
| 9 | + replicas: 1 |
| 10 | + selector: |
| 11 | + matchLabels: |
| 12 | + app: semantic-router |
| 13 | + template: |
| 14 | + metadata: |
| 15 | + labels: |
| 16 | + app: semantic-router |
| 17 | + spec: |
| 18 | + initContainers: |
| 19 | + - name: model-downloader |
| 20 | + image: python:3.11-slim |
| 21 | + securityContext: |
| 22 | + runAsNonRoot: false |
| 23 | + allowPrivilegeEscalation: false |
| 24 | + command: ["/bin/bash", "-c"] |
| 25 | + args: |
| 26 | + - | |
| 27 | + set -e |
| 28 | + echo "Installing Hugging Face CLI..." |
| 29 | + pip install --no-cache-dir huggingface_hub[cli] |
| 30 | +
|
| 31 | + echo "Downloading models to persistent volume..." |
| 32 | + cd /app/models |
| 33 | +
|
| 34 | + # Download category classifier model |
| 35 | + if [ ! -d "category_classifier_modernbert-base_model" ]; then |
| 36 | + echo "Downloading category classifier model..." |
| 37 | + huggingface-cli download LLM-Semantic-Router/category_classifier_modernbert-base_model --local-dir category_classifier_modernbert-base_model |
| 38 | + else |
| 39 | + echo "Category classifier model already exists, skipping..." |
| 40 | + fi |
| 41 | +
|
| 42 | + # Download PII classifier model |
| 43 | + if [ ! -d "pii_classifier_modernbert-base_model" ]; then |
| 44 | + echo "Downloading PII classifier model..." |
| 45 | + huggingface-cli download LLM-Semantic-Router/pii_classifier_modernbert-base_model --local-dir pii_classifier_modernbert-base_model |
| 46 | + else |
| 47 | + echo "PII classifier model already exists, skipping..." |
| 48 | + fi |
| 49 | +
|
| 50 | + # Download jailbreak classifier model |
| 51 | + if [ ! -d "jailbreak_classifier_modernbert-base_model" ]; then |
| 52 | + echo "Downloading jailbreak classifier model..." |
| 53 | + huggingface-cli download LLM-Semantic-Router/jailbreak_classifier_modernbert-base_model --local-dir jailbreak_classifier_modernbert-base_model |
| 54 | + else |
| 55 | + echo "Jailbreak classifier model already exists, skipping..." |
| 56 | + fi |
| 57 | +
|
| 58 | + # Download PII token classifier model |
| 59 | + if [ ! -d "pii_classifier_modernbert-base_presidio_token_model" ]; then |
| 60 | + echo "Downloading PII token classifier model..." |
| 61 | + huggingface-cli download LLM-Semantic-Router/pii_classifier_modernbert-base_presidio_token_model --local-dir pii_classifier_modernbert-base_presidio_token_model |
| 62 | + else |
| 63 | + echo "PII token classifier model already exists, skipping..." |
| 64 | + fi |
| 65 | +
|
| 66 | + echo "All models downloaded successfully!" |
| 67 | + ls -la /app/models/ |
| 68 | + env: |
| 69 | + - name: HF_HUB_CACHE |
| 70 | + value: /tmp/hf_cache |
| 71 | + # Reduced resource requirements for init container |
| 72 | + resources: |
| 73 | + requests: |
| 74 | + memory: "512Mi" |
| 75 | + cpu: "250m" |
| 76 | + limits: |
| 77 | + memory: "1Gi" |
| 78 | + cpu: "500m" |
| 79 | + volumeMounts: |
| 80 | + - name: models-volume |
| 81 | + mountPath: /app/models |
| 82 | + containers: |
| 83 | + - name: semantic-router |
| 84 | + image: ghcr.io/vllm-project/semantic-router/extproc:latest |
| 85 | + args: ["--secure=true"] |
| 86 | + securityContext: |
| 87 | + runAsNonRoot: false |
| 88 | + allowPrivilegeEscalation: false |
| 89 | + ports: |
| 90 | + - containerPort: 50051 |
| 91 | + name: grpc |
| 92 | + protocol: TCP |
| 93 | + - containerPort: 9190 |
| 94 | + name: metrics |
| 95 | + protocol: TCP |
| 96 | + - containerPort: 8080 |
| 97 | + name: classify-api |
| 98 | + protocol: TCP |
| 99 | + env: |
| 100 | + - name: LD_LIBRARY_PATH |
| 101 | + value: "/app/lib" |
| 102 | + volumeMounts: |
| 103 | + - name: config-volume |
| 104 | + mountPath: /app/config |
| 105 | + readOnly: true |
| 106 | + - name: models-volume |
| 107 | + mountPath: /app/models |
| 108 | + livenessProbe: |
| 109 | + tcpSocket: |
| 110 | + port: 50051 |
| 111 | + initialDelaySeconds: 60 |
| 112 | + periodSeconds: 30 |
| 113 | + timeoutSeconds: 10 |
| 114 | + failureThreshold: 3 |
| 115 | + readinessProbe: |
| 116 | + tcpSocket: |
| 117 | + port: 50051 |
| 118 | + initialDelaySeconds: 90 |
| 119 | + periodSeconds: 30 |
| 120 | + timeoutSeconds: 10 |
| 121 | + failureThreshold: 3 |
| 122 | + # Significantly reduced resource requirements for kind cluster |
| 123 | + resources: |
| 124 | + requests: |
| 125 | + memory: "3Gi" # Reduced from 8Gi |
| 126 | + cpu: "1" # Reduced from 2 |
| 127 | + limits: |
| 128 | + memory: "6Gi" # Reduced from 12Gi |
| 129 | + cpu: "2" # Reduced from 4 |
| 130 | + volumes: |
| 131 | + - name: config-volume |
| 132 | + configMap: |
| 133 | + name: semantic-router-config |
| 134 | + - name: models-volume |
| 135 | + persistentVolumeClaim: |
| 136 | + claimName: semantic-router-models |
0 commit comments