Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Options.Namespace takes priority over ChartSpec.Namespace #104

Open
elonsalfati opened this issue Jul 31, 2022 · 5 comments
Open

Options.Namespace takes priority over ChartSpec.Namespace #104

elonsalfati opened this issue Jul 31, 2022 · 5 comments

Comments

@elonsalfati
Copy link

My use case:
I have initialized a helm client, and I'm iterating through multiple charts and installing them one by one. Different charts go to different namespaces.

I've initialized the helm client like this:

        opt := &helmclient.KubeConfClientOptions{
            Options: &helmclient.Options{
                Namespace:        "default",
                RepositoryCache:  "/tmp/.helmcache",
                RepositoryConfig: "/tmp/.helmrepo",
                Debug:            true,
                Linting:          true,
                DebugLog: func(format string, v ...interface{}) {
                    fmt.Printf(format, v...)
                    fmt.Printf("\n")
                },
            },
            KubeContext: kubecontext,
            KubeConfig: kubeconfig,
        }

        // initialize helm client with the correct kube context
        helmClient, err := helmclient.NewClientFromKubeConf(opt, helmclient.Burst(100), helmclient.Timeout(time.Duration(time.Minute*15)))
        if err != nil {
            return err
        }

and my ChartSpec looks like:

    chartSpec := helmclient.ChartSpec{
        ReleaseName: m.Name,
        ChartName: m.HelmPackage,
        Version: "0.1.0",
        ValuesYaml: string(buf),
        DryRun: m.dryRun,
        Wait: false,
        Timeout: time.Duration(time.Minute*15),
        Namespace: m.Namespace,
        CreateNamespace: true
    }

I've set the ChartSpec.Namespace = "nopeus" and ChartSpec.CreateNamespace = true accordingly and ran InstallOrUpgradeChart with the chart.

Yet when I run this, the charts are deployed to the default namespace instead of the intended nopeus namespace. Which isn't a behavior I would expect.

I would love your help on this. Am I missing something? Is it a bug? Should I just create a new client every time (sounds weird)?

@g3kk0
Copy link

g3kk0 commented Nov 10, 2022

I too would like to know how best to handle this.

Should you create a new client each time you change namespace?

@drish
Copy link

drish commented May 26, 2023

👍 for this issue, having the same problem

@KaimingWan
Copy link

same issue here...

@Aniurm
Copy link

Aniurm commented Jul 13, 2023

I really hope that the problem reflected in this issue can be fixed as soon as possible

@nxtcoder17
Copy link
Contributor

just rolled into the same issue

nxtcoder17 added a commit to nxtcoder17/go-helm-client that referenced this issue Jul 28, 2023
…espaces

- fixes issue which caused helm charts to be applied to default
  namespace, even when a namespace has been specified in
  chartspec. read more at mittwald#104

- functionality wise, `actionConfig` and `clientGetter` are now lazily
  created with a namespace, prior to a chart being installed or updated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants