Helm Generator
If a component already has a productive Helm chart, the HelmGenerator implementation
(package pkg/manifests/helm) can render it:
package helm
func NewHelmGenerator(fsys fs.FS, chartPath string, clnt client.Client) (*HelmGenerator, error)
fsysmust be anfs.FSimplementation (such as anembed.FS), ornil. Ifnil, all file operations are performed on the OS filesystem, andchartPathmay be an absolute path or a path relative to the controller’s working directory. Iffsysis non-nil,chartPathshould be relative (an absolute path is turned into a relative one by stripping the leading slash). When using a real filesystem,os.Root.FS()is recommended overos.DirFS()in order to fence symbolic links. An emptychartPathis treated like..clntis deprecated and ignored; it will be removed in a future release. The clients used at generation time are taken from the context instead.
Transformable variants are available as NewTransformableHelmGenerator(),
NewHelmGeneratorWithParameterTransformer(), and
NewHelmGeneratorWithObjectTransformer() (see
Transforming Existing Generators).
HelmGenerator does not use the Helm SDK; instead it emulates Helm’s behavior as closely
as possible. A few differences and restrictions arise from this:
- Most, but not all Helm template functions are supported. For example,
toTomlis not supported; all other functions should work but may behave more strictly on errors. - Not all builtin variables are supported:
.Releaseis supported;Release.IsInstallistrueduring the first reconcile iteration (that is, whenstatus.revisionequals 1), andRelease.IsUpgradeis its inverse;Release.Revisionincreases whenever the component manifest or one of its references (such as referenced secrets) changes.- for
.Chart, only.Chart.Name,.Chart.Version,.Chart.Type,.Chart.AppVersion, and.Chart.Dependenciesare supported. - for
.Capabilities, only.Capabilities.KubeVersionand.Capabilities.APIVersionsare supported. .Templateis fully supported..Filesis supported but does not return any of the paths reserved by Helm (such asChart.yamlortemplates/).
- Regarding hooks:
pre-deleteandpost-deletehooks are not allowed; test and rollback hooks are ignored;pre-install,post-install,pre-upgrade, andpost-upgradehooks may be handled slightly differently:- install hooks added later to objects of an already installed release are applied with the next reconcile, even though this is not the install case.
- objects using
pre-install,post-installorpre-upgrade,post-upgradeare applied only once per reconcile (early), and, if the deletion policyhook-succeededis set, are deleted late. - obsolete hook objects (created by a hook, but no longer part of the manifest) are
deleted immediately, unless they carry
helm.sh/resource-policy: keep— in which case they are never deleted, even when the component is deleted. - hook weights are handled compatibly; the
hook-faileddeletion policy is not allowed, butbefore-hook-creationandhook-succeededwork as expected.
- The
.helmignorefile is currently not evaluated; files can still be accessed through.Fileseven if listed in.helmignore.
Finally, note that native component-operator-runtime object annotations, such as mycomponent-operator.mydomain.io/apply-order, are forbidden in Helm templates.
This is to prevent potential clashes arising from the framework translating certain Helm annotations (such as helm.sh/hook": post-install) into component-operator-runtime annotations.