Skip to content
This repository was archived by the owner on Nov 17, 2021. It is now read-only.

Support for HELM charts #267

Open
pja-kit opened this issue Sep 26, 2019 · 1 comment
Open

Support for HELM charts #267

pja-kit opened this issue Sep 26, 2019 · 1 comment

Comments

@pja-kit
Copy link

pja-kit commented Sep 26, 2019

KSonnet had an std.native function:
renderHelmChart
A similar thing can be achieved by using a workaround, by doing a
helm template ...
And importing the resulting YAML by using
kubecfg.parseYaml

However by doing this the configuration needs to be in both YAML for the helm template, and jsonnet for the kubecfg parts. Therefor it would be a really useful if kubecfg had something similar to renderHelmChart in KSonnet.

@mkmik
Copy link
Contributor

mkmik commented Sep 26, 2019

Yeah this was something I'd wanted to attack for a long time now. I'm happy to see there is public interest too.

anguslees added a commit to anguslees/kubecfg-1 that referenced this issue Aug 31, 2021
Add a new `helmTemplate` native function that downloads and expands
helm charts into jsonnet objects.  The new code links helm (v3)
libraries directly, and does not require nor use the external `helm`
command.

Fixes vmware-archive#267

Example usage:

```
local kubecfg = import "kubecfg.libsonnet";

local url = "https://charts.jetstack.io/charts/cert-manager-v1.5.3.tgz";
local cm = kubecfg.helmTemplate("cert-manager", namespace, url, {
  // Example values.yaml
  webhook: {replicaCount: 2},
});

// ... returns a jsonnet object with filename keys from the helm chart
// and expanded/parsed Kubernetes objects as values.

// The result can be manipulated and used just like any other jsonnet
// value.
cm + {
  "cert-manager/templates/webhook-deployment.yaml": {
    spec+: {
      template+: {
        spec+: {
          nodeSelector+: {"kubernetes.io/arch": "amd64"},
        },
      },
    },
  },
}
```

*Caveats:*

- Helm 'hooks' are not supported and ignored.
- Chart sort order is ignored, and the usual kubecfg sort mechanism is
  used.
- `chartURL` argument uses the kubecfg URL-based importer, but
  will reject relative URLs by default[1].
- HTTP_PROXY is obeyed, but there is no other cache.  The helm chart
  is re-downloaded on every invocation (for now).
- Probably some other things.

[1]: Relative URLs can be enabled using a new
`--allow-relative-helm-urls` flag.  URLs are interpreted relative to
$PWD currently, even when used by jsonnet from remote URLs.  _This will
change_.  TODO: Make this consistent with usual relative `import`
semantics, and enable by default.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants