This repository has been archived by the owner on Aug 17, 2023. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kustomize fn to transform images (#345)
* kustomize fn to transform images * This PR defines a kustomize/kpt function to transform images based on their prefix. * This is an alternative to using kfctl mirror overwrite * This works as follows. i) you define a function config like the following ``` apiVersion: v1alpha1 # Define a transform to change all the image prefixes to use images from a different registry kind: ImagePrefix metadata: name: use-mirror-images-gcr annotations: config.kubernetes.io/function: | container: image: gcr.io/kubeflow-images-public/kpt-fns:v1.0-rc.3-58-g616f986-dirty spec: imageMappings: - src: quay.io/jetstack dest: gcr.io/gcp-private-dev/jetstack # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"gcloud.core.project","value":"gcp-private-dev"}]}} - src: gcr.io/kubeflow-images-public dest: gcr.io/gcp-private-dev # {"type":"string","x-kustomize":{"setBy":"kpt","partialSetters":[{"name":"gcloud.core.project","value":"gcp-private-dev"}]}} ``` ii) You use kpt to appy the function e.g. ``` kpt fn ${DIR} ``` * Typically you would apply this to the hydrated manfiests * The transform will look for any objects with `image-prefix.kubeflow.org` annotation and then map the image prefixes specified in that annotation * The kpt function has a number of advantages over the kfctl functionality * In particular the transform configuration (i.e. the annotation) doesn't need to change when a user upgrades and the image tags change. Since the transform is applied after hydration we would end up applying the transform to any docker images * `kpt fns` are more scalable then baking all the functionality into a single go binary * It also looks like this functionality will be upstreamed into kustomize * kubeflow/manifests#1033 proposed a similar transformer for images. * This is different only in we are using kpt/kustomize functions rather than kustomize transformations * kpt functions are more flexible because its YAML in YAML out; so you could just as easily * Trigger kustomize-fns unittests. * Revert go.mod changes. * Address comments.
- Loading branch information