Get all resources created by a helm release using k8s rest API

1/27/2022

Is there a way I can get a list of all helm releases, and then all resources that have been created by this release, using the Kubernetes REST API?

I mean something similar to helm and kubectl commands

helm list

kubectl get all --all-namespaces -l=release-name

but using REST - https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.23/

-- Daria DomagaƂa
kubernetes
kubernetes-helm
rest

1 Answer

1/29/2022

Helm is built on top of the Kubernetes API layer, in that it creates objects like Deployments and Services and stores its state in Secrets; but a Helm release is not itself a Kubernetes object and you can't directly use the Kubernetes API to access it.

If your application is in Go, then Helm 3 includes a Go SDK, which essentially exposes most of the helm binary as Go-native library calls. This isn't a network-visible API, though, and if your application is in any other language you won't be able to integrate with it.

If instead it's more important to be able to manipulate your application using Kubernetes's REST API than to be using Helm proper, one alternative is to write a program (a Kubernetes controller) that interacts with the Kubernetes API, and have it be driven by a custom resource, a Kubernetes object that would include your application-specific configuration. This pair is commonly called an operator. Much more so than a Helm chart, though, this involves actually writing code and not just dropping in bits of Kubernetes YAML. (And, much more so than a Helm chart, you can unit-test more complex logic using your host language's native test tools.)

But in short, no, unless you can use the Helm Go SDK then there's not a good way to programmatically interact with a Helm chart beyond shelling out to the helm command.

-- David Maze
Source: StackOverflow