This doc is used to introduce how to migrate Helm Chart to an AddOn.
- Not all of built-in Objects of Helm Chart are support in AddOn. We only support below:
- Capabilities.KubeVersion.Version
- Release.Name
- Release.Namespace
- Not support Hooks of Helm Chart currently.
We have an example for Helm Chart migration in helloworld_helm.
- Need to import Helm Chart files into embed.FS.
- Create and start helmAgentAddon instance like this:
mgr, err := addonmanager.New(controllerContext.KubeConfig) if err != nil { return err } agentAddon, err := addonfactory.NewAgentAddonFactory(addonName, FS, "manifests/charts/helloworld"). WithGetValuesFuncs(getValues, addonfactory.GetValuesFromAddonAnnotation). WithAgentRegistrationOption(registrationOption). BuildHelmAgentAddon() if err != nil { return err } mgr.AddAgent(agentAddon) mgr.Start(ctx)
AddOn built-in values
Value.clusterNameValue.addonInstallNamespaceValue.hubKubeConfigSecret(used when the AddOn is needed to register to the Hub cluster)
Helm Chart built-in values
Capabilities.KubeVersionis theManagedCluster.Status.Version.Kubernetes.Release.Nameis the AddOn name.Release.Namespaceis theaddonInstallNamespace.
In the list of GetValuesFuncs, the values from the big index Func will override the one from low index Func.
The built-in values will override the values got from the list of GetValuesFuncs.
The Variable names in Values should begin with lowercase. So the best practice is to define a json struct for the values, and convert it to Values using the JsonStructToValues.
We support a helper GetValuesFunc named GetValuesFromAddonAnnotation which can get values from annotation of ManagedClusterAddon.
The key of the Helm Chart values in annotation is addon.open-cluster-management.io/values,
and the value should be a valid json string which has key-value format.