| description | Generate Helm chart for Kubernetes application |
| shortcut | kh |
| category | devops |
| difficulty | advanced |
| estimated_time | 3 minutes |
Helm Chart Generator
Creates production-ready Helm charts for Kubernetes applications with parameterized templates, values files, and best practices.
When to Use This
- Package app for multiple environments (dev, staging, prod)
- Need configurable deployments (replicas, resources, ingress)
- Want version-controlled releases
- Deploy to multiple clusters with different configs
- Single environment deployment (use
/k8s-manifest-generate)
- Quick one-off deployment (use
kubectl run)
How It Works
You are a Helm expert. When user runs /k8s-helm-chart or /kh:
-
Detect application:
- Identify workload type (Deployment, StatefulSet)
- Determine configuration needs
- Check for persistence requirements
- Assess external access needs
-
Generate chart structure:
mychart/
├── Chart.yaml # Chart metadata
├── values.yaml # Default values
├── values-dev.yaml # Dev overrides
├── values-prod.yaml # Production overrides
├── templates/
│ ├── deployment.yaml # Parameterized deployment
│ ├── service.yaml # Parameterized service
│ ├── ingress.yaml # Conditional ingress
│ ├── configmap.yaml # Configuration
│ ├── secret.yaml # Secrets (template only)
│ ├── hpa.yaml # Auto-scaling (conditional)
│ └── _helpers.tpl # Template helpers
└── README.md # Usage documentation
-
Parameterize templates:
- Use Go templating (
{{ .Values.* }})
- Add conditionals for optional resources
- Create reusable helpers
- Apply naming conventions
-
Provide values files:
- Sensible defaults in values.yaml
- Environment-specific overrides
- Comments explaining each value
-
Include deployment guide:
- Installation commands
- Upgrade procedures
- Rollback instructions
- Values customization guide
Output Format
# Complete chart directory structure
# Ready to use with helm install/upgrade
## Installation
### Install chart:
```bash
helm install myapp ./mychart -f values-prod.yaml
Upgrade:
helm upgrade myapp ./mychart -f values-prod.yaml
Rollback:
helm rollback myapp <revision>
## Example
**User:** `/kh` (for Node.js API)
**Questions:**
- App name? → `nodejs-api`
- Chart version? → `1.0.0`
- Default image? → `myregistry/nodejs-api:latest`
- Configurable options? → Replicas, resources, ingress, auto-scaling
**Output:**
```yaml
# Chart.yaml
apiVersion: v2
name: nodejs-api
description: Production-ready Node.js API Helm chart
type: application
version: 1.0.0
appVersion: "1.0.0"
keywords:
- nodejs
- api
- microservice
maintainers:
- name: Your Name
email: [email protected]
image:
repository: myregistry/nodejs-api
pullPolicy: IfNotPresent
tag: "latest"
replicaCount: 3
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: 500m
memory: 1Gi
autoscaling:
enabled: true
minReplicas: 2
maxReplicas: 10
targetCPUUtilizationPercentage: 70
targetMemoryUtilizationPercentage: 80
service:
type: ClusterIP
port: 80
targetPort: 3000
ingress:
enabled: true
className: nginx
annotations:
{}
{}
[]
{}
replicaCount: 1
autoscaling:
enabled: false
image:
tag: "dev"
resources:
requests:
cpu: 100m
memory: 256Mi
limits:
cpu: 250m
memory: 512Mi
ingress:
enabled: true
hosts:
- host: api-dev.example.com
paths:
- path: /
pathType: Prefix
config:
NODE_ENV: "development"
LOG_LEVEL: "debug"
replicaCount: 5
image:
tag: "1.0.0"
autoscaling:
enabled: true
minReplicas: 3
maxReplicas: 20
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 1000m
memory: 2Gi
ingress:
enabled: true
annotations:
cert-manager.io/cluster-issuer: "letsencrypt-prod"
nginx.ingress.kubernetes.io/rate-limit: "100"
hosts:
- host: api.example.com
paths:
- path: /
pathType: Prefix
config:
NODE_ENV: "production"
LOG_LEVEL: "info"
podDisruptionBudget:
enabled: true
minAvailable:
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "nodejs-api.selectorLabels" . | nindent 6 }}
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 1
maxUnavailable: 0
template:
metadata:
annotations:
checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "nodejs-api.selectorLabels" . | nindent 4 }}
{{- if .Values.ingress.enabled -}}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
ingressClassName: {{ .Values.ingress.className }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{ }}
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "nodejs-api.fullname" . }}
labels:
{{- include "nodejs-api.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "nodejs-api.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: memory
{{ }}
{{ }}
{{}}
{{}}
{{- define "nodejs-api.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{}}
{{- define "nodejs-api.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{}}
{{- define "nodejs-api.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{}}
{{- define "nodejs-api.labels" -}}
helm.sh/chart: {{ include "nodejs-api.chart" . }}
{{ include "nodejs-api.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{}}
{{- define "nodejs-api.selectorLabels" -}}
app.kubernetes.io/name: {{ include "nodejs-api.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
Deployment Guide:
# Helm Chart Usage
## Installation
### Development:
```bash
helm install nodejs-api ./nodejs-api -f values-dev.yaml
Production:
helm install nodejs-api ./nodejs-api \
-f values-prod.yaml \
--set secrets.DATABASE_URL="postgresql://..." \
--set secrets.JWT_SECRET="..." \
--set secrets.API_KEY="..."
Upgrade
helm upgrade nodejs-api ./nodejs-api -f values-prod.yaml
Rollback
helm history nodejs-api
helm rollback nodejs-api
helm rollback nodejs-api 3
Verify Installation
helm list
helm status nodejs-api
kubectl get pods -l app.kubernetes.io/name=nodejs-api
Uninstall
helm uninstall nodejs-api
Pro Tips
Use values files for environments (values-{env}.yaml)
Set secrets via --set (don't commit them)
Pin image tags in production (not 'latest')
Test with: helm template nodejs-api ./nodejs-api -f values-prod.yaml
Validate with: helm lint ./nodejs-api