1

I have the following chartInflator.yml file:

apiVersion: builtin
kind: ChartInflator
metadata:
  name: project-helm-inflator
chartName: helm-k8s
chartHome: ../../../helm-k8s/
releaseName: project-monitoring-chart
values: ../../values.yaml
releaseNamespace: project-monitoring-ns

When I ran it using this, I got the error message below:

$ kustomize build .
Error: loading generator plugins: failed to load generator: plugin HelmChartInflationGenerator.builtin.[noGrp]/project-helm-inflator.[noNs] fails configuration: chart name cannot be empty

Here is my project structure:

project
  - helm-k8s
   - values.yml
   - Chart.yml
   - templates
    - base
      - project-namespace.yml
      - grafana
        - grafana-service.yml
        - grafana-deployment.yml
        - grafana-datasource-config.yml
      - prometheus
        - prometheus-service.yml
        - prometheus-deployment.yml
        - prometheus-config.yml
        - prometheus-roles.yml
      - kustomization.yml
    - prod
      - kustomization.yml
    - test
      - kustomization.yml
Jonas
  • 121,568
  • 97
  • 310
  • 388
joesan
  • 13,963
  • 27
  • 95
  • 232

1 Answers1

2

I think you may have found some outdated documentation for the helm chart generator. The canonical documentation for this is here. Reading that implies several changes:

  1. Include the inflator directly in your kustomization.yaml in the helmCharts section.

  2. Use name instead of chartName.

  3. Set chartHome in the helmGlobals section rather than per-chart.

That gets us something like this in our kustomization.yaml:

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

helmGlobals:
  chartHome: ../../../helm-k8s/

helmCharts:
- name: helm-k8s
  releaseName: project-monitoring-chart
  values: ../../values.yaml
  releaseNamespace: project-monitoring-ns

I don't know if this will actually work -- you haven't provided a reproducer in your question, and I'm not familiar enough with Helm to whip one up on the spot -- but I will note that your project layout is highly unusual. You appear to be trying to use Kustomize to deploy a Helm chart that contains your kustomize configuration, and it's not clear what the benefit is of this layout vs. just creating a helm chart and then using kustomize to inflate it from outside of the chart templates directory.

You may need to add --load-restrictor LoadRestrictionsNone when calling kustomize build for this to work; by default, the chartHome location must be contained by the same directory that contains your kustomization.yaml.


Update

To make sure things are clear, this is what I'm recommending:

  1. Remove the kustomize bits from your helm chart, so that it looks like this.

  2. Publish your helm charts somewhere. I've set up github pages for that repository and published the charts at http://oddbit.com/open-electrons-deployments/.

  3. Use kustomize to deploy the chart with transformations. Here we add a -prod suffix to all the resources:

    apiVersion: kustomize.config.k8s.io/v1beta1
    kind: Kustomization
    
    helmCharts:
      - name: open-electrons-monitoring
        repo: http://oddbit.com/open-electrons-deployments/
    
    nameSuffix: -prod
    
larsks
  • 277,717
  • 41
  • 399
  • 399
  • Here is the actual project: https://github.com/open-electrons/open-electrons-deployments/tree/master/open-electrons-monitoring – joesan Feb 04 '23 at 14:07
  • Like I said, the layout is odd. It's not entirely clear what you're trying to accomplish. If you're creating a helm chart...just create a helm chart. It doesn't look like you need kustomize for what you're doing. Someone might use kustomize to deploy your helm chart, perhaps applying some transformations, but you wouldn't use kustomize *inside* your helm chart. – larsks Feb 04 '23 at 14:42
  • I've updated the answer with a more explicit example. – larsks Feb 04 '23 at 15:12
  • I'll take a look into that, but one question remains with your approach which is if I could still overlay other values when I deploy the chart with transformations. I guess so or? – joesan Feb 04 '23 at 18:02
  • I'm not sure what you're asking. You can use Kustomize transformations -- including patches -- to modify values in the manifests produced by the helm chart. You **cannot** use template calls (`{{ .SomeValue }}`) in your kustomize files. – larsks Feb 04 '23 at 18:03
  • Patches is what I was looking for. So may be I have an idea on how to proceed. Thanks for the help! – joesan Feb 04 '23 at 18:09