Documentation ¶
Index ¶
- Constants
- Variables
- func NewAddOnDeploymentConfigGetter(addonClient addonv1alpha1client.Interface) utils.AddOnDeploymentConfigGetter
- func NewFakeManagedCluster(name string, k8sVersion string) *clusterv1.ManagedCluster
- func NewFakeManagedClusterAddon(name, clusterName, installNamespace, values string) *addonapiv1alpha1.ManagedClusterAddOn
- func OverrideImage(registries []addonapiv1alpha1.ImageMirror, imageName string) string
- type AddOnDeploymentConfigToValuesFunc
- type AgentAddonFactory
- func (f *AgentAddonFactory) BuildHelmAgentAddon() (agent.AgentAddon, error)
- func (f *AgentAddonFactory) BuildTemplateAgentAddon() (agent.AgentAddon, error)
- func (f *AgentAddonFactory) WithAgentDeployTriggerClusterFilter(filter func(old, new *clusterv1.ManagedCluster) bool) *AgentAddonFactory
- func (f *AgentAddonFactory) WithAgentHealthProber(prober *agent.HealthProber) *AgentAddonFactory
- func (f *AgentAddonFactory) WithAgentHostedInfoFn(...) *AgentAddonFactory
- func (f *AgentAddonFactory) WithAgentHostedModeEnabledOption() *AgentAddonFactory
- func (f *AgentAddonFactory) WithAgentInstallNamespace(nsFunc func(addon *addonapiv1alpha1.ManagedClusterAddOn) (string, error)) *AgentAddonFactory
- func (f *AgentAddonFactory) WithAgentRegistrationOption(option *agent.RegistrationOption) *AgentAddonFactory
- func (f *AgentAddonFactory) WithConfigCheckEnabledOption() *AgentAddonFactory
- func (f *AgentAddonFactory) WithConfigGVRs(gvrs ...schema.GroupVersionResource) *AgentAddonFactory
- func (f *AgentAddonFactory) WithGetValuesFuncs(getValuesFuncs ...GetValuesFunc) *AgentAddonFactory
- func (f *AgentAddonFactory) WithHelmEngineStrict() *AgentAddonFactory
- func (f *AgentAddonFactory) WithHostingCluster(cluster *clusterv1.ManagedCluster) *AgentAddonFactory
- func (f *AgentAddonFactory) WithManagedClusterClient(c clusterclientset.Interface) *AgentAddonFactory
- func (f *AgentAddonFactory) WithScheme(s *runtime.Scheme) *AgentAddonFactory
- func (f *AgentAddonFactory) WithTrimCRDDescription() *AgentAddonFactory
- type GetValuesFunc
- type HelmAgentAddon
- func (a *HelmAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions
- func (a *HelmAgentAddon) Manifests(cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) ([]runtime.Object, error)
- func (a *HelmAgentAddon) SetHostingCluster(hostingCluster *clusterv1.ManagedCluster)deprecated
- type TemplateAgentAddon
- type Values
- func GetValuesFromAddonAnnotation(cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) (Values, error)
- func JsonStructToValues(a interface{}) (Values, error)
- func MergeValues(a, b Values) Values
- func StructToValues(a interface{}) Values
- func ToAddOnCustomizedVariableValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
- func ToAddOnDeploymentConfigValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
- func ToAddOnNodePlacementValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
- func ToAddOnProxyConfigValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
Constants ¶
const AddonDefaultInstallNamespace = "open-cluster-management-agent-addon"
const AnnotationValuesName string = "addon.open-cluster-management.io/values"
AnnotationValuesName is the annotation Name of customized values
Variables ¶
var AddOnDeploymentConfigGVR = schema.GroupVersionResource{
Group: "addon.open-cluster-management.io",
Version: "v1alpha1",
Resource: "addondeploymentconfigs",
}
Deprecated: use AddOnDeploymentConfigGVR in package "open-cluster-management.io/addon-framework/pkg/utils" instead.
Functions ¶
func NewAddOnDeploymentConfigGetter ¶ added in v0.6.1
func NewAddOnDeploymentConfigGetter(addonClient addonv1alpha1client.Interface) utils.AddOnDeploymentConfigGetter
NewAddOnDeploymentConfigGetter returns a AddOnDeploymentConfigGetter with addon client Deprecated: use NewAddOnDeploymentConfigGetter in pkg/utils package instead.
func NewFakeManagedCluster ¶
func NewFakeManagedCluster(name string, k8sVersion string) *clusterv1.ManagedCluster
func NewFakeManagedClusterAddon ¶
func NewFakeManagedClusterAddon(name, clusterName, installNamespace, values string) *addonapiv1alpha1.ManagedClusterAddOn
func OverrideImage ¶ added in v0.8.0
func OverrideImage(registries []addonapiv1alpha1.ImageMirror, imageName string) string
OverrideImage checks whether the source configured in registries can match the imagedName, if yes will use the mirror value in the registries to override the imageName
Types ¶
type AddOnDeploymentConfigToValuesFunc ¶ added in v0.6.1
type AddOnDeploymentConfigToValuesFunc func(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
AddOnDeploymentConfigToValuesFunc transform the AddOnDeploymentConfig object into Values object The transformation logic depends on the definition of the addon template
func ToImageOverrideValuesFunc ¶ added in v0.8.0
func ToImageOverrideValuesFunc(imageKey, image string) AddOnDeploymentConfigToValuesFunc
ToImageOverrideValuesFunc return a func that can use the AddOnDeploymentConfig.spec.Registries to override image, then return the overridden value with key imageKey.
for example: the spec of one AddOnDeploymentConfig is: { registries: [{source: "quay.io/open-cluster-management/addon-agent", mirror: "quay.io/ocm/addon-agent"}]} the imageKey is "helloWorldImage", the image is "quay.io/open-cluster-management/addon-agent:v1" after transformed, the Values object will be: {"helloWorldImage": "quay.io/ocm/addon-agent:v1"}
Note:
- the imageKey can support the nested key, for example: "global.imageOverrides.helloWorldImage", the output will be: {"global": {"imageOverrides": {"helloWorldImage": "quay.io/ocm/addon-agent:v1"}}}
- If you want to override the image with the value from the AddOnDeploymentConfig.spec.Registries first, and if it is not changed, then override it with the value from the cluster annotation, you can use the function GetAgentImageValues instead.
type AgentAddonFactory ¶
type AgentAddonFactory struct {
// contains filtered or unexported fields
}
AgentAddonFactory includes the common fields for building different agentAddon instances.
func NewAgentAddonFactory ¶
func NewAgentAddonFactory(addonName string, fs embed.FS, dir string) *AgentAddonFactory
NewAgentAddonFactory builds an addonAgentFactory instance with addon name and fs. dir is the path prefix based on the fs path.
func (*AgentAddonFactory) BuildHelmAgentAddon ¶
func (f *AgentAddonFactory) BuildHelmAgentAddon() (agent.AgentAddon, error)
BuildHelmAgentAddon builds a helm agentAddon instance.
func (*AgentAddonFactory) BuildTemplateAgentAddon ¶
func (f *AgentAddonFactory) BuildTemplateAgentAddon() (agent.AgentAddon, error)
BuildTemplateAgentAddon builds a template agentAddon instance.
func (*AgentAddonFactory) WithAgentDeployTriggerClusterFilter ¶ added in v0.8.0
func (f *AgentAddonFactory) WithAgentDeployTriggerClusterFilter( filter func(old, new *clusterv1.ManagedCluster) bool, ) *AgentAddonFactory
WithAgentDeployTriggerClusterFilter defines the filter func to trigger the agent deploy/redploy when cluster info is changed. Addons that need information from the ManagedCluster resource when deploying the agent should use this function to set what information they need, otherwise the expected/up-to-date agent may be deployed delayed since the default filter func returns false when the ManagedCluster resource is updated.
For example, the agentAddon needs information from the ManagedCluster annotation, it can set the filter function like:
WithAgentDeployClusterTriggerFilter(func(old, new *clusterv1.ManagedCluster) bool { return !equality.Semantic.DeepEqual(old.Annotations, new.Annotations) })
func (*AgentAddonFactory) WithAgentHealthProber ¶ added in v0.4.0
func (f *AgentAddonFactory) WithAgentHealthProber(prober *agent.HealthProber) *AgentAddonFactory
WithAgentHealthProber defines how is the healthiness status of the ManagedClusterAddon probed.
func (*AgentAddonFactory) WithAgentHostedInfoFn ¶ added in v0.10.0
func (f *AgentAddonFactory) WithAgentHostedInfoFn( infoFn func(*addonapiv1alpha1.ManagedClusterAddOn, *clusterv1.ManagedCluster) (string, string)) *AgentAddonFactory
WithAgentHostedInfoFn sets the function to get the hosting cluster of an addon in the hosted mode.
func (*AgentAddonFactory) WithAgentHostedModeEnabledOption ¶ added in v0.5.0
func (f *AgentAddonFactory) WithAgentHostedModeEnabledOption() *AgentAddonFactory
WithAgentHostedModeEnabledOption will enable the agent hosted deploying mode.
func (*AgentAddonFactory) WithAgentInstallNamespace ¶ added in v0.9.0
func (f *AgentAddonFactory) WithAgentInstallNamespace( nsFunc func(addon *addonapiv1alpha1.ManagedClusterAddOn) (string, error), ) *AgentAddonFactory
WithAgentInstallNamespace defines the namespace where the agent resources will be deployed, this will override the default built-in namespace value; And if the registrationOption is not nil but the registrationOption.AgentInstallNamespace is nil, this will also set it to this.
func (*AgentAddonFactory) WithAgentRegistrationOption ¶
func (f *AgentAddonFactory) WithAgentRegistrationOption(option *agent.RegistrationOption) *AgentAddonFactory
WithAgentRegistrationOption defines how agent is registered to the hub cluster.
func (*AgentAddonFactory) WithConfigCheckEnabledOption ¶ added in v0.11.0
func (f *AgentAddonFactory) WithConfigCheckEnabledOption() *AgentAddonFactory
WithConfigCheckEnabledOption will enable the configured condition check before rendering manifests.
func (*AgentAddonFactory) WithConfigGVRs ¶ added in v0.5.0
func (f *AgentAddonFactory) WithConfigGVRs(gvrs ...schema.GroupVersionResource) *AgentAddonFactory
WithConfigGVRs defines the addon supported configuration GroupVersionResource
func (*AgentAddonFactory) WithGetValuesFuncs ¶
func (f *AgentAddonFactory) WithGetValuesFuncs(getValuesFuncs ...GetValuesFunc) *AgentAddonFactory
WithGetValuesFuncs adds a list of the getValues func. the values got from the big index Func will override the one from small index Func.
func (*AgentAddonFactory) WithHelmEngineStrict ¶ added in v0.10.0
func (f *AgentAddonFactory) WithHelmEngineStrict() *AgentAddonFactory
WithHelmEngineStrict is to enable script go template rendering for Helm charts to generate manifestWork.
func (*AgentAddonFactory) WithHostingCluster ¶ added in v0.6.1
func (f *AgentAddonFactory) WithHostingCluster(cluster *clusterv1.ManagedCluster) *AgentAddonFactory
WithHostingCluster defines the hosting cluster used in hosted mode. An AgentAddon may use this to provide additional metadata. Deprecated: use WithManagedClusterClient to set a cluster client that can get the hosting cluster.
func (*AgentAddonFactory) WithManagedClusterClient ¶ added in v0.10.0
func (f *AgentAddonFactory) WithManagedClusterClient(c clusterclientset.Interface) *AgentAddonFactory
WithManagedClusterClient defines the cluster client that can get the hosting cluster used in hosted mode.
func (*AgentAddonFactory) WithScheme ¶
func (f *AgentAddonFactory) WithScheme(s *runtime.Scheme) *AgentAddonFactory
WithScheme is an optional configuration, only used when the agentAddon has customized resource types.
func (*AgentAddonFactory) WithTrimCRDDescription ¶
func (f *AgentAddonFactory) WithTrimCRDDescription() *AgentAddonFactory
WithTrimCRDDescription is to enable trim the description of CRDs in manifestWork.
type GetValuesFunc ¶
type GetValuesFunc func(cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) (Values, error)
func GetAddOnDeploymentConfigValues ¶ added in v0.6.1
func GetAddOnDeploymentConfigValues( getter utils.AddOnDeploymentConfigGetter, toValuesFuncs ...AddOnDeploymentConfigToValuesFunc) GetValuesFunc
GetAddOnDeploymentConfigValues uses AddOnDeploymentConfigGetter to get the AddOnDeploymentConfig object, then uses AddOnDeploymentConfigToValuesFunc to transform the AddOnDeploymentConfig object to Values object If there are multiple AddOnDeploymentConfig objects in the AddOn ConfigReferences, the big index object will override the one from small index
func GetAgentImageValues ¶ added in v0.8.0
func GetAgentImageValues(getter utils.AddOnDeploymentConfigGetter, imageKey, image string) GetValuesFunc
GetAgentImageValues return a func that can use two ways, AddOnDeploymentConfig.spec.Registries and annotation on the ManagedCluster, to override image, then return the overridden value with key imageKey. For example:
configure the image registries with the spec of the AddOnDeploymentConfig, if the registries in the spec is: {...,"spec":{"registries":[{"mirror":"quay.io/ocm/addon-agent","source":"quay.io/open-cluster-management/addon-agent"}]}} the "imageKey" is "helloWorldImage", the "image" is "quay.io/open-cluster-management/addon-agent:v1" after transformed, the Values object will be: {"helloWorldImage": "quay.io/ocm/addon-agent:v1"}
configure the image registries with the annotation "open-cluster-management.io/image-registries" on the ManagedCluster, if the annotation on the managed cluster resource is: "open-cluster-management.io/image-registries": '{"registries":[{"mirror":"quay.io/ocm","source":"quay.io/open-cluster-management"}]}' the "imageKey" is "helloWorldImage", the "image" is "quay.io/open-cluster-management/addon-agent:v1" after transformed, the Values object will be: {"helloWorldImage": "quay.io/ocm/addon-agent:v1"}
Note:
- the imageKey can support the nested key, for example: "global.imageOverrides.helloWorldImage", the output will be: {"global": {"imageOverrides": {"helloWorldImage": "quay.io/ocm/addon-agent:v1"}}}
- Image registries configured in the addonDeploymentConfig will take precedence over the managed cluster annotation
type HelmAgentAddon ¶
type HelmAgentAddon struct {
// contains filtered or unexported fields
}
func (*HelmAgentAddon) GetAgentAddonOptions ¶
func (a *HelmAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions
func (*HelmAgentAddon) Manifests ¶
func (a *HelmAgentAddon) Manifests( cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) ([]runtime.Object, error)
func (*HelmAgentAddon) SetHostingCluster
deprecated
added in
v0.10.0
func (a *HelmAgentAddon) SetHostingCluster(hostingCluster *clusterv1.ManagedCluster)
Deprecated: use "WithManagedClusterClient" in AgentAddonFactory to set a cluster client that can be used to get the hosting cluster.
type TemplateAgentAddon ¶
type TemplateAgentAddon struct {
// contains filtered or unexported fields
}
func (*TemplateAgentAddon) GetAgentAddonOptions ¶
func (a *TemplateAgentAddon) GetAgentAddonOptions() agent.AgentAddonOptions
func (*TemplateAgentAddon) Manifests ¶
func (a *TemplateAgentAddon) Manifests( cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) ([]runtime.Object, error)
type Values ¶
type Values map[string]interface{}
func GetValuesFromAddonAnnotation ¶
func GetValuesFromAddonAnnotation( cluster *clusterv1.ManagedCluster, addon *addonapiv1alpha1.ManagedClusterAddOn) (Values, error)
GetValuesFromAddonAnnotation get the values in the annotation of addon cr. the key of the annotation is `addon.open-cluster-management.io/values`, the value is a json string which has the values. for example: "addon.open-cluster-management.io/values": `{"NodeSelector":{"host":"ssd"},"Image":"quay.io/helloworld:2.4"}`
func JsonStructToValues ¶
JsonStructToValues converts the given json struct to a Values
func MergeValues ¶
MergeValues merges the 2 given Values to a Values. the values of b will override that in a for the same fields.
func StructToValues ¶
func StructToValues(a interface{}) Values
StructToValues converts the given struct to a Values
func ToAddOnCustomizedVariableValues ¶ added in v0.6.0
func ToAddOnCustomizedVariableValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
ToAddOnCustomizedVariableValues only transform the CustomizedVariables in the spec of AddOnDeploymentConfig into Values object. for example: the spec of one AddOnDeploymentConfig is:
{ customizedVariables: [{name: "a", value: "x"}, {name: "b", value: "y"}], }
after transformed, the Values will be: map[a:x b:y]
func ToAddOnDeploymentConfigValues ¶ added in v0.6.1
func ToAddOnDeploymentConfigValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
ToAddOnDeploymentConfigValues transform the AddOnDeploymentConfig object into Values object that is a plain value map for example: the spec of one AddOnDeploymentConfig is:
{ customizedVariables: [{name: "Image", value: "img"}, {name: "ImagePullPolicy", value: "Always"}], nodePlacement: {nodeSelector: {"host": "ssd"}, tolerations: {"key": "test"}}, }
after transformed, the key set of Values object will be: {"Image", "ImagePullPolicy", "NodeSelector", "Tolerations"}
func ToAddOnNodePlacementValues ¶ added in v0.5.0
func ToAddOnNodePlacementValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
ToAddOnNodePlacementValues only transform the AddOnDeploymentConfig NodePlacement part into Values object that has a specific for helm chart values for example: the spec of one AddOnDeploymentConfig is:
{ nodePlacement: {nodeSelector: {"host": "ssd"}, tolerations: {"key":"test"}}, }
after transformed, the Values will be: map[global:map[nodeSelector:map[host:ssd]] tolerations:[map[key:test]]]
func ToAddOnProxyConfigValues ¶ added in v0.8.0
func ToAddOnProxyConfigValues(config addonapiv1alpha1.AddOnDeploymentConfig) (Values, error)
ToAddOnProxyConfigValues transform the spec.proxyConfig of AddOnDeploymentConfig into Values object that has a specific for helm chart values for example: the spec of one AddOnDeploymentConfig is:
{ proxyConfig: {"httpProxy": "http://10.11.12.13:3128", "httpsProxy": "https://10.11.12.13:3129", "noProxy": "example.com"}, }
after transformed, the Values will be: map[global:map[proxyConfig:map[httpProxy:http://10.11.12.13:3128 httpsProxy:https://10.11.12.13:3129 noProxy:example.com]]]