Simplifying Kubernetes Deployments with Helm Charts

Chart Structure and Configuration

A Helm chart is a collection of files that describe a related set of Kubernetes resources. The core components include Chart.yaml, values.yaml, and template files under the templates/ directory.

Chart.yaml

This file defines metadata about the chart:

apiVersion: v1
name: k8sapp
version: 0.1.1
appVersion: "1.1"
description: A demo Helm chart for Kubernetes

Required fields include name, version, and apiVersion (always v1 for Helm 2/3 compatibility). Optional fields like kubeVersion, maintainers, and sources provide additional context.

values.yaml and Templates

The values.yaml file contains default configuration values:

replicaCount: 1
image:
  repository: ccr.ccs.tencentyun.com/magicodes/k8sapp
  tag: latest
  pullPolicy: Always

service:
  type: NodePort
  port: 80

resources:
  limits:
    cpu: "1"
    memory: 228Mi
  requests:
    cpu: 100m
    memory: 128Mi

ingress:
  enabled: false

These values are injected into Kubernetes manifests via Go templating. For example, a deployment.yaml template might reference them like this:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "k8sapp.fullname" . }}
spec:
  replicas: {{ .Values.replicaCount }}
  template:
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          resources:
{{ toYaml .Values.resources | indent 12 }}

Template functions like {{ .Release.Name }} provide built-in context such as release name, namespace, and revision number.

Managing Dependencies

Dependencies are declared in requirements.yaml (Helm 2) or directly in Chart.yaml (Helm 3):

dependencies:
  - name: mysql
    version: "8.0.0"
    repository: https://charts.bitnami.com/bitnami

Run helm dependency update to fetch dependencies into the charts/ directory.

Deploying a Sample Application

To deploy the chart:

  1. Add a chart repository (if using a remote registry):
helm repo add myrepo https://hub.tencentyun.com/charts/myrepo \
 --username USER --password PASS
  1. Install from local directory:
helm install my-release ./k8sapp
  1. Or install from remote repository:
helm repo update
helm install my-release myrepo/k8sapp --version 0.1.1

After deployment, a NodePort service exposes the application. Use kubectl get svc to find the assigned port and access via <NODE_IP>:<NODE_PORT>.

Essential Helm Commands

  • Upgrade a release: ``` helm upgrade my-release myrepo/k8sapp --set image.tag=v2
  • Rollback: ``` helm rollback my-release 1
  • List releases: ``` helm list
  • Delete a release: ``` helm uninstall my-release
  • Package a chart: ``` helm package ./k8sapp # outputs k8sapp-0.1.1.tgz
  • Fetch a chart: ``` helm pull myrepo/k8sapp --version 0.1.1
    
    

Helm simplifies application lifecycle management on Kubernetes by packaging configurations, enabling versioned deployments, and supporting parameterized customization through values and templates.

Tags: Helm kubernetes devops containerization GoTemplates

Posted on Tue, 19 May 2026 17:19:43 +0000 by llirik