Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python/Go binary to bulk replace images in kustomization.yaml files (was Port use_gcr_for_all_images.sh to work with kustomize) #3210

Closed
jlewi opened this issue May 7, 2019 · 17 comments · Fixed by kubeflow/website#1886

Comments

@jlewi
Copy link
Contributor

jlewi commented May 7, 2019

Port https://github.com/kubeflow/kubeflow/blob/master/scripts/gke/use_gcr_for_all_images.sh
to kustomize.

This script is used for switching the images to a private registry. We will need to update the script
to work with the new kustomize manifests.

@issue-label-bot
Copy link

Issue-Label Bot is automatically applying the label improvement/enhancement to this issue, with a confidence of 0.93. Please mark this comment with 👍 or 👎 to give our bot feedback!

Links: app homepage, dashboard and code for this bot.

@jlewi jlewi added this to To do in gcp-enterprise via automation May 7, 2019
@jlewi jlewi added this to New in 0.6.0 via automation May 7, 2019
@jlewi jlewi added this to To do in ksonnet-turndown via automation May 7, 2019
@jlewi jlewi changed the title Port use_gcr_for_all_images.sh Port use_gcr_for_all_images.sh to work with kustomize May 13, 2019
@jlewi jlewi moved this from To do to 0.6-backlog in ksonnet-turndown Jun 21, 2019
@jlewi jlewi added this to To Do in 0.7.0 via automation Jul 22, 2019
@jlewi jlewi removed this from New in 0.6.0 Jul 22, 2019
@jlewi
Copy link
Contributor Author

jlewi commented Jul 22, 2019

I might suggest rewriting this as a go program and baking it into kfctl.

It might be nice if the tool supported some flexible way to match and replace images; e.g. using regexes. This way we could easily replace all images hosted in quay.io with another registry.

This would go a long way to making it easy to mirror all the required images to a different registry and then pull the images from it.

@swiftdiaries
Copy link
Member

/help-wanted

@swiftdiaries
Copy link
Member

Yeah, we're slated for 0.7 but this hasn't been picked yet

@ashahba
Copy link
Member

ashahba commented Aug 15, 2019

To backup your point @jlewi I think we should start with only supporting internal registries that have the same repo structure that we propose, otherwise users need to update image urls manually.
This is mainly to simplify the private registry support.

@jlewi jlewi changed the title Port use_gcr_for_all_images.sh to work with kustomize Python/Go binary to bulk replace images in kustomization.yaml files (was Port use_gcr_for_all_images.sh to work with kustomize) Aug 27, 2019
@jlewi
Copy link
Contributor Author

jlewi commented Aug 27, 2019

If someone wants to pick this up; I think a great first step would just be to modify
https://github.com/kubeflow/kubeflow/blob/master/scripts/gke/use_gcr_for_all_images.sh

To replace the ks param commands with kustomize edit set commands.

If we wanted to be a bit more forward looking we could rewrite that bash script as a go program but still shell out to kustomize and hard code the list of images to replace.

@xaniasd
Copy link
Contributor

xaniasd commented Aug 30, 2019

I'll take a stab at this if noone else is doing that already!

@jlewi
Copy link
Contributor Author

jlewi commented Oct 6, 2019

Thanks @xaniasd !

After #4222 is merged can we update the docs on kubeflow/website before we close this issue?

A follow on issue would be to provide tooling to mirror of the Kubeflow images to a different repository.

I think one way we might be able to do that in a generic way would be to spit out a Tekton workflow that would pull the images from one repo, retag them and push them. (I'm hoping that's doable with Tekton).

@xaniasd Any interest in tackling that next (after the docs?)?

@xaniasd
Copy link
Contributor

xaniasd commented Oct 6, 2019

@jlewi I can add the documentation (I'll look into the setup and make a PR), no worries. About the follow-up; sure thing. I'm not familiar with Tekton and how we want to use it in this case, if you could give some background information I can give it a try. That said, a simple way to do this would be to just implement it in kfctl and fork docker pull/push commands for each image. Then we don't assume a running tekton instance (?). Along the same lines, an even simpler option would be to use kfctl to just spit out a list of images and build a bash command to do the pulling and pushing.

@yanniszark
Copy link
Contributor

@xaniasd I actually have a small PR ready for exactly this thing, spitting out a changelist in stdout.
The user can use it to mirror images with any tool they want.
Will make a PR tomorrow.

@jlewi
Copy link
Contributor Author

jlewi commented Oct 25, 2019

There's a couple reasons why on GCP we'd like to leverage Google Cloud Build or possibly Tekton to replicate the images

  1. The number of images for Kubeflow is large O(10)'s if not O(100')s so we want to do the retagging in parallel
  2. Given the large number of images we'd like to do the image pulling/pushing in the cloud to avoid network transfer to lower machines
  3. With private GKE and Secure VPC we want to be able to use service accounts to talk to GCR

We have a sample jsonnet workflow here.

I think for GCP what we'd want is a command or separate go binary to traverse the kustomize directory and generate a YAML spec for the workflow to replicate all images.

I think this should be separate from the set-image-name command so we can build a replication workflow without modifying the kustomization.yaml files.

The code should look at kustomization.yaml to get the old image name and tag and the new image name and tag.

Generating a Tekton workflow would be a cloud neutral solution to this.

@stale
Copy link

stale bot commented Jan 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@jlewi
Copy link
Contributor Author

jlewi commented Jan 28, 2020

/lifecycle frozen

It looks like kustomize supports composition; see kubernetes-sigs/kustomize#171

So if we define a kustomize manifest that composes all of the individual applications in Kubeflow (i.e. lists each kubeflow application as a base); then we should just be able to override all the images by writing a kustomization.yaml file in that package that specifies the image we want to replace and the new image.

Related: Get rid of kustomize magic in kfctl kubeflow/manifests#774
Relevant thread: https://groups.google.com/forum/m/#!topic/kubeflow-discuss/uWp39i2nNuQ

@kunmingg
Copy link
Contributor

kubeflow/kfctl#226

@jlewi
Copy link
Contributor Author

jlewi commented Feb 19, 2020

@kunmingg what is the remaining work to close out this issue?

It looks like we need to update the documentation page; e.g https://www.kubeflow.org/docs/gke/private-clusters/#deploy-kubeflow-with-private-gke

to describe how to use the new functionality. Is there anything else that needs to be done?

@jlewi jlewi added this to To do in Kubeflow 1.1 via automation Mar 19, 2020
@jlewi jlewi removed this from 0.6-backlog in ksonnet-turndown Mar 19, 2020
@jlewi
Copy link
Contributor Author

jlewi commented Mar 19, 2020

@kunmingg thoughts? Any more immediate work to be done?

@jlewi
Copy link
Contributor Author

jlewi commented Apr 6, 2020

@kunmingg ping?

jlewi pushed a commit to jlewi/website that referenced this issue Apr 8, 2020
* Add instructions for mirroring docker images to private repositories
  * Fix kubeflow/kubeflow#3210

* Delete instructions under private GKE and just link to the doc issue kubeflow#1705

  * The instructions are outdated. Since managed certificates are used there
    should be no reason to need to update iap-ingress.yaml anymore.
    * Fix kubeflow#1811

  * Most of the other instructions under the private GKE section are also
    very obsolete.
gcp-enterprise automation moved this from To do to Done Apr 8, 2020
Kubeflow 1.1 automation moved this from To do to Done Apr 8, 2020
k8s-ci-robot pushed a commit to kubeflow/website that referenced this issue Apr 8, 2020
* Private GKE: Document image mirroring

* Add instructions for mirroring docker images to private repositories
  * Fix kubeflow/kubeflow#3210

* Delete instructions under private GKE and just link to the doc issue #1705

  * The instructions are outdated. Since managed certificates are used there
    should be no reason to need to update iap-ingress.yaml anymore.
    * Fix #1811

  * Most of the other instructions under the private GKE section are also
    very obsolete.

* Fix indentation.

* Fix indetation.

* Fix indentation.

* Fix alert.

* More formatting fixes.

* Add comment about Tekton.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

8 participants