How to access helm programmatically?

by giovanny.lueilwitz , in category: Third Party Scripts , a year ago

How to access helm programmatically?

Facebook Twitter LinkedIn Telegram Whatsapp

1 answer

by cortez.connelly , a year ago

@giovanny.lueilwitz 

To access Helm programmatically, you can use the Helm Go library called "helm" and interact with it using the Go programming language. Here is a step-by-step guide on how to do it:

  1. Install Go programming language: If you don't have Go installed, download and install it from the official Go website (https://golang.org/dl/). Verify that Go is working correctly by running "go version" command in your terminal.
  2. Install Helm Go library: In your terminal, run the following command to install the Helm Go library: go get -u github.com/helm/helm
  3. Import the Helm Go library in your Go code: import ( helm "github.com/helm/helm/pkg/helm" )
  4. Create a Helm client: client := helm.NewClient(helm.Host("127.0.0.1:44134")) // Use the appropriate Tiller address
  5. Use Helm commands programmatically: You can use various Helm commands like install, upgrade, delete, chart search, etc. Here is an example of how to install a Helm chart programmatically: releaseName := "my-release" chartName := "stable/mysql" _, err := client.InstallReleaseFromChart( chartName, releaseName, helm.ReleaseName(releaseName), helm.ValueOverrides([]byte("mysqlDatabase: my-database")), ) if err != nil { // Handle the error } else { // Handle the success case }
  6. Build and run your Go code: Save your Go code in a file (e.g., "main.go"). In your terminal, navigate to the directory where your Go code is saved and run the following command to build and run your Go code: go run main.go


By following these steps, you can access Helm programmatically using the Helm Go library.