DEV Community

Suresh Kumar Pallapothu
Suresh Kumar Pallapothu

Posted on Originally published at sureshpallapothu.in

Day 13: Helm Charts — Packaging, Versioning and Updating AI Deployments

A real AI stack has dozens of manifests across development, staging and production. Copied by hand, they drift: someone fixes staging, forgets production, and nobody knows which version is the truth. Helm bundles the manifests into a versioned, parameterised chart, so you roll out and roll back with a single command.

Diagram: FIG 1 · Copy-pasted manifests drift apart. A Helm chart is one versioned, parameterised package, and each environment supplies only its own values. See the animated version.

Chart layout

Diagram: FIG 2 · A chart holds metadata, default values, one values file per environment and a templates folder with the Kubernetes manifests. See the animated version.

  • Chart.yaml holds the chart name and a SemVer version.
  • values.yaml holds defaults for every setting.
  • values-staging.yaml and values-prod.yaml override only what differs, such as RAM or replica counts.
  • templates/ holds the Kubernetes manifests, written as templates.

Values and templates

# values.yaml
global:
  environment: production
  namespace: ai-platform

inferenceEngine:
  modelName: gemma-2-2b-it-awq
  image: vllm/vllm-openai:v0.5.0
  replicas: 2
  quantization: awq
  contextLength: 4096
  gpuMemoryUtilization: 0.85
  resources:
    requests: { cpu: "2", memory: 4Gi }
    limits:   { cpu: "4", memory: 8Gi }

vectorDatabase:
  image: qdrant/qdrant:v1.9.0
  replicas: 3
  storageSize: 20Gi
  storageClass: local-storage

autoscaling:
  enabled: true
  minReplicas: 1
  maxReplicas: 4
  targetQueueDepth: 10
Enter fullscreen mode Exit fullscreen mode
# templates/deployment-llm.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-llm
  namespace: {{ .Values.global.namespace }}
spec:
  replicas: {{ .Values.inferenceEngine.replicas }}
  selector:
    matchLabels: { app: {{ .Release.Name }}-llm }
  template:
    metadata:
      labels: { app: {{ .Release.Name }}-llm }
    spec:
      containers:
        - name: vllm
          image: {{ .Values.inferenceEngine.image }}
          args:
            - --model=/models/{{ .Values.inferenceEngine.modelName }}
            - --quantization={{ .Values.inferenceEngine.quantization }}
            - --max-model-len={{ .Values.inferenceEngine.contextLength }}
          resources:
            {{- toYaml .Values.inferenceEngine.resources | nindent 12 }}
Enter fullscreen mode Exit fullscreen mode

Diagram: FIG 3 · Helm merges your values into the templates to produce plain Kubernetes manifests. Always preview with helm template or a dry run. See the animated version.

Helm merges your values into the templates to produce plain Kubernetes YAML. Preview the result before you apply it with helm template, or --dry-run --debug.

Releases and rollbacks

helm lint ./helm-ai-stack
helm install local-ai ./helm-ai-stack --dry-run --debug
helm upgrade --install local-ai ./helm-ai-stack -f ./helm-ai-stack/values-staging.yaml
helm history local-ai
helm rollback local-ai 1
Enter fullscreen mode Exit fullscreen mode

Diagram: FIG 4 · Helm records each release as a numbered revision, so a bad upgrade can be undone with a single rollback command. See the animated version.

Each install or upgrade creates a numbered revision, and helm rollback returns to an earlier one in a single step. Version the chart in Git, keep image tags pinned and use one values file per environment, and your deployments become reviewable, repeatable and reversible.

Run it yourself

This is the exact example from the video. Real helm lint and helm template on a small chart. The template is trimmed from the lesson's version to fit.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Release.Name }}-llm
spec:
  replicas: {{ .Values.inferenceEngine.replicas }}
  selector:
    matchLabels: { app: {{ .Release.Name }}-llm }
  template:
    metadata:
      labels: { app: {{ .Release.Name }}-llm }
    spec:
      containers:
        - name: vllm
          image: {{ .Values.inferenceEngine.image }}
          args:
            - --quantization={{ .Values.inferenceEngine.quantization }}
Enter fullscreen mode Exit fullscreen mode

Helper file Chart.yaml, used by the run:

apiVersion: v2
name: helm-ai-stack
version: 0.1.0
Enter fullscreen mode Exit fullscreen mode

Helper file values.yaml, used by the run:

inferenceEngine:
  image: vllm/vllm-openai:v0.5.0
  replicas: 2
  quantization: awq
Enter fullscreen mode Exit fullscreen mode

Helper file values-staging.yaml, used by the run:

inferenceEngine:
  replicas: 1
Enter fullscreen mode Exit fullscreen mode

Run it:

helm template local-ai . -f values-staging.yaml
Enter fullscreen mode Exit fullscreen mode

Output I got while recording the video:

1 chart(s) linted, 0 chart(s) failed
name: local-ai-llm
replicas: 1
image: vllm/vllm-openai:v0.5.0
- --quantization=awq
Enter fullscreen mode Exit fullscreen mode

Coming Up Next

Day 14: Week 2 capstone: deploying a highly available local AI application on K3d.

Helm #Kubernetes #InfrastructureAsCode #DevOps #CICD #PlatformEngineering #ReleaseManagement


Originally published at https://sureshpallapothu.in/blog/ai-int-day-13-helm-charts, where this post includes animated diagrams.

Top comments (0)