Skip to content

Commit fb01fe0

Browse files
yangyi.hu593671Blackoutta
authored andcommitted
feat: add helm charts
1 parent 08d4613 commit fb01fe0

File tree

10 files changed

+463
-9
lines changed

10 files changed

+463
-9
lines changed

Makefile

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ SRC = $(shell find . -type f -name '*.go')
4444

4545
.PHONY: help
4646
help: ## Print help
47-
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
47+
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $1, $2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($0, 5) } ' $(MAKEFILE_LIST)
4848

4949
GO_LDFLAGS := -extldflags '-L$(shell pwd)/lib $(LDFLAGS)'
5050
CGO_ENABLED=1
@@ -142,7 +142,20 @@ install-docker: check-container-tool ## Install app using $(CONTAINER_TOOL)
142142
uninstall-docker: check-container-tool ## Uninstall app from $(CONTAINER_TOOL)
143143
@echo "Stopping and removing container in $(CONTAINER_TOOL)..."
144144
-$(CONTAINER_TOOL) stop $(PROJECT_NAME)-container && $(CONTAINER_TOOL) rm $(PROJECT_NAME)-container
145-
@echo "$(CONTAINER_TOOL) uninstallation complete. Remove alias if set: unalias $(PROJECT_NAME)"
145+
@echo "$(CONTAINER_TOOL) uninstallation complete. Remove alias if set: unalias $(PROJECT_NAME)"
146+
147+
### Helm Targets
148+
.PHONY: install-helm
149+
install-helm: check-helm ## Install app using Helm
150+
@echo "Installing chart with Helm..."
151+
helm upgrade --install $(PROJECT_NAME) helm/$(PROJECT_NAME) --namespace default
152+
@echo "Helm installation complete."
153+
154+
.PHONY: uninstall-helm
155+
uninstall-helm: check-helm ## Uninstall app using Helm
156+
@echo "Uninstalling chart with Helm..."
157+
helm uninstall $(PROJECT_NAME) --namespace default
158+
@echo "Helm uninstallation complete."
146159

147160
.PHONY: env
148161
env: ## Print environment variables
@@ -152,13 +165,13 @@ env: ## Print environment variables
152165

153166

154167
##@ Tools
155-
156168
.PHONY: check-tools
157-
check-tools: \
158-
check-go \
159-
check-ginkgo \
160-
check-golangci-lint \
161-
check-container-tool
169+
check-tools:
170+
check-go \
171+
check-ginkgo \
172+
check-golangci-lint \
173+
check-container-tool \
174+
check-helm
162175
@echo "✅ All required tools are installed."
163176

164177
.PHONY: check-go
@@ -182,6 +195,12 @@ check-container-tool:
182195
echo "$(CONTAINER_TOOL) is not installed."; \
183196
echo "🔧 Try: sudo apt install $(CONTAINER_TOOL) OR brew install $(CONTAINER_TOOL)"; exit 1; }
184197

198+
.PHONY: check-helm
199+
check-helm:
200+
@command -v helm >/dev/null 2>&1 || { \
201+
echo "❌ helm is not installed. Install it from https://helm.sh/docs/intro/install/"; exit 1; }
202+
203+
185204
.PHONY: check-builder
186205
check-builder:
187206
@if [ -z "$(BUILDER)" ]; then \
@@ -194,7 +213,7 @@ check-builder:
194213
##@ Alias checking
195214
.PHONY: check-alias
196215
check-alias: check-container-tool
197-
@echo "🔍 Checking alias functionality for container '$(PROJECT_NAME)-container'..."
216+
@echo "🔍 Checking alias functionality for container '$(PROJECT_NAME)-container'வுகளை..."
198217
@if ! $(CONTAINER_TOOL) exec $(PROJECT_NAME)-container /app/$(PROJECT_NAME) --help >/dev/null 2>&1; then \
199218
echo "⚠️ The container '$(PROJECT_NAME)-container' is running, but the alias might not work."; \
200219
echo "🔧 Try: $(CONTAINER_TOOL) exec -it $(PROJECT_NAME)-container /app/$(PROJECT_NAME)"; \
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
apiVersion: v2
2+
name: llm-d-inference-sim
3+
description: A Helm chart for the vLLM Simulator
4+
5+
# A chart can be either an 'application' or a 'library' chart.
6+
#
7+
# Application charts are a collection of templates that can be packaged into versioned archives
8+
# to be deployed.
9+
#
10+
# Library charts provide useful utilities or functions for the chart developer. They're included as
11+
# a dependency of application charts to inject those utilities and functions into the rendering
12+
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
13+
type: application
14+
15+
# This is the chart version. This version number should be incremented each time you make changes
16+
# to the chart and its templates, including the app version.
17+
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18+
version: 0.1.0
19+
20+
# This is the version number of the application being deployed. This version number should be
21+
# incremented each time you make changes to the application. Versions are not expected to
22+
# follow Semantic Versioning. They should reflect the version the application is using.
23+
# It is recommended to use it with quotes.
24+
appVersion: "v0.4.0"
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
1. Get the application URL by running these commands:
2+
{{- if .Values.ingress.enabled }}
3+
{{- range $host := .Values.ingress.hosts }}
4+
{{- range .paths }}
5+
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
6+
{{- end }}
7+
{{- end }}
8+
{{- else if contains "NodePort" .Values.service.type }}
9+
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "llm-d-inference-sim.fullname" . }})
10+
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
11+
echo http://$NODE_IP:$NODE_PORT
12+
{{- else if contains "LoadBalancer" .Values.service.type }}
13+
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
14+
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "llm-d-inference-sim.fullname" . }}"'
15+
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "llm-d-inference-sim.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0)}}{{.}}{{ end }}"}}")
16+
echo http://$SERVICE_IP:{{ .Values.service.port }}
17+
{{- else if contains "ClusterIP" .Values.service.type }}
18+
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "llm-d-inference-sim.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
19+
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
20+
export LOCAL_PORT=8001
21+
export HOST_NAME=localhost
22+
23+
echo "Run 'kubectl port-forward --namespace {{ .Release.Namespace }} $POD_NAME $LOCAL_PORT:$CONTAINER_PORT &' to forward the port."
24+
echo "Then, you can test the service with:"
25+
26+
curl --request POST \
27+
--url http://$HOST_NAME:$LOCAL_PORT/v1/chat/completions \
28+
--header 'authorization: Bearer YOUR_API_KEY' \
29+
--header 'content-type: application/json' \
30+
--data '{
31+
"model": "model1",
32+
"messages": [
33+
{
34+
"role": "system",
35+
"content": "You are a helpful assistant."
36+
},
37+
{
38+
"role": "user",
39+
"content": "Hello!"
40+
}
41+
]
42+
}'
43+
{{- end }}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{{/*
2+
Expand the name of the chart.
3+
*/}}
4+
{{- define "llm-d-inference-sim.name" -}}
5+
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
6+
{{- end }}
7+
8+
{{/*
9+
Create a default fully qualified app name.
10+
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
11+
If release name contains chart name it will be used as a full name.
12+
*/}}
13+
{{- define "llm-d-inference-sim.fullname" -}}
14+
{{- if .Values.fullnameOverride }}
15+
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
16+
{{- else }}
17+
{{- $name := default .Chart.Name .Values.nameOverride }}
18+
{{- if contains $name .Release.Name }}
19+
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
20+
{{- else }}
21+
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
22+
{{- end }}
23+
{{- end }}
24+
{{- end }}
25+
26+
{{/*
27+
Create chart name and version as used by the chart label.
28+
*/}}
29+
{{- define "llm-d-inference-sim.chart" -}}
30+
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
31+
{{- end }}
32+
33+
{{/*
34+
Common labels
35+
*/}}
36+
{{- define "llm-d-inference-sim.labels" -}}
37+
helm.sh/chart: {{ include "llm-d-inference-sim.chart" . }}
38+
{{ include "llm-d-inference-sim.selectorLabels" . }}
39+
{{- if .Chart.AppVersion }}
40+
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
41+
{{- end }}
42+
app.kubernetes.io/managed-by: {{ .Release.Service }}
43+
{{- end }}
44+
45+
{{/*
46+
Selector labels
47+
*/}}
48+
{{- define "llm-d-inference-sim.selectorLabels" -}}
49+
app.kubernetes.io/name: {{ include "llm-d-inference-sim.name" . }}
50+
app.kubernetes.io/instance: {{ .Release.Name }}
51+
{{- end }}
52+
53+
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
apiVersion: v1
2+
kind: ConfigMap
3+
metadata:
4+
name: {{ include "llm-d-inference-sim.fullname" . }}-config
5+
labels:
6+
{{- include "llm-d-inference-sim.labels" . | nindent 4 }}
7+
data:
8+
config.yaml: |
9+
port: {{ .Values.config.port }}
10+
model: "{{ .Values.config.model }}"
11+
served-model-name:
12+
{{- toYaml .Values.config.servedModelName | nindent 4 }}
13+
max-loras: {{ .Values.config.maxLoras }}
14+
max-cpu-loras: {{ .Values.config.maxCpuLoras }}
15+
max-num-seqs: {{ .Values.config.maxNumSeqs }}
16+
max-model-len: {{ .Values.config.maxModelLen }}
17+
lora-modules:
18+
{{- toYaml .Values.config.loraModules | nindent 4 }}
19+
mode: "{{ .Values.config.mode }}"
20+
time-to-first-token: {{ .Values.config.timeToFirstToken }}
21+
inter-token-latency: {{ .Values.config.interTokenLatency }}
22+
kv-cache-transfer-latency: {{ .Values.config.kvCacheTransferLatency }}
23+
seed: {{ .Values.config.seed }}
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
apiVersion: apps/v1
2+
kind: Deployment
3+
metadata:
4+
name: {{ include "llm-d-inference-sim.fullname" . }}
5+
labels:
6+
{{- include "llm-d-inference-sim.labels" . | nindent 4 }}
7+
spec:
8+
replicas: {{ .Values.replicaCount }}
9+
selector:
10+
matchLabels:
11+
{{- include "llm-d-inference-sim.selectorLabels" . | nindent 6 }}
12+
template:
13+
metadata:
14+
annotations:
15+
checksum/config: {{ include (print .Template.BasePath "/configmap.yaml") . | sha256sum }}
16+
{{- with .Values.podAnnotations }}
17+
{{- toYaml . | nindent 8 }}
18+
{{- end }}
19+
labels:
20+
{{- include "llm-d-inference-sim.labels" . | nindent 8 }}
21+
{{- with .Values.podLabels }}
22+
{{- toYaml . | nindent 8 }}
23+
{{- end }}
24+
spec:
25+
{{- with .Values.imagePullSecrets }}
26+
imagePullSecrets:
27+
{{- toYaml . | nindent 8 }}
28+
{{- end }}
29+
{{- with .Values.podSecurityContext }}
30+
securityContext:
31+
{{- toYaml . | nindent 8 }}
32+
{{- end }}
33+
containers:
34+
- name: {{ .Chart.Name }}
35+
{{- with .Values.securityContext }}
36+
securityContext:
37+
{{- toYaml . | nindent 12 }}
38+
{{- end }}
39+
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
40+
imagePullPolicy: {{ .Values.image.pullPolicy }}
41+
args:
42+
- --config
43+
- /config/config.yaml
44+
env:
45+
- name: POD_NAME
46+
valueFrom:
47+
fieldRef:
48+
apiVersion: v1
49+
fieldPath: metadata.name
50+
- name: POD_NAMESPACE
51+
valueFrom:
52+
fieldRef:
53+
apiVersion: v1
54+
fieldPath: metadata.namespace
55+
ports:
56+
- name: http
57+
containerPort: {{ .Values.service.port }}
58+
protocol: TCP
59+
livenessProbe:
60+
httpGet:
61+
path: /health
62+
port: http
63+
readinessProbe:
64+
httpGet:
65+
path: /ready
66+
port: http
67+
{{- with .Values.resources }}
68+
resources:
69+
{{- toYaml . | nindent 12 }}
70+
{{- end }}
71+
volumeMounts:
72+
- name: config
73+
mountPath: /config
74+
volumes:
75+
- name: config
76+
configMap:
77+
name: {{ include "llm-d-inference-sim.fullname" . }}-config
78+
{{- with .Values.nodeSelector }}
79+
nodeSelector:
80+
{{- toYaml . | nindent 8 }}
81+
{{- end }}
82+
{{- with .Values.affinity }}
83+
affinity:
84+
{{- toYaml . | nindent 8 }}
85+
{{- end }}
86+
{{- with .Values.tolerations }}
87+
tolerations:
88+
{{- toYaml . | nindent 8 }}
89+
{{- end }}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{{- if .Values.ingress.enabled -}}
2+
apiVersion: networking.k8s.io/v1
3+
kind: Ingress
4+
metadata:
5+
name: {{ include "llm-d-inference-sim.fullname" . }}
6+
labels:
7+
{{- include "llm-d-inference-sim.labels" . | nindent 4 }}
8+
{{- with .Values.ingress.annotations }}
9+
annotations:
10+
{{- toYaml . | nindent 4 }}
11+
{{- end }}
12+
spec:
13+
{{- with .Values.ingress.className }}
14+
ingressClassName: {{ . }}
15+
{{- end }}
16+
{{- if .Values.ingress.tls }}
17+
tls:
18+
{{- range .Values.ingress.tls }}
19+
- hosts:
20+
{{- range .hosts }}
21+
- {{ . | quote }}
22+
{{- end }}
23+
secretName: {{ .secretName }}
24+
{{- end }}
25+
{{- end }}
26+
rules:
27+
{{- range .Values.ingress.hosts }}
28+
- host: {{ .host | quote }}
29+
http:
30+
paths:
31+
{{- range .paths }}
32+
- path: {{ .path }}
33+
{{- with .pathType }}
34+
pathType: {{ . }}
35+
{{- end }}
36+
backend:
37+
service:
38+
name: {{ include "llm-d-inference-sim.fullname" $ }}
39+
port:
40+
number: {{ $.Values.service.port }}
41+
{{- end }}
42+
{{- end }}
43+
{{- end }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ include "llm-d-inference-sim.fullname" . }}
5+
labels:
6+
{{- include "llm-d-inference-sim.labels" . | nindent 4 }}
7+
spec:
8+
type: {{ .Values.service.type }}
9+
ports:
10+
- port: {{ .Values.service.port }}
11+
targetPort: http
12+
protocol: TCP
13+
name: http
14+
selector:
15+
{{- include "llm-d-inference-sim.selectorLabels" . | nindent 4 }}

0 commit comments

Comments
 (0)