$npx -y skills add mjunaidca/mjs-agent-skills --skill helm-chartsCreates and manages Helm charts for Kubernetes deployments. This skill should be used when packaging applications for Kubernetes using Helm, creating Chart.yaml, values.yaml, and templates. It covers chart structure, templating, dependencies, and deployment patterns. Use this ski
| 1 | # Helm Charts Skill |
| 2 | |
| 3 | ## Overview |
| 4 | |
| 5 | Helm is the package manager for Kubernetes. It packages Kubernetes manifests into reusable **charts** that can be versioned, shared, and deployed with customizable values. |
| 6 | |
| 7 | ## Core Concepts |
| 8 | |
| 9 | ### What is a Helm Chart? |
| 10 | |
| 11 | A chart is a collection of files that describe a related set of Kubernetes resources: |
| 12 | |
| 13 | ``` |
| 14 | mychart/ |
| 15 | ├── Chart.yaml # Chart metadata (name, version, dependencies) |
| 16 | ├── values.yaml # Default configuration values |
| 17 | ├── charts/ # Dependency charts |
| 18 | ├── templates/ # Kubernetes manifest templates |
| 19 | │ ├── deployment.yaml |
| 20 | │ ├── service.yaml |
| 21 | │ ├── ingress.yaml |
| 22 | │ ├── configmap.yaml |
| 23 | │ ├── secret.yaml |
| 24 | │ ├── _helpers.tpl # Template helpers |
| 25 | │ └── NOTES.txt # Post-install notes |
| 26 | └── .helmignore # Files to ignore when packaging |
| 27 | ``` |
| 28 | |
| 29 | ### Key Files |
| 30 | |
| 31 | | File | Purpose | |
| 32 | |------|---------| |
| 33 | | `Chart.yaml` | Metadata: name, version, appVersion, dependencies | |
| 34 | | `values.yaml` | Default configuration values (overridable) | |
| 35 | | `templates/` | Go-templated Kubernetes manifests | |
| 36 | | `_helpers.tpl` | Reusable template snippets | |
| 37 | |
| 38 | ## Chart.yaml Structure |
| 39 | |
| 40 | ```yaml |
| 41 | apiVersion: v2 # Helm 3 uses v2 |
| 42 | name: taskflow # Chart name |
| 43 | description: TaskFlow Platform # Short description |
| 44 | type: application # application or library |
| 45 | version: 1.0.0 # Chart version (SemVer) |
| 46 | appVersion: "1.0.0" # Application version |
| 47 | |
| 48 | # Dependencies (optional) |
| 49 | dependencies: |
| 50 | - name: postgresql |
| 51 | version: "12.x.x" |
| 52 | repository: "https://charts.bitnami.com/bitnami" |
| 53 | condition: postgresql.enabled |
| 54 | ``` |
| 55 | |
| 56 | ## values.yaml Pattern |
| 57 | |
| 58 | ```yaml |
| 59 | # Global settings |
| 60 | global: |
| 61 | imageRegistry: "" |
| 62 | imagePullSecrets: [] |
| 63 | |
| 64 | # Per-service configuration |
| 65 | api: |
| 66 | replicaCount: 1 |
| 67 | image: |
| 68 | repository: taskflow/api |
| 69 | tag: "latest" |
| 70 | pullPolicy: IfNotPresent |
| 71 | service: |
| 72 | type: ClusterIP |
| 73 | port: 8000 |
| 74 | resources: |
| 75 | limits: |
| 76 | cpu: 500m |
| 77 | memory: 512Mi |
| 78 | requests: |
| 79 | cpu: 100m |
| 80 | memory: 128Mi |
| 81 | env: |
| 82 | DATABASE_URL: "" |
| 83 | SSO_URL: "http://sso:3001" |
| 84 | |
| 85 | # Feature flags |
| 86 | postgresql: |
| 87 | enabled: true |
| 88 | auth: |
| 89 | postgresPassword: "postgres" |
| 90 | database: "taskflow" |
| 91 | ``` |
| 92 | |
| 93 | ## Template Syntax |
| 94 | |
| 95 | ### Accessing Values |
| 96 | |
| 97 | ```yaml |
| 98 | # templates/deployment.yaml |
| 99 | apiVersion: apps/v1 |
| 100 | kind: Deployment |
| 101 | metadata: |
| 102 | name: {{ include "taskflow.fullname" . }} |
| 103 | labels: |
| 104 | {{- include "taskflow.labels" . | nindent 4 }} |
| 105 | spec: |
| 106 | replicas: {{ .Values.api.replicaCount }} |
| 107 | selector: |
| 108 | matchLabels: |
| 109 | {{- include "taskflow.selectorLabels" . | nindent 6 }} |
| 110 | template: |
| 111 | spec: |
| 112 | containers: |
| 113 | - name: {{ .Chart.Name }} |
| 114 | image: "{{ .Values.api.image.repository }}:{{ .Values.api.image.tag }}" |
| 115 | ports: |
| 116 | - containerPort: {{ .Values.api.service.port }} |
| 117 | env: |
| 118 | - name: DATABASE_URL |
| 119 | value: {{ .Values.api.env.DATABASE_URL | quote }} |
| 120 | ``` |
| 121 | |
| 122 | ### Helper Templates (_helpers.tpl) |
| 123 | |
| 124 | ```yaml |
| 125 | {{/* |
| 126 | Expand the name of the chart. |
| 127 | */}} |
| 128 | {{- define "taskflow.name" -}} |
| 129 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 130 | {{- end }} |
| 131 | |
| 132 | {{/* |
| 133 | Create a default fully qualified app name. |
| 134 | */}} |
| 135 | {{- define "taskflow.fullname" -}} |
| 136 | {{- if .Values.fullnameOverride }} |
| 137 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 138 | {{- else }} |
| 139 | {{- $name := default .Chart.Name .Values.nameOverride }} |
| 140 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 141 | {{- end }} |
| 142 | {{- end }} |
| 143 | |
| 144 | {{/* |
| 145 | Common labels |
| 146 | */}} |
| 147 | {{- define "taskflow.labels" -}} |
| 148 | helm.sh/chart: {{ include "taskflow.chart" . }} |
| 149 | {{ include "taskflow.selectorLabels" . }} |
| 150 | app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 151 | {{- end }} |
| 152 | |
| 153 | {{/* |
| 154 | Selector labels |
| 155 | */}} |
| 156 | {{- define "taskflow.selectorLabels" -}} |
| 157 | app.kubernetes.io/name: {{ include "taskflow.name" . }} |
| 158 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 159 | {{- end }} |
| 160 | ``` |
| 161 | |
| 162 | ## Essential Commands |
| 163 | |
| 164 | ### Create New Chart |
| 165 | ```bash |
| 166 | helm create mychart |
| 167 | ``` |
| 168 | |
| 169 | ### Install Chart |
| 170 | ```bash |
| 171 | # From local directory |
| 172 | helm install my-release ./mychart |
| 173 | |
| 174 | # With custom values file |
| 175 | helm install my-release ./mychart --values custom-values.yaml |
| 176 | |
| 177 | # With inline value overrides |
| 178 | helm install my-release ./mychart \ |
| 179 | --set api.replicaCount=3 \ |
| 180 | --set api.image.tag=v2.0.0 |
| 181 | |
| 182 | # To specific namespace (create if needed) |
| 183 | helm install my-release ./mychart \ |
| 184 | --namespace production \ |
| 185 | --create-namespace |
| 186 | |
| 187 | # Dry run (preview without installing) |
| 188 | helm install my-release ./mychart --dry-run --debug |
| 189 | ``` |
| 190 | |
| 191 | ### Upgrade Release |
| 192 | ```bash |
| 193 | helm upgrade my-release ./mychart --values new-values.yaml |
| 194 | ``` |
| 195 | |
| 196 | ### Rollback |
| 197 | ```bash |
| 198 | helm rollback my-release 1 # R |