kubernetes-maven-plugin automatic pull for cacheFrom image #1519
davidecavestro
started this conversation in
General
Replies: 1 comment
-
Hi @davidecavestro, This has nothing to do with your original question, but while we investigate: I understand that the end purpose is to be able to reuse some of the intermediate images whilst performing your final build. Have you tried doing a multilayered (XML/DSL configured) build with a non-fatjar? In your case, considering the build produces an intermediate version of your jar with the dependencies, it would be something like: <configuration>
<images>
<image>
<name>${image.repo}/${image.name}:%l</name>
<build>
<from>registry.access.redhat.com/ubi8/openjdk-17</from>
<assembly>
<targetDir>/home/jboss</targetDir>
<excludeFinalOutputArtifact>true</excludeFinalOutputArtifact>
<layers>
<layer>
<id>dependencies</id>
<fileSets>
<fileSet>
<directory>${project.build.directory}/dependencies</directory>
</fileSet>
</fileSets>
</layer>
<layer>
<id>loader</id>
<fileSets>
<fileSet>
<directory>${project.build.directory}/loader</directory>
</fileSet>
</fileSets>
</layer>
<!-- ... -->
<layer>
<id>app</id>
<fileSets>
<fileSet>
<directory>${project.build.directory}/app</directory>
</fileSet>
</fileSets>
</layer>
</layers>
</assembly>
<ports>
<!-- Ports to expose in the pod specs -->
<port>8080</port>
</ports>
</build>
</image>
</images>
</configuration> |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Forewords
Hi, I open a discussion here as per @manusa suggestion.
I've not provided some reproducible code yet as it would imply pushing a container image on a shared docker registry.
The issue
I've configured the kubernetes-maven-plugin with the cacheFrom config entry in order to reuse some layers from previously produced images.
But it seems that I have to force pulling the image externally in order to have the cacheFrom image in-place and eventually reuse its layers.
Additional details
I leveraged multi-staged builds extracting layers produced by spring boot maven plugin into subfolders, so that when 3rd party deps don't change within the fatjar I reuse the old layer.
I've seen this can be achieved even on ephemeral builders (no docker cache) using cacheFrom to pass the reference to a previously built image (i.e. the image built on the previous run by the CI tool).
I've tried passing to maven CLI -Djkube.docker.imagePullPolicy=Always -Djkube.docker.autoPull=on but they seem to be inifluent, though I have no debugged so far.
OTOH I see a reuse of layers if I manually force the download of the cacheFrom image from outside maven (or even with a maven exec).
Excerpt from Dockerfile
Follows an excerpt from Dockerfile, where the various
COPY --from=builder
instructions at the bottom potentially benefit from the cacheFrom image (when locally pulled).Beta Was this translation helpful? Give feedback.
All reactions