Add a new flag to cleanup the filesystem at the end#370
Add a new flag to cleanup the filesystem at the end#370priyawadhwa merged 1 commit intoGoogleContainerTools:masterfrom
Conversation
|
Hi @vbehar. Thanks for your PR. I'm waiting for a GoogleContainerTools member to verify that this patch is reasonable to test. If it is, they should reply with I understand the commands that are listed here. DetailsInstructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
|
This would be awesome! I'm using GitLab CI, I need to build 2 images, the second depending on the first. To be able to use kaniko I had to create 2 stages because GitLab's jobs can't be sequential. If this gets merged everything could be achieved in a single job |
priyawadhwa
left a comment
There was a problem hiding this comment.
Thanks for contributing this feature! Just had a few comments around organization.
| opts = &config.KanikoOptions{} | ||
| logLevel string | ||
| force bool | ||
| cleanup bool |
There was a problem hiding this comment.
Instead of creating a new variable here, could we add this to KanikoOptions? This should help with executing the comment below.
| if err := executor.DoPush(image, opts); err != nil { | ||
| exit(errors.Wrap(err, "error pushing image")) | ||
| } | ||
| if cleanup { |
There was a problem hiding this comment.
Instead of having this in root.go, I think it would be better placed in this if statement in build.go
If opts.Cleanup is true, then delete the filesystem before returning the image.
da14929 to
3989d27
Compare
Currently, kaniko can only build a single image per container run, because the filesystem is full of the content of the first image. When running kaniko in Jenkins, where we need to start the container "doing nothing" first (using the debug kaniko container), and then exec /kaniko/executor, this is a limitation because it means that if we want to build multiple images, we need to start multiple containers - see https://groups.google.com/forum/#!topic/kaniko-users/_7LivHdMdy0 for more details A solution to fix this issue is to add a new flag to cleanup the filesystem at the end - the same way it is done between stages when building a multi-stages image. This way, the same (debug) container can be used to build multiple images.
3989d27 to
49ab8e4
Compare
|
@priyawadhwa ok, thanks for the review! I changed the implementation and squashed. |
priyawadhwa
left a comment
There was a problem hiding this comment.
LGTM, thanks for contributing this!
Currently, kaniko can only build a single image per container run, because the filesystem is full of the content of the first image.
When running kaniko in Jenkins, where we need to start the container "doing nothing" first (using the debug kaniko container), and then exec /kaniko/executor, this is a limitation because it means that if we want to build multiple images, we need to start multiple containers - see https://groups.google.com/forum/#!topic/kaniko-users/_7LivHdMdy0 for more details
A solution to fix this issue is to add a new flag to cleanup the filesystem at the end - the same way it is done between stages when building a multi-stages image. This way, the same (debug) container can be used to build multiple images.