helm mixes namespaces from kubeconfig file and actionConfig.Init funtion
- Dominant language
- Go
- Stars
- 30.2k
- Forks
- 7.8k
- Avg merge
- 20h 58m
- Merged PRs (30d)
- 36
Description
I'm developing a Golang application that uses Helm as a library. And I noticed the behavior that Helm ignores the client settings and uses the namespace that is specified in kubeconfig. Here is my function code:
```go
func (vc *HelmConn) DeleteHelmRelease(name, ns string) error {
actionConfig := new(action.Configuration)
if err := actionConfig.Init(vc.HelmConfig.RESTClientGetter(), ns, "", log.Printf); err != nil {
return err
}
client := action.NewUninstall(actionConfig)
client.Timeout = helmDeleteTimeout
client.DeletionPropagation = "background"
client.Wait = true
_, err := client.Run(name)
if err != nil {
return err
}
return nil
}
```
at the same time, even the namespace from kubeconfig is not fully used. Let's say namespace test1 is set in kubeconfig, and I pass namespace test2 to the function, the result will be:
* helm release (metadata) will be removed from namespace **test2**
* k8s resources will be removed from namespace **test1**
* post-install hooks will run in namespace **test1** , but `{{ .Release.Namespace }}` in hooks template will be **test2**.
Also in command line utility I managed to reproduce the same behavior.
1. Set namespace test1 in kubeconfig
2. run helm uninstall release_name
3. immediately change the namespace in kubeconfig to test2.
The result will be the same as described above.
Output of `helm version`:
```
version.BuildInfo{Version:"v3.14.4", GitCommit:"81c902a123462fd4052bc5e9aa9c513c4c8fc142", GitTreeState:"clean", GoVersion:"go1.22.2"}
```
Output of `kubectl version`:
```
Client Version: v1.30.1
Kustomize Version: v5.0.4-0.20230601165947-6ce0bf390ce3
Server Version: v1.23.16+k3s1
WARNING: version difference between client (1.30) and server (1.23) exceeds the supported minor version skew of +/-1
```
Contributor guide
Assessment
This issue has not been assessed yet.