Get the FREE Ultimate OpenClaw Setup Guide →

helm-generator

Scanned
npx machina-cli add skill pantheon-org/tekhne/generator --openclaw
Files (1)
SKILL.md
8.0 KB

Helm Chart Generator

Overview

Generate production-ready Helm charts with best practices built-in. Create complete charts or individual resources with standard helpers, proper templating, and automatic validation.

Official Documentation:

When to Use This Skill

Use for creating/generating Helm charts and templates. For validation/linting of existing charts use devops-skills:helm-validator; for raw K8s YAML (no Helm) use k8s-generator.

Chart Generation Workflow

Stage 1: Understand Requirements

REQUIRED: Use AskUserQuestion if any of these are missing or ambiguous:

Missing InformationQuestion to Ask
Image repository/tag"What container image should be used? (e.g., nginx:1.25)"
Service port"What port does the application listen on?"
Resource limits"What CPU/memory limits should be set? (e.g., 500m CPU, 512Mi memory)"
Probe endpoints"What health check endpoints does the app expose? (e.g., /health, /ready)"
Scaling requirements"Should autoscaling be enabled? If yes, min/max replicas and target CPU%?"
Workload type"What workload type: Deployment, StatefulSet, or DaemonSet?"
Storage requirements"Does the application need persistent storage? Size and access mode?"

Do NOT assume values for critical settings. Ask first, then proceed.

Stage 2: CRD Documentation Lookup

If custom resources are needed:

  1. Try context7 MCP first:

    mcp__context7__resolve-library-id with operator name
    mcp__context7__get-library-docs with topic for CRD kind
    
  2. Fallback to WebSearch:

    "<operator>" "<CRD-kind>" "<version>" kubernetes documentation spec
    

See references/crd_patterns.md for common CRD examples.

Stage 3: Create Chart Structure

Use the scaffolding script:

bash scripts/generate_chart_structure.sh <chart-name> <output-directory> [options]

Script options:

  • --image <repo> - Image repository (default: nginx). Note: Pass only the repository name without tag (e.g., redis not redis:7-alpine)
  • --port <number> - Service port (default: 80)
  • --type <type> - Workload type: deployment, statefulset, daemonset (default: deployment)
  • --with-templates - Generate resource templates (deployment.yaml, service.yaml, etc.)
  • --with-ingress - Include ingress template
  • --with-hpa - Include HPA template
  • --force - Overwrite existing chart without prompting

Important customization notes:

  • The script uses http as the default port name in templates. Customize port names for non-HTTP services (e.g., redis, mysql, grpc)
  • Templates include checksum annotations for ConfigMap/Secret changes (conditionally enabled via .Values.configMap.enabled and .Values.secret.enabled)

Stage 4: Generate Standard Helpers

Use the helpers script or assets/_helpers-template.tpl:

bash scripts/generate_standard_helpers.sh <chart-name> <chart-directory>

Stage 5: Generate Templates

⚠️ CRITICAL REQUIREMENT: Read Reference Files NOW

You MUST use the Read tool to load these reference files at this stage, even if you read them earlier in the conversation:

1. Read references/resource_templates.md - for the specific resource type patterns
2. Read references/helm_template_functions.md - for template function usage
3. Read references/crd_patterns.md - if generating CRD resources (ServiceMonitor, Certificate, etc.)

Why: Prior context may be incomplete or summarized. Reading reference files at generation time guarantees all patterns, functions, and examples are available for accurate template creation.

Do NOT skip this step. Template quality depends on having current reference patterns loaded.

Reference templates for all resource types in references/resource_templates.md:

  • Workloads: Deployment, StatefulSet, DaemonSet, Job, CronJob
  • Services: Service, Ingress
  • Config: ConfigMap, Secret
  • RBAC: ServiceAccount, Role, RoleBinding, ClusterRole, ClusterRoleBinding
  • Network: NetworkPolicy
  • Autoscaling: HPA, PodDisruptionBudget

Key patterns (MUST include in all templates):

# Use helpers for names and labels
metadata:
  name: {{ include "mychart.fullname" . }}
  labels: {{- include "mychart.labels" . | nindent 4 }}

# Conditional sections with 'with'
{{- with .Values.nodeSelector }}
nodeSelector: {{- toYaml . | nindent 2 }}
{{- end }}

# Checksum annotation (REQUIRED for Deployments/StatefulSets/DaemonSets to trigger restarts on config changes)
annotations:
  checksum/config: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }}

Stage 6: Create values.yaml

Structure guidelines:

  • Group related settings logically
  • Document every value with # -- comments
  • Provide sensible defaults
  • Include security contexts, resource limits, probes

See assets/values-schema-template.json for JSON Schema validation.

Stage 7: Validate

Run validation using devops-skills:helm-validator skill (helm lint, template render, schema checks, dry-run).

Template Functions Quick Reference

See references/helm_template_functions.md for complete guide.

FunctionPurposeExample
requiredEnforce required values{{ required "msg" .Values.x }}
defaultFallback value{{ .Values.x | default 1 }}
quoteQuote strings{{ .Values.x | quote }}
includeUse helpers{{ include "name" . | nindent 4 }}
toYamlConvert to YAML{{ toYaml .Values.x | nindent 2 }}
tplRender as template{{ tpl .Values.config . }}
nindentNewline + indent{{- include "x" . | nindent 4 }}

Working with CRDs

See references/crd_patterns.md for complete examples. Ship CRDs in crds/ directory (not templated); template CR instances in templates/.

Converting Manifests to Helm

  1. Parameterize names (use helpers) and extract values
  2. Apply label/conditional patterns, use toYaml for complex objects
  3. Create _helpers.tpl with standard helpers
  4. Validate with devops-skills:helm-validator

Error Handling

IssueSolution
Template syntax errorsCheck {{- / -}} matching, use helm template --debug
Undefined valuesUse default or required functions
Indentation issuesUse nindent consistently
CRD validation failsVerify apiVersion, check docs for required fields

Resources

Scripts

ScriptUsage
scripts/generate_chart_structure.shbash <script> <chart-name> <output-dir>
scripts/generate_standard_helpers.shbash <script> <chart-name> <chart-dir>

References

FileContent
references/helm_template_functions.mdComplete template function guide
references/resource_templates.mdAll K8s resource templates
references/crd_patterns.mdCRD patterns (cert-manager, Prometheus, Istio, ArgoCD)

Assets

FilePurpose
assets/_helpers-template.tplStandard helpers template
assets/values-schema-template.jsonJSON Schema for values validation

Post-Generation Validation

After generating charts, invoke devops-skills:helm-validator to ensure quality.

Source

git clone https://github.com/pantheon-org/tekhne/blob/main/skills/ci-cd/helm/generator/SKILL.mdView on GitHub

Overview

Generates production-ready Helm charts with best practices built-in. Create complete charts or individual resources, with standard templating, helpers, and automatic validation.

How This Skill Works

It follows a staged workflow: understand requirements, scaffold the chart with the provided script, then generate standard helpers and templates. The process supports configurable options like image, port, workload type, and optional ingress or HPA, while aligning with Helm’s chart best practices.

When to Use It

  • Starting a new Helm chart from scratch
  • Scaffolding deployment, service, and ingress templates
  • Including helpers, values.yaml, and Chart.yaml during generation
  • Adding optional features like ingress or HPA
  • Building a complete Helm project with best-practices from scratch

Quick Start

  1. Step 1: bash scripts/generate_chart_structure.sh <chart-name> <output-directory> [options]
  2. Step 2: bash scripts/generate_standard_helpers.sh <chart-name> <chart-directory>
  3. Step 3: Validate (helm lint) and package (helm package) the chart; customize values.yaml as needed

Best Practices

  • AskUserQuestion for missing critical values before proceeding
  • Use the scaffold script with explicit options (--image, --port, --type, --with-templates, --with-ingress, --with-hpa)
  • Customize port names for non-HTTP services
  • Generate and reuse standard helpers (assets/_helpers-template.tpl)
  • Validate and lint the generated charts against Helm docs and chart best practices

Example Use Cases

  • Scaffold a deployment-based chart for a web app using nginx with deployment and service templates
  • Create a Redis chart with a non-HTTP port and custom port naming
  • Build a MySQL chart with persistent storage and service
  • Generate a chart including ingress, HPA, and template helpers
  • Assemble a full Helm project from scratch for a microservice architecture

Frequently Asked Questions

Add this skill to your agents
Sponsor this space

Reach thousands of developers