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

jib builder #1656

Closed
lburgazzoli opened this issue Aug 11, 2020 · 13 comments
Closed

jib builder #1656

lburgazzoli opened this issue Aug 11, 2020 · 13 comments

Comments

@lburgazzoli
Copy link
Contributor

Evaluate to use jib [1] as a builder strategy and eventually leverage its plug-in extension mechanism [2]

[1] https://github.com/GoogleContainerTools/jib
[2] https://cloud.google.com/blog/products/application-development/using-jib-to-containerize-java-apps

@lburgazzoli lburgazzoli added the area/build-operator Related to the internal image build operator label Aug 11, 2020
@lburgazzoli
Copy link
Contributor Author

/cc @astefanutti

@github-actions
Copy link
Contributor

This issue has been automatically marked as stale due to 90 days of inactivity.
It will be closed if no further activity occurs within 15 days.
If you think that’s incorrect or the issue should never stale, please simply write any comment.
Thanks for your contributions!

@lburgazzoli
Copy link
Contributor Author

I think it would be nice to consolidate on jib (except of s2i probably) and get rid of the other build strategies mentioned here: #3336

@squakez
Copy link
Contributor

squakez commented Jun 6, 2022

Would it make sense to target for a 2.0 version? It looks like we won't be able to maintain compatibility (at least, not that easily) if we switch to something new.

@lburgazzoli
Copy link
Contributor Author

Yes for 2.x

@squakez
Copy link
Contributor

squakez commented Feb 2, 2023

Something else we want to consider is to support multi-architecture via JIB: see #1238

@gansheer
Copy link
Contributor

gansheer commented Feb 15, 2023

I spent some time getting to know the existing JIB plugins available.

The ones I found and tested are:

I did some build test using the following requirements :

  • build a container image containing the content from the /tmp/kit-xxxxxx-yyyyy/context instead of the default target folder ( /tmp/kit-xxxxxx-yyyyy/maven/target)
  • build incrementally the container images between multiple integration kits by having some influence on layer build
  • build the container image for different architectures (linux/am64, linux/arm64, etc)
  • producing a container image the most similar than the one produced by spectrum

The native build still needs to be tested but in the context of container image build is it also about a runner being made available in /tmp/kit-xxxxxx-yyyyy/context after the build phase, so it should be covered but the requirements.

I put all my data here : https://github.com/gansheer/jib-work

Only two of the tested plugins validate all the requirements : Jib maven plugin and Fabric8 docker plugin. Seeing the Fabric8 docker plugin's version is 0.41.0, I feel the Jib maven plugin is the best choice.

The Jkube Kubernetes Plugin is still a good candidate if it can add the multi-architecture support. I found it offers a lot of flexibility and also come with a Jkube Openshift Plugin built on top of Kubernetes Plugin that has s2i features.

What I see as an implementation roadmap for the addition of a jib publish strategy would be:

  • implement a first version using the Jib maven plugin while discussing with the jkube projet to see if the multi-architecture can be added
  • if (and hopefully when) the Jkube Kubernetes Plugin provides the multi-architecure feature, plan a migration to the JKube plugin

Last notes:

Please don't hesitate to tell me your opinions on this and any additional inputs.

cc @lburgazzoli @astefanutti @oscerd @claudio4j @christophd @tadayosi

@squakez
Copy link
Contributor

squakez commented Feb 15, 2023

Great analysis. I think that eventually JIB and JKube may coexist if we manage to have enough resources to support both. For the time being we could start with JIB implementation IMO.

@gansheer
Copy link
Contributor

I am trying to understand the reason behind some code designs. This is partially related to the #4024 discussion.

From what I can see the effective build code consist of 2 Tasks: a BuildTask and a PublishTask. The BuildTask itself contains many Steps separated in 5 phases:

  • InitPhase
  • ProjectGenerationPhase
  • ProjectBuildPhase
  • ApplicationPackagePhase
  • ApplicationPublishPhase

Camel-k build flow

I want to find a right way to add the maven command for the Jib build in the new Publish strategy. From the current code, I don't get the information about the build maven command already generated by the build task (passed through the steps in the builderContext), that leaves me 3 choices (that I can see):

  • generate it again as it was done in build code
  • create a BuilderTask Step instead of a publish task
  • find a way to communicate it from the build task to the publish task

Before making any design choice I would like to understand the following points:

  • Why has the code been separated in 2 Tasks ? Is there a technical reason why the PublishTask code is not a BuilderTask Step ?
  • Is there a purpose to the presence of the ApplicationPublishPhase or is it some dead code ? There is no step associated to it.
  • What are the possible way to pass information from a Task to another (here the BuilderTask to the PublishTask) ? There might some possibility in the CRs, but I can't see it.

I would really like your opinions and any input that could help me avoid any known pitfall.

cc @squakez @claudio4j @christophd @lburgazzoli @astefanutti @oscerd @tadayosi

@squakez
Copy link
Contributor

squakez commented Mar 21, 2023

@gansheer I don't have the full historical context to answer, but from what I've experimented in the past, the best approach is to go in iterations and make live past and new approaches for a short period of time. IMO, you can keep the "build" part the way it is now (we may rework this part in #4024). The "publish" part with the JIB strategy may be overlapping what we're already doing in the "build". What I think you could do is not to worry at this stage. I think you should consider the input coming from the build part (ie, the Maven project in a given directory), then, you should "decorate" it with the configuration required by JIB (ie, adding plugin and registry configuration). Finally you can run, again, a maven command but through the JIB plugin this time. Hope it helps.

@gansheer
Copy link
Contributor

Thank for you input @squakez .

To explain the technical code problem. The maven command expect the following informations:

  • GlobalSettings: KO computed by BuildTask
  • UserSettings: KO computed by BuildTask
  • SettingsSecurity: KO computed by BuildTask
  • ExtraMavenOpts: KO computed by BuildTask (mainly Truststore)
  • LocalRepository: OK since available from ip through localRepository
  • AdditionalArguments : Partially available from ip through cliOptions
  • AdditionalEntries: can't see any code using this one.

type Context struct {
Path string
ExtraMavenOpts []string
GlobalSettings []byte
UserSettings []byte
SettingsSecurity []byte
AdditionalArguments []string
AdditionalEntries map[string]interface{}
LocalRepository string
}

Just to be clear : your advice is to only take what is in the /tmps/kit-xxxxxx directory by principle and ignore what is computed in the build task ?

@squakez
Copy link
Contributor

squakez commented Mar 21, 2023

So, what you're trying to do is to unmarshal what the "build" has provided before. IMO we could avoid that step and instead change the configuration structure on the directory files. Basically it would be a very low level "publisher" whose goal is to parse the pom xml, add some configuration with some raw editor, save it back and run the mvn compile accordingly.

@squakez squakez added area/builder and removed area/build-operator Related to the internal image build operator labels Mar 24, 2023
gansheer added a commit to gansheer/camel-k that referenced this issue Jun 7, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Jun 7, 2023
* Add publish jib strategy
* Use google jib plugin
@squakez squakez modified the milestones: 2.0.0, 2.1.0 Jul 27, 2023
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 16, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy
* Use google jib plugin
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 21, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 22, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 22, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 22, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 23, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 24, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 25, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Manage container layers in generated image
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 25, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Use builder maven profiles trait to configure jib plugin
 * The ConfigMap is created with:
   * maven jib plugin profile content in profile.xml
   * kit as an owner
 * The Jib Profile is used in the Jib published strategy
gansheer added a commit to gansheer/camel-k that referenced this issue Aug 25, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Use builder maven profiles trait to configure jib plugin
 * The ConfigMap is created with:
   * maven jib plugin profile content in profile.xml
   * kit as an owner
 * The Jib Profile is used in the Jib published strategy
squakez pushed a commit that referenced this issue Aug 30, 2023
* Add publish jib strategy compatible with incremental build and native build
* Use google jib maven plugin
* Use builder maven profiles trait to configure jib plugin
 * The ConfigMap is created with:
   * maven jib plugin profile content in profile.xml
   * kit as an owner
 * The Jib Profile is used in the Jib published strategy
@squakez
Copy link
Contributor

squakez commented Aug 30, 2023

Closed by #4680

@squakez squakez closed this as completed Aug 30, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants