open-cluster-management-io / addon-framework

addon apis
Apache License 2.0
23 stars 40 forks source link

:sparkles: Support override addon images by the cluster's annotation #197

Closed zhujian7 closed 1 year ago

zhujian7 commented 1 year ago

Make the addon framework support override addon agents' images by the cluster's annotation. If the managedCluster has annotation open-cluster-management.io/image-registries in format:

{
   "registries":[
      {
         "mirror":"quay.io/ocm/addon-examples",
         "source":"quay.io/open-cluster-management/addon-examples"
      }
   ]
}

For example:

apiVersion: cluster.open-cluster-management.io/v1
kind: ManagedCluster
metadata:
  annotations:
    open-cluster-management.io/image-registries: '{"registries":[{"mirror":"quay.io/ocm/addon-examples","source":"quay.io/open-cluster-management/addon-examples"}]}'

If the addon manager uses the GetAgentImageValues func in the addon manager like:

            addonfactory.GetAgentImageValues(
                addonfactory.NewAddOnDeploymentConfigGetter(addonClient),
                "global.imageOverrides.helloWorldHelm",
                "quay.io/open-cluster-management/addon-examples",
            ),

and use the "global.imageOverrides.helloWorldHelm" placeholder in the agent manifests yaml like:

      - name: helloWorld-agent
        image: {{ .Values.global.imageOverrides.helloWorldHelm }}

The image will be overridden to "quay.io/ocm/addon-examples"

Note: if the addon is also configured by the addonDeploymentConfig to override the image, the addonDeploymentConfig will take precedence over this annotation.

zhujian7 commented 1 year ago

/hold

zhujian7 commented 1 year ago

/unhold /assign @zhiweiyin318 /cc @qiujian16

zhiweiyin318 commented 1 year ago

/lgtm

qiujian16 commented 1 year ago

/approve /lgtm

openshift-ci[bot] commented 1 year ago

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: qiujian16, zhujian7

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files: - ~~[OWNERS](https://github.com/open-cluster-management-io/addon-framework/blob/main/OWNERS)~~ [qiujian16] Approvers can indicate their approval by writing `/approve` in a comment Approvers can cancel approval by writing `/approve cancel` in a comment