-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Add a new flag to cleanup the filesystem at the end #370
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. Instructions 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for contributing this feature! Just had a few comments around organization.
cmd/executor/cmd/root.go
Outdated
@@ -37,11 +37,13 @@ var ( | |||
opts = &config.KanikoOptions{} | |||
logLevel string | |||
force bool | |||
cleanup bool |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Instead of creating a new variable here, could we add this to KanikoOptions? This should help with executing the comment below.
cmd/executor/cmd/root.go
Outdated
@@ -77,6 +79,11 @@ var RootCmd = &cobra.Command{ | |||
if err := executor.DoPush(image, opts); err != nil { | |||
exit(errors.Wrap(err, "error pushing image")) | |||
} | |||
if cleanup { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.