kaniko icon indicating copy to clipboard operation
kaniko copied to clipboard

Adding a --include-path flag to kaniko build

Open Ga13Ou opened this issue 1 year ago • 1 comments

Actual behavior Hello Kaniko Team,

I'm encountering a challenge with persistent volume usage in Kaniko. To manage ephemeral storage issues in Kaniko pods, I've set up a PVC/PV and mounted it at /opt/my-user/my-big-dependencies-and-relevant-files for building the image. With the build process utilizing the persistent volume effectively, thereby reducing the load on node ephemeral storage.

However, I encountered an issue where the contents of /opt/my-user/my-big-dependencies-and-relevant-files are not included in the final image that is pushed to the registry. This results in the final image missing installed packages that were expected to be part of it.

Upon investigating, I found that the internal logic of Kaniko, specifically in fs_util.go (fs_util.go#L455C6-L455C32), seems to skip directories listed in /proc/self/mountinfo during the snapshotting process. The logs indicate that /opt/my-user/my-big-dependencies-and-relevant-files is recognized as mounted but is later 'whiteouted' and skipped in the final image.

While Kaniko offers an --ignore-paths flag, it lacks an equivalent include-paths option.

Expected behavior Have the mounted paths be part of the image. Or have flag that can be used to explicitly include those paths

To Reproduce Steps to reproduce the behavior in kubernetes :

  1. Mount a pvc to the kaniko pod on a specific path
  2. Build the image
  3. Note that the specific mounted path is ignored during build and does not exist in the final image.

Thank you in advance for your assistance and looking forward to a possible enhancement in Kaniko's functionality.

Triage Notes for the Maintainers

Description Yes/No
Please check if this a new feature you are proposing
  • - [ ]
Please check if the build works in docker but not in kaniko
  • - [ ]
Please check if this error is seen when you use --cache flag
  • - [ ]
Please check if your dockerfile is a multistage dockerfile
  • - [ ]

Ga13Ou avatar Nov 30 '23 09:11 Ga13Ou