Kubernetes
Helm
Golang
Kubernetes Client
DevOps

Samples on kubernetes helm golang client

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

Introduction

If you want to manage Helm releases from Go, the usual answer is to use the Helm Go SDK rather than shelling out to the helm CLI. The SDK lets you list, install, upgrade, and uninstall releases programmatically while still using the same chart model as Helm itself. This article shows a minimal setup and a working sample for listing and installing releases.

The Main Packages You Need

The Helm SDK lives under the Helm project modules, especially the action package. A minimal program usually works with:

  • 'helm.sh/helm/v3/pkg/action'
  • 'helm.sh/helm/v3/pkg/cli'
  • 'helm.sh/helm/v3/pkg/chart/loader'
  • Kubernetes REST configuration support

Add the dependency in your Go module:

bash
go get helm.sh/helm/v3

The exact transitive Kubernetes packages will be pulled in automatically.

Initialize the Helm Action Configuration

Before performing actions, initialize action.Configuration. This is the object most Helm operations use internally.

go
1package main
2
3import (
4    "fmt"
5    "log"
6
7    "helm.sh/helm/v3/pkg/action"
8    "helm.sh/helm/v3/pkg/cli"
9)
10
11func main() {
12    settings := cli.New()
13    actionConfig := new(action.Configuration)
14
15    err := actionConfig.Init(
16        settings.RESTClientGetter(),
17        settings.Namespace(),
18        "secret",
19        log.Printf,
20    )
21    if err != nil {
22        panic(err)
23    }
24
25    fmt.Println("Helm action configuration initialized")
26}

The storage driver argument is often secret, though other drivers exist.

List Releases

Once initialized, listing releases is straightforward.

go
1package main
2
3import (
4    "fmt"
5    "log"
6
7    "helm.sh/helm/v3/pkg/action"
8    "helm.sh/helm/v3/pkg/cli"
9)
10
11func main() {
12    settings := cli.New()
13    cfg := new(action.Configuration)
14
15    if err := cfg.Init(settings.RESTClientGetter(), settings.Namespace(), "secret", log.Printf); err != nil {
16        panic(err)
17    }
18
19    listAction := action.NewList(cfg)
20    listAction.All = true
21
22    releases, err := listAction.Run()
23    if err != nil {
24        panic(err)
25    }
26
27    for _, rel := range releases {
28        fmt.Printf("%s	%s	%d
29", rel.Name, rel.Namespace, rel.Version)
30    }
31}

This is the simplest real sample for proving that your SDK setup is correct.

Install a Local Chart

To install a chart from disk, load it and run an install action.

go
1package main
2
3import (
4    "log"
5
6    "helm.sh/helm/v3/pkg/action"
7    "helm.sh/helm/v3/pkg/chart/loader"
8    "helm.sh/helm/v3/pkg/cli"
9)
10
11func main() {
12    settings := cli.New()
13    cfg := new(action.Configuration)
14
15    if err := cfg.Init(settings.RESTClientGetter(), settings.Namespace(), "secret", log.Printf); err != nil {
16        panic(err)
17    }
18
19    install := action.NewInstall(cfg)
20    install.ReleaseName = "demo-release"
21    install.Namespace = settings.Namespace()
22
23    chart, err := loader.Load("./charts/myapp")
24    if err != nil {
25        panic(err)
26    }
27
28    values := map[string]interface{}{
29        "replicaCount": 2,
30    }
31
32    _, err = install.Run(chart, values)
33    if err != nil {
34        panic(err)
35    }
36}

This example assumes the chart already exists locally and the target namespace is reachable through your current kubeconfig.

Kubeconfig and In-Cluster Behavior

The SDK usually uses the same Kubernetes access conventions as Helm itself. Locally, it often relies on your kubeconfig. Inside a cluster, you may need to ensure the program has in-cluster credentials and the service account permissions required to manage releases.

In practice, most early failures come from cluster authentication or RBAC, not from the Helm API usage itself.

When to Use the SDK Instead of the CLI

Use the Go SDK when:

  • you are building an operator or internal platform tool
  • release management is part of a larger Go service
  • you need programmatic control rather than shelling out

If you just need a few admin scripts, the Helm CLI may still be simpler and easier to maintain.

Watch Version Compatibility

Helm SDK usage is tied to Helm major versions. If your cluster tooling or charts assume Helm v3, make sure your Go dependency is also Helm v3. Mixing examples from different major versions is a common source of confusion.

The Kubernetes client version pulled in transitively can also influence behavior in stricter environments.

Common Pitfalls

  • Shelling out to helm when the real requirement is an embedded Go workflow.
  • Forgetting to initialize action.Configuration before constructing actions.
  • Blaming Helm SDK code when the actual problem is kubeconfig or RBAC.
  • Mixing Helm v2 examples with Helm v3 imports.
  • Assuming SDK-based release management removes the need to understand chart values and namespaces.

Summary

  • The Helm Go SDK is the standard way to manage Helm releases programmatically from Go.
  • Start by initializing action.Configuration with a valid Kubernetes client getter.
  • Use action.NewList for listing releases and action.NewInstall for installations.
  • Expect kubeconfig and RBAC issues to be the most common runtime blockers.
  • Choose the SDK only when you truly need embedded programmatic control rather than the Helm CLI.

Related reading
Course
Beginner
27 lessons
10 hours
System Design Fundamentals

Build a strong foundation in designing scalable, reliable distributed systems.

View the course
Track what you have practised

A free account saves your progress, solutions and study plan across every problem on Codemia.

System Design practice on Codemia

Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.

Practice system design

All Rights Reserved.