Claude
Skills
Sign in
Back

helm

Included with Lifetime
$97 forever

# Helm Chart Quick Reference

General

What this skill does

# Helm Chart Quick Reference

**Version**: 1.0.0 | **Target Size**: <100KB | **Purpose**: Fast reference for Helm chart development and deployment

---

## Overview

Helm is a package manager for Kubernetes that simplifies application deployment through **charts** - pre-configured Kubernetes resource templates. This quick reference provides essential patterns for chart creation, templating, and deployment.

**When to Load This Skill**:
- Detected: `Chart.yaml`, `values.yaml`, `templates/` directory
- Manual: `--tools=helm` flag
- Use Case: Kubernetes application packaging and deployment

**Progressive Disclosure**:
- **This file (SKILL.md)**: Quick reference for immediate use
- **REFERENCE.md**: Comprehensive guide with advanced patterns and 10+ production examples

---

## Table of Contents

1. [Chart Structure](#chart-structure)
2. [Chart.yaml Configuration](#chartyaml-configuration)
3. [Template Syntax Quick Reference](#template-syntax-quick-reference)
4. [Values File Patterns](#values-file-patterns)
5. [Common Helm Commands](#common-helm-commands)
6. [Dependency Management](#dependency-management)
7. [Release Lifecycle](#release-lifecycle)
8. [Testing with Helm](#testing-with-helm)
9. [Security Best Practices](#security-best-practices)
10. [Quick Examples](#quick-examples)

---

## Chart Structure

Standard Helm chart directory layout:

```
mychart/
├── Chart.yaml          # Chart metadata (name, version, description)
├── values.yaml         # Default configuration values
├── charts/             # Chart dependencies (subcharts)
├── templates/          # Kubernetes manifest templates
│   ├── NOTES.txt       # Post-install usage notes
│   ├── _helpers.tpl    # Named templates (partials)
│   ├── deployment.yaml
│   ├── service.yaml
│   ├── ingress.yaml
│   ├── configmap.yaml
│   └── secret.yaml
├── .helmignore         # Files to exclude from packaging
└── README.md           # Chart documentation
```

**Key Concepts**:
- **Chart.yaml**: Defines chart metadata (name, version, dependencies)
- **values.yaml**: Default configuration values (can be overridden)
- **templates/**: Go templates that render to Kubernetes manifests
- **charts/**: Dependency charts (populated by `helm dependency update`)

---

## Chart.yaml Configuration

**Chart.yaml** defines chart metadata and dependencies:

```yaml
apiVersion: v2                    # Helm 3 uses v2
name: webapp                      # Chart name (DNS-compatible)
version: 1.2.3                    # Chart version (SemVer)
appVersion: "2.0.1"               # Application version
description: Production web application with autoscaling
type: application                 # application or library
keywords:
  - webapp
  - kubernetes
  - production
home: https://example.com
sources:
  - https://github.com/example/webapp
maintainers:
  - name: DevOps Team
    email: [email protected]
dependencies:
  - name: postgresql
    version: "12.1.0"
    repository: https://charts.bitnami.com/bitnami
    condition: postgresql.enabled  # Optional: conditional dependency
  - name: redis
    version: "17.3.0"
    repository: https://charts.bitnami.com/bitnami
    condition: redis.enabled
```

**Version Guidelines**:
- **Chart version**: Increment when chart templates/structure changes
- **appVersion**: Application/container image version (independent of chart version)
- Use [Semantic Versioning](https://semver.org/): MAJOR.MINOR.PATCH

**Dependency Types**:
- **Condition**: Enable/disable via values (`postgresql.enabled: true`)
- **Tags**: Group dependencies (`--set tags.database=false`)
- **Import-values**: Import child chart values into parent

---

## Template Syntax Quick Reference

Helm uses [Go templates](https://pkg.go.dev/text/template) with additional functions.

### Built-in Objects

```yaml
# Access values from values.yaml
{{ .Values.replicaCount }}
{{ .Values.image.repository }}
{{ .Values.service.port }}

# Release information
{{ .Release.Name }}           # Release name (helm install <name>)
{{ .Release.Namespace }}      # Kubernetes namespace
{{ .Release.IsInstall }}      # true if installing (not upgrading)
{{ .Release.IsUpgrade }}      # true if upgrading
{{ .Release.Revision }}       # Revision number

# Chart metadata (from Chart.yaml)
{{ .Chart.Name }}
{{ .Chart.Version }}
{{ .Chart.AppVersion }}

# Kubernetes cluster capabilities
{{ .Capabilities.APIVersions.Has "apps/v1" }}
{{ .Capabilities.KubeVersion.Major }}
{{ .Capabilities.KubeVersion.Minor }}

# Template context
{{ .Template.Name }}          # Current template file name
{{ .Template.BasePath }}      # Template directory path
```

### Control Structures

```yaml
# If/Else conditionals
{{- if .Values.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
# ... ingress spec
{{- end }}

# If/Else with multiple conditions
{{- if and .Values.persistence.enabled (not .Values.persistence.existingClaim) }}
# Create new PVC
{{- else if .Values.persistence.existingClaim }}
# Use existing PVC
{{- else }}
# Use emptyDir
{{- end }}

# Range (loops)
{{- range .Values.extraEnv }}
- name: {{ .name }}
  value: {{ .value | quote }}
{{- end }}

# Range with key-value pairs
{{- range $key, $value := .Values.config }}
{{ $key }}: {{ $value | quote }}
{{- end }}

# With (scope modification)
{{- with .Values.nodeSelector }}
nodeSelector:
  {{- toYaml . | nindent 2 }}
{{- end }}
```

### Template Functions

**String Functions**:
```yaml
{{ .Values.name | quote }}              # "webapp"
{{ .Values.name | upper }}              # WEBAPP
{{ .Values.name | lower }}              # webapp
{{ .Values.name | title }}              # Webapp
{{ .Values.name | trim }}               # Remove whitespace
{{ .Values.name | trunc 10 }}           # Truncate to 10 chars
{{ .Values.name | default "default" }}  # Default if empty
```

**Type Conversion**:
```yaml
{{ .Values.port | toString }}           # Convert to string
{{ .Values.replicas | int }}            # Convert to integer
{{ .Values.enabled | ternary "yes" "no" }}  # Conditional value
```

**Encoding**:
```yaml
{{ .Values.config | b64enc }}           # Base64 encode
{{ .Values.secret | b64dec }}           # Base64 decode
{{ .Values.data | toJson }}             # Convert to JSON
{{ .Values.data | toYaml }}             # Convert to YAML
```

**Lists and Dictionaries**:
```yaml
{{ .Values.list | first }}              # First element
{{ .Values.list | rest }}               # All but first
{{ .Values.list | last }}               # Last element
{{ .Values.list | has "item" }}         # Check if contains
{{ .Values.dict | keys }}               # Dictionary keys
{{ .Values.dict | values }}             # Dictionary values
```

**Kubernetes-Specific**:
```yaml
{{ include "mychart.labels" . | nindent 4 }}  # Include named template with indent
{{ .Values.resources | toYaml | nindent 8 }}  # Convert resources to YAML
{{ .Release.Name | trunc 63 | trimSuffix "-" }}  # DNS-safe name (≤63 chars)
```

### Named Templates (Helpers)

**Define in templates/_helpers.tpl**:
```yaml
{{/*
Expand the name of the chart.
*/}}
{{- define "mychart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a fully qualified app name.
*/}}
{{- define "mychart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}

{{/*
Common labels
*/}}
{{- define "mychart.labels" -}}
helm.sh/chart: {{ include "mychart.chart" . }}
{{ include "mychart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "mychart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "mychart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
```
Files: 2
Size: 64.3 KB
Complexity: 33/100
Category: General

Related in General