Skip to content

What I Learned Online

coding

Kubernetes Helm for Beginners – Master Package Management Quickly

Kubernetes Helm for Beginners

Photo by Growtika on Unsplash

Turn a chaotic YAML jungle into tidy, reusable deployments


Why Helm matters right now

If you’ve ever stared at dozens of Deployment, Service, or ConfigMap files and wondered why your team keeps reinventing the wheel, you’re not alone. Kubernetes has made it trivial to run containers at scale, but the sheer volume of manifests can become a maintenance nightmare. Helm steps in as a package manager for Kubernetes—think “apt” or “npm” but for cluster resources.

Helm’s value shows up in three places:

  1. Reusability – A single chart can be versioned, shared, and installed anywhere.
  2. Consistency – Installations are declarative; the same values.yaml produces identical environments across dev, test, and prod.
  3. Automation – Helm integrates with CI/CD pipelines, making roll‑outs and rollbacks effortless.

For a newcomer, mastering Helm means cutting through boilerplate and focusing on business logic instead of plumbing details.


1. What is a Helm chart?

A Helm chart is a collection of files that describe a related set of Kubernetes resources:

File Purpose
Chart.yaml Metadata (name, version, description)
values.yaml Default configuration values
templates/ Go‑templated YAML manifests
charts/ Dependencies on other charts

The life cycle of a chart

  1. Create – Write templates and defaults.
  2. Package – Bundle into a .tgz archive with helm package.
  3. Publish – Push to a chart repository (e.g., ArtifactHub, GitHub Packages).
  4. Install/Upgrade – Deploy to a cluster with helm install or update with helm upgrade.

Because the templates use Go templating, you can inject variables from values.yaml, environment files, or command‑line overrides.


2. Installing Helm and setting up a test cluster

Before you start writing charts, get a working Helm client and a cluster to deploy into.

# Install Helm (macOS)
brew install helm

# Verify installation
helm version

# Create a local kind cluster for quick experiments
kind create cluster --name demo-cluster

Once the cluster is ready:

kubectl config use-context kind-demo-cluster

You’re now set to experiment with charts without touching production infrastructure.


3. Building your first chart from scratch

Let’s package a simple Nginx web server.

Step 1 – Scaffold the directory

helm create nginx-chart
cd nginx-chart

The create command generates all boilerplate files. Inspect them:

  • Chart.yaml: rename to nginx-chart.
  • values.yaml: customize container image and port.
  • templates/deployment.yaml: template for a Deployment.

Step 2 – Tweak the defaults

# values.yaml
replicaCount: 3

image:
  repository: nginx
  tag: "1.27"
  pullPolicy: IfNotPresent

service:
  type: ClusterIP
  port: 80

Now, when you install, Helm will spin up three Nginx pods listening on port 80.

Step 3 – Install the chart

helm install my-nginx ./nginx-chart
kubectl get pods -l app.kubernetes.io/name=nginx

You should see three running containers. Open a port‑forward to test:

kubectl port-forward svc/my-nginx 8080:80
curl http://localhost:8080

Step 4 – Upgrade with new values

Suppose you want to expose the service externally.

helm upgrade my-nginx ./nginx-chart --set service.type=LoadBalancer

Helm intelligently patches only what changed, keeping the rest of the deployment intact.


4. Packaging and sharing charts

Once a chart is stable, you’ll likely want to share it with teammates or open‑source communities.

Create a package

helm package .
# Produces nginx-chart-0.1.0.tgz

Publish to a public repo

ArtifactHub hosts many community charts. You can also set up a private Helm repository using GitHub Packages, ChartMuseum, or Harbor. The process generally involves:

  1. Upload the .tgz file.
  2. Update an index.yaml (Helm automatically generates this).
  3. Add the repo to your cluster:
helm repo add myrepo https://my.repo.url/
helm repo update

Versioning strategy

Follow semantic versioning (MAJOR.MINOR.PATCH). Increment PATCH for bug fixes, MINOR for backward‑compatible feature additions, and MAJOR for breaking changes. This discipline keeps consumers of your chart predictable.


5. Helm best practices for teams

Practice Why it matters
Use values files per environment Keeps production secrets out of values.yaml. Use --set-file or separate prod-values.yaml.
Leverage helmfile or Argo CD Declaratively manage releases across clusters.
Pin chart dependencies Avoid accidental upgrades that break your stack.
Run helm lint before publishing Catches template syntax errors early.
Keep templates DRY Use helpers (templates/_helpers.tpl) to avoid repetition.

Common pitfalls and how to avoid them

  • Indentation errors in YAML – Helm’s templating can mask an extra space, leading to a broken manifest. Run helm template . locally; it outputs the rendered YAML for quick inspection.
  • Hard‑coding secrets – Never store passwords in plain text within values.yaml. Use Kubernetes Secrets or external secret managers (e.g., Vault). Helm 3 supports --set-string for sensitive data, but consider templating with {{ .Values.secret | b64enc }} and decoding at runtime.
  • Over‑riding defaults unintentionally – When running helm install, use --dry-run --debug to see what values are actually applied.

6. Integrating Helm into CI/CD

A typical pipeline might look like:

  1. Build Docker image → push to registry.
  2. Update chart values (appVersion, image.tag) automatically via a script.
  3. Run helm lint and helm package.
  4. Deploy with helm upgrade --install.

Example GitHub Actions snippet:

- name: Helm Deploy
  run: |
    helm repo add myrepo https://my.repo.url/
    helm repo update
    helm upgrade --install myapp ./charts/myapp \
      --namespace prod \
      --set image.tag=${{ steps.build.outputs.image_tag }}

Automation removes manual errors and ensures that every deployment is reproducible.


7. When Helm isn’t the right tool

Helm shines for application bundles, but there are scenarios where raw manifests or other tools fit better:

  • Single‑resource deployments – A simple kubectl apply -f may be faster than packaging a chart.
  • Fine‑grained CI/CD control – Tools like Kustomize allow overlays and patches without the templating layer Helm adds.
  • Complex dependency graphs – Helm’s dependency management can become unwieldy for deeply nested charts. In such cases, consider separating concerns into multiple charts or using a dedicated operator.

Conclusion

Helm transforms Kubernetes from a configuration‑heavy playground into a manageable package ecosystem. By learning to write, version, and deploy charts, you gain:

  • Speed – Reuse ready‑made templates across environments.
  • Reliability – Declarative installs that are repeatable.
  • Collaboration – Share charts through registries, making onboarding smoother.

Start with the simple Nginx example, experiment locally, then iterate to production. Once you’re comfortable, explore more advanced topics like chart dependencies, hooks, and Helm operators. The path from “I have a single YAML file” to “I can deploy a complex stack in seconds” is just a few Helm commands away. Happy charting!

Frequently Asked Questions (FAQ)

What is the difference between helm install and helm upgrade?

helm install creates a new release from a chart, while helm upgrade updates an existing release with changes to the chart or values. The upgrade command patches only what has changed, preserving any custom resources that were manually modified.


How do I override default values when installing a Helm chart?

You can pass overrides on the command line using --set key=value, supply a custom values file with -f my-values.yaml, or combine both. These options merge into the chart’s defaults before rendering the templates.


Where can I host and share my own Helm charts securely?

Publicly, ArtifactHub is the most popular community repository. For private sharing, GitHub Packages, ChartMuseum, Harbor, or a self‑hosted Helm repo provide secure storage with authentication and role‑based access control.


Can Helm manage non‑Kubernetes resources (e.g., external databases)?

Helm itself only renders Kubernetes manifests, but you can include initContainers or use custom hooks to run scripts that provision external services. For complex external dependencies, consider using tools like Terraform alongside Helm for a full infrastructure stack.

Related Articles

0 0 votes
Article Rating
guest
0 Comments
Oldest
Newest Most Voted
Scroll to Top