<p>I want to create a service on kubernetes which manages helm charts on the cluster. It installs charts from a private chart repository. Since I didn't find any documents on how to use helm client api, I was looking for some samples or guidelines for creating a service on top of helm client.</p>

<p><strong>FOR HELM3</strong></p>

<p>As other answers pointed, with Helm 2, you need to talk with tiller which complicates stuff.</p>

<p>It is way more clean with Helm 3 since tiller was removed and helm client directly communicates with Kubernetes API Server. </p>

<p>Here is an example code to install a helm chart programmatically with helm3:</p>

<pre><code>package main

import (
    "fmt"
    "os"

    "helm.sh/helm/v3/pkg/action"
    "helm.sh/helm/v3/pkg/chart/loader"
    "helm.sh/helm/v3/pkg/kube"
    _ "k8s.io/client-go/plugin/pkg/client/auth"
)

func main() {
    chartPath := "/tmp/my-chart-0.1.0.tgz"
    chart, err := loader.Load(chartPath)
    if err != nil {
        panic(err)
    }

    kubeconfigPath := "/tmp/my-kubeconfig"
    releaseName := "my-release"
    releaseNamespace := "default"
    actionConfig := new(action.Configuration)
    if err := actionConfig.Init(kube.GetConfig(kubeconfigPath, "", releaseNamespace), releaseNamespace, os.Getenv("HELM_DRIVER"), func(format string, v ...interface{}) {
        fmt.Sprintf(format, v)
    }); err != nil {
        panic(err)
    }

    iCli := action.NewInstall(actionConfig)
    iCli.Namespace = releaseNamespace
    iCli.ReleaseName = releaseName
    rel, err := iCli.Run(chart, nil)
    if err != nil {
        panic(err)
    }
    fmt.Println("Successfully installed release: ", rel.Name)
}
</code></pre>
