Create a Kubernetes Helm Chart with Best Practices and Customization
Generate a complete, production-ready Kubernetes Helm chart with deployment, autoscaling, ingress, probes, and security best practices.
๐ The Prompt
Generate a complete Kubernetes Helm chart for deploying [APPLICATION_NAME], a [APPLICATION_TYPE] (e.g., stateless web API, worker service, stateful database). The application runs on port [APP_PORT] and requires [RESOURCE_DEPENDENCIES] (e.g., PostgreSQL, Redis, S3).
**Chart Structure โ Generate all files:**
1. **Chart.yaml**: Set apiVersion v2, include dependencies for [SUBCHART_DEPENDENCIES] (e.g., bitnami/postgresql, bitnami/redis) with version pinning and condition toggles.
2. **values.yaml**: Provide a comprehensive, well-commented defaults file covering:
- Image repository, tag (default `latest`), and pull policy
- Replica count with HPA settings (min: [MIN_REPLICAS], max: [MAX_REPLICAS], CPU target: [CPU_TARGET]%)
- Resource requests/limits (CPU: [CPU_REQUEST]/[CPU_LIMIT], Memory: [MEM_REQUEST]/[MEM_LIMIT])
- Environment variables from ConfigMap and Secrets with `existingSecret` support
- Ingress configuration with TLS and [INGRESS_CLASS] annotation
- Pod disruption budget, topology spread constraints, and affinity rules
3. **templates/deployment.yaml**: Include liveness/readiness/startup probes hitting [HEALTH_ENDPOINT], security context (non-root, read-only filesystem), graceful shutdown with preStop hook, and init containers for [INIT_TASK] (e.g., DB migration, config loading).
4. **templates/service.yaml**: ClusterIP service with named ports.
5. **templates/ingress.yaml**: Conditional ingress with path-based routing.
6. **templates/hpa.yaml**: HorizontalPodAutoscaler with CPU and custom metrics.
7. **templates/configmap.yaml** and **templates/secret.yaml**: Externalized configuration.
8. **templates/_helpers.tpl**: Standard helper templates for name, fullname, labels, and selector labels.
9. **templates/NOTES.txt**: Post-install instructions showing how to access the application.
10. **templates/tests/test-connection.yaml**: Helm test that verifies the service is reachable.
Use `{{- include }}`, `{{- toYaml }}`, and proper indentation helpers throughout. Add comments explaining non-obvious template logic.
๐ก Tips for Better Results
Always specify your Kubernetes cluster version and ingress controller type (nginx, traefik, ALB) since annotation syntax varies significantly between them. Set explicit resource requests and limits in your prompt values โ the AI will structure them properly, and you avoid noisy-neighbor issues in production. Test the generated chart with `helm template . | kubectl apply --dry-run=client -f -` before deploying to catch rendering issues early.
๐ฏ Use Cases
Platform engineers and DevOps teams use this when packaging applications for Kubernetes deployment, ensuring consistency across environments and enabling teams to customize deployments through values overrides.