$npx -y skills add BagelHole/DevOps-Security-Agent-Skills --skill helm-chartsCreate, manage, and deploy Helm charts for Kubernetes package management. Build reusable chart templates, manage releases, configure values, and use Helm repositories. Use when packaging Kubernetes applications or managing K8s deployments with Helm.
| 1 | # Helm Charts |
| 2 | |
| 3 | Package and deploy Kubernetes applications using Helm, the package manager for Kubernetes. |
| 4 | |
| 5 | ## When to Use This Skill |
| 6 | |
| 7 | Use this skill when: |
| 8 | - Creating reusable Kubernetes application packages |
| 9 | - Deploying applications with configurable values |
| 10 | - Managing Helm releases and upgrades |
| 11 | - Using third-party Helm charts |
| 12 | - Implementing chart versioning and repositories |
| 13 | |
| 14 | ## Prerequisites |
| 15 | |
| 16 | - Helm 3.x installed |
| 17 | - kubectl configured with cluster access |
| 18 | - Basic Kubernetes knowledge |
| 19 | |
| 20 | ## Chart Structure |
| 21 | |
| 22 | ``` |
| 23 | mychart/ |
| 24 | ├── Chart.yaml # Chart metadata |
| 25 | ├── values.yaml # Default configuration values |
| 26 | ├── charts/ # Chart dependencies |
| 27 | ├── templates/ # Kubernetes manifest templates |
| 28 | │ ├── deployment.yaml |
| 29 | │ ├── service.yaml |
| 30 | │ ├── ingress.yaml |
| 31 | │ ├── configmap.yaml |
| 32 | │ ├── secret.yaml |
| 33 | │ ├── _helpers.tpl # Template helpers |
| 34 | │ ├── NOTES.txt # Post-install notes |
| 35 | │ └── tests/ |
| 36 | │ └── test-connection.yaml |
| 37 | └── .helmignore # Files to ignore |
| 38 | ``` |
| 39 | |
| 40 | ## Chart.yaml |
| 41 | |
| 42 | ```yaml |
| 43 | apiVersion: v2 |
| 44 | name: myapp |
| 45 | description: A Helm chart for MyApp |
| 46 | type: application |
| 47 | version: 1.0.0 |
| 48 | appVersion: "2.0.0" |
| 49 | keywords: |
| 50 | - myapp |
| 51 | - web |
| 52 | maintainers: |
| 53 | - name: DevOps Team |
| 54 | email: devops@example.com |
| 55 | dependencies: |
| 56 | - name: postgresql |
| 57 | version: "12.x.x" |
| 58 | repository: "https://charts.bitnami.com/bitnami" |
| 59 | condition: postgresql.enabled |
| 60 | ``` |
| 61 | |
| 62 | ## values.yaml |
| 63 | |
| 64 | ```yaml |
| 65 | replicaCount: 2 |
| 66 | |
| 67 | image: |
| 68 | repository: myapp |
| 69 | tag: "" # Defaults to appVersion |
| 70 | pullPolicy: IfNotPresent |
| 71 | |
| 72 | service: |
| 73 | type: ClusterIP |
| 74 | port: 80 |
| 75 | |
| 76 | ingress: |
| 77 | enabled: false |
| 78 | className: nginx |
| 79 | hosts: |
| 80 | - host: myapp.example.com |
| 81 | paths: |
| 82 | - path: / |
| 83 | pathType: Prefix |
| 84 | tls: [] |
| 85 | |
| 86 | resources: |
| 87 | limits: |
| 88 | cpu: 500m |
| 89 | memory: 256Mi |
| 90 | requests: |
| 91 | cpu: 100m |
| 92 | memory: 128Mi |
| 93 | |
| 94 | postgresql: |
| 95 | enabled: true |
| 96 | auth: |
| 97 | database: myapp |
| 98 | ``` |
| 99 | |
| 100 | ## Templates |
| 101 | |
| 102 | ### Deployment Template |
| 103 | |
| 104 | ```yaml |
| 105 | # templates/deployment.yaml |
| 106 | apiVersion: apps/v1 |
| 107 | kind: Deployment |
| 108 | metadata: |
| 109 | name: {{ include "myapp.fullname" . }} |
| 110 | labels: |
| 111 | {{- include "myapp.labels" . | nindent 4 }} |
| 112 | spec: |
| 113 | replicas: {{ .Values.replicaCount }} |
| 114 | selector: |
| 115 | matchLabels: |
| 116 | {{- include "myapp.selectorLabels" . | nindent 6 }} |
| 117 | template: |
| 118 | metadata: |
| 119 | labels: |
| 120 | {{- include "myapp.selectorLabels" . | nindent 8 }} |
| 121 | spec: |
| 122 | containers: |
| 123 | - name: {{ .Chart.Name }} |
| 124 | image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" |
| 125 | imagePullPolicy: {{ .Values.image.pullPolicy }} |
| 126 | ports: |
| 127 | - name: http |
| 128 | containerPort: 8080 |
| 129 | {{- with .Values.resources }} |
| 130 | resources: |
| 131 | {{- toYaml . | nindent 12 }} |
| 132 | {{- end }} |
| 133 | env: |
| 134 | - name: DATABASE_URL |
| 135 | valueFrom: |
| 136 | secretKeyRef: |
| 137 | name: {{ include "myapp.fullname" . }}-secrets |
| 138 | key: database-url |
| 139 | ``` |
| 140 | |
| 141 | ### Helper Functions |
| 142 | |
| 143 | ```yaml |
| 144 | # templates/_helpers.tpl |
| 145 | {{/* |
| 146 | Expand the name of the chart. |
| 147 | */}} |
| 148 | {{- define "myapp.name" -}} |
| 149 | {{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} |
| 150 | {{- end }} |
| 151 | |
| 152 | {{/* |
| 153 | Create a default fully qualified app name. |
| 154 | */}} |
| 155 | {{- define "myapp.fullname" -}} |
| 156 | {{- if .Values.fullnameOverride }} |
| 157 | {{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} |
| 158 | {{- else }} |
| 159 | {{- $name := default .Chart.Name .Values.nameOverride }} |
| 160 | {{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} |
| 161 | {{- end }} |
| 162 | {{- end }} |
| 163 | |
| 164 | {{/* |
| 165 | Common labels |
| 166 | */}} |
| 167 | {{- define "myapp.labels" -}} |
| 168 | helm.sh/chart: {{ .Chart.Name }}-{{ .Chart.Version }} |
| 169 | {{ include "myapp.selectorLabels" . }} |
| 170 | app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} |
| 171 | app.kubernetes.io/managed-by: {{ .Release.Service }} |
| 172 | {{- end }} |
| 173 | |
| 174 | {{/* |
| 175 | Selector labels |
| 176 | */}} |
| 177 | {{- define "myapp.selectorLabels" -}} |
| 178 | app.kubernetes.io/name: {{ include "myapp.name" . }} |
| 179 | app.kubernetes.io/instance: {{ .Release.Name }} |
| 180 | {{- end }} |
| 181 | ``` |
| 182 | |
| 183 | ### Conditional Resources |
| 184 | |
| 185 | ```yaml |
| 186 | # templates/ingress.yaml |
| 187 | {{- if .Values.ingress.enabled -}} |
| 188 | apiVersion: networking.k8s.io/v1 |
| 189 | kind: Ingress |
| 190 | metadata: |
| 191 | name: {{ include "myapp.fullname" . }} |
| 192 | labels: |
| 193 | {{- include "myapp.labels" . | nindent 4 }} |
| 194 | {{- with .Values.ingress.annotations }} |
| 195 | annotations: |
| 196 | {{- toYaml . | nindent 4 }} |
| 197 | {{- end }} |
| 198 | spec: |
| 199 | ingressClassName: {{ .Values.ingress.className }} |
| 200 | {{- if .Values.ingress.tls }} |
| 201 | tls: |
| 202 | {{- range .Values.ingress.tls }} |
| 203 | - hosts: |
| 204 | {{- range .hosts }} |
| 205 | - {{ . | quote }} |
| 206 | {{- end }} |
| 207 | secretName: {{ .secretName }} |
| 208 | {{- end }} |
| 209 | {{- end }} |
| 210 | rules: |
| 211 | {{- range .Values.ingress.hosts }} |