#helmfile (2024-05)

https://github.com/helmfile/helmfile

Questions and discussion around helmfile https://github.com/roboll/helmfile and https://github.com/cloudposse/helmfiles

Archive: https://archive.sweetops.com/helmfile/

2024-05-04

Jim avatar

@yxxhero Would I be able to collaborate with you here on my pull request to Helmfile rather than posting comments into the PR itself?

Jim avatar

The pull request in question is https://github.com/helmfile/helmfile/pull/1494

#1494 Add helmfile template --show-only

Add a --show-only parameter to the helmfile template command to pass on to the helm template command.

Jim avatar

You’ve asked me to write some tests. As stated in my early comment on the pull request, I am not a golang programmer. I’ve spend half of the day today (Sat) trying to learn enough go to be able to perform your request, but I still don’t have enough knowledge to know how to proceed.

Jim avatar

Do I just add something like this to the TestTemplate function in pkg/app/app_template_test.go

Jim avatar

OR am I supposed to do something in test/e2e/template/helmfile/tmpl_test.go instead? (or as well?)

Jim avatar

OR am I supposed to do something under test/integration/test-cases/ ?

Jim avatar

Also a question on my change itself. Did I need to add the showOnly stuff to the HelmSpec and ReleaseSpec structs in pkg/state/state.go? The HelmSpec struct is for the helmDefault values right? And the --show-only option for helmfile template wouldn’t be something you’d likely want to set in the helmDefault section I suspect. And the ReleaseSpec struct if for the release: section of helmfile.yaml right? So probably also an area where you wouldn’t set the new parameter. I suspect I should remove it from those places?

I also don’t know if the changes I did in pkg/app/app_test.go were necessary or not?

Jim avatar

And if I don’t need those vars in the structs, then I guess my change to pkg/state/helmx.go simply becomes the following instead?

yxxhero avatar
yxxhero

I will help you. Waiting for my commit. Study with each other. Thanks so much.

Jim avatar

Thanks.

Jim avatar

I’d like to attempt to work on this again tomorrow. To help me get started, can you please let me know where I should create my tests? I’m thinking it is in one of the following 3 locations? • In pkg/app/app_template_test.go ? • In test/e2e/template/helmfile/tmpl_test.go ? • Or in the test/integration/test-cases/ area?

Jim avatar

I’ve made changes to remove showOnly from the HelmSpec and ReleaseSpec structs in pkg/state/state.go that I had previously added as it doesn’t make sense to specify this flag against helmDefaults: nor releases: in helmfile.yaml. And likewise I’ve adjusted the change in pkg/state/helmx.go to cater for the above.

And I’ve added a test to pkg/app/app_template_test.go

Finally I rebased it against your upstream changes to the main branch, and squashed my changes together.

How’s that looking?

Jim avatar

I’ve installed golangci-lint on my system and fixed the lint error as well now.

Jim avatar

Hmm. The integration tests failed whereas last time they passed fine. Seems more like a pipeline issue this time rather than my change?

Jim avatar

I’ve pushed the change adding the other test that you asked for.

Jim avatar

Hi @yxxhero Is there likely to be another 0.x release of helmfile that could include this change before version 1.0 comes out? It would be nice to have a 0.165.0 (for example) release that has this new --show-only option while still supporting --arg so that I can get it out on my deployment agents without breaking pipelines before they’ve been converted from using --arg '--show-only BLAH' to the new --show-only BLAH option.

yxxhero avatar
yxxhero

Yeah. You are right.

Jim avatar

Thank you for the 0.165.0 release.

2024-05-08

2024-05-09

2024-05-10

William avatar
William

Is there a way to use the folder name that a helmfile is in as the namespace? Maybe using exec pwd or something in the helmfile?

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

It sounds like the directory might be being used the way environments are intended to be used. The exec could work, but I think it may be relative to the current working directory where helmfile is being executed and not the path of the helmfile. Also, since helmfiles can import other helmfiles, the knowing the path is a bit ambiguous.

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

We usually use things in the built-in object to determine the namespace

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

And have environments define the namespace

William avatar
William

This is pretty much exactly what I was thinking. Thank you for the input!

William avatar
William

The environment was what I was trying to use as the folder name. I have since looked at doing a helmfile per service as per the docs.

William avatar
William

Also, if I am trying to build a value template and I have a values.yml.gotmpl and a service1.yaml that will render the values based on the values template mentioned. The problem is that I cannot get it to use the service1.yaml as the .Values for the gotmpl. I have to put the service1.yaml into the environment default for it to work. Seems very strange I have to use the environment section at all.

2024-05-11

2024-05-12

2024-05-18

donovan734 avatar
donovan734

Hi, for the most part, all releases exist in all environments. Super simple. However, one cluster, call it x, has 10+ releases specific to the x environment. Is there a way to have all the x releases in a separate file and have it invoked when running helmfile -e x?

donovan734 avatar
donovan734

I’m just listing all releases in a single file which is a little verbose and using installedTemplate: {{ eq .Environment.Name "x" }} to specify which releases would go to x

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

Maybe conditionally add a helmfile for that release?

{{ if eq .Environment.Name "x" }}
helmfiles:
- nested/{{ .Environment.Name }}.yaml.gotmpl
{{ endif }}
Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

Then inside of x.yaml.gotmpl

releases:
  # Releases specific to environment 'x'
  - name: x-release-1
    namespace: x-namespace
    chart: x/chart-1

  - name: x-release-2
    namespace: x-namespace
    chart: x/chart-2 
# ... 10+ releases
donovan734 avatar
donovan734

Awesome. I forget it’s just go templating. Had a laugh at the 1.0 release notes covering that. Thank you!

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

2024-05-22

2024-05-24

morguldir avatar
morguldir

Are the replies in https://github.com/helmfile/helmfile/issues/277 still up to date? raw/incubator doesn’t seem to be a thing anymore, but i’d like to avoid switching to something argocd/flux, so would be great to have something included I just got strategicMergePatches working for existing resources at least, and it seems great so far

1
Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

You can also just clone the original raw chart and use it locally with helmfile

Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

The raw chart is very basic, not much going on, from what I recall. It was a clever hack.

morguldir avatar
morguldir

I think i can still use the deprecated chart, and i guess since the template is like 9 lines it doesn’t really hurt

1
Erik Osterman (Cloud Posse) avatar
Erik Osterman (Cloud Posse)

Agreed.

2024-05-25

2024-05-26

2024-05-30

Jason avatar

Hi has anyone been able to use the helm client to deploy a helm chart with GO? https://pkg.go.dev/github.com/mittwald/[email protected]

I’m trying to deploy an ingress-nginx chart no customization and it works when I use helm install even with a custom yaml file. But it doesn’t work with the GO helm client.

I get context deadline exceeded

client package - sigs.k8s.io/controller-runtime/pkg/client - Go Packages

Package client contains functionality for interacting with Kubernetes API servers.

yxxhero avatar
yxxhero

you can post an issue into project github address.

client package - sigs.k8s.io/controller-runtime/pkg/client - Go Packages

Package client contains functionality for interacting with Kubernetes API servers.

Jason avatar

I did do that after this post. Thank you

Jason avatar

As It does seem like an issue with the pkg

yxxhero avatar
yxxhero

show the issue link. pls

Jason avatar
#209 Can not deploy simple nginx-helm chart

I’m trying to deploy the ingress-nginx helm chart with no customizations, and I keep getting context deadline exceeded.

I can deploy this with helm install absolutely fine.

My code snippet:

	// Builds Helm Chart Client ////
	fmt.Println("Building Helm Client\n")
	opt := &helmclient.Options{
		Namespace:        "default", // Change this to the namespace you wish the client to operate in.
		RepositoryCache:  "/tmp/.helmcache",
		RepositoryConfig: "/tmp/.helmrepo",
		Debug:            false,
		Linting:          true,
		DebugLog:         func(format string, v ...interface{}) {},
		Output:           &outputBuffer, // Not mandatory, leave open for default os.Stdout
	}

	myHelmClient, err := helmclient.New(opt)
	if err != nil {
		panic(err)
	}

	/////////////////////////////////////////////////////////////////////////////////////////////////////
	//// Now use Helmchart client to create external-secrets chart repo //////
	fmt.Println("Deploying nginx-ingress\n")
	nginxchartRepo := repo.Entry{
		Name:               "ingress-nginx",
		URL:                "<https://kubernetes.github.io/ingress-nginx>",
		PassCredentialsAll: true,
	}

	if err := myHelmClient.AddOrUpdateChartRepo(nginxchartRepo); err != nil {
		log.Fatal(err)
	} else {
		fmt.Printf("Added Chart Repo %s\n", nginxchartRepo.Name)
	}

	// Now Run Update Chart Repos
	if err := myHelmClient.UpdateChartRepos(); err != nil {
		log.Fatal(err)
	} else {
		fmt.Printf("Updating Chart Repo\n")
	}

	///////////////////////////////////////////////////////////////////////////////////////////////////////
	// Now install the chart from the repo thats just been created./////////////////////
	nginxchartSpec := helmclient.ChartSpec{
		ReleaseName:     "nginx-ingress",
		ChartName:       "ingress-nginx/ingress-nginx",
		Namespace:       "nginx-ingress",
		CreateNamespace: true,
		SkipCRDs:        false,
		Wait:            true,
		//ValuesOptions: values.Options{
		//	ValueFiles: []string{"nginxvalues.yaml"},
		//},
	}
	nginxInstalledHelmChart, err := myHelmClient.InstallChart(ctx, &nginxchartSpec, nil)
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Status of Chart Install %v,\n", *nginxInstalledHelmChart.Info)
	

```

yxxhero avatar
yxxhero

IMO. you can try to use helm code. not go-helm-client.

2024-05-31

    keyboard_arrow_up