-
Notifications
You must be signed in to change notification settings - Fork 40.6k
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
Document how to provide runtime JVM arguments when building an image #21478
Comments
As I understand, I also have the same question as yours. I want to pass some environment variables to my application image. I've checked Paketo buildpacks web site and it doesn't seem to have the information I need. I'd suggest to improve the plugin document to give an example how to include environment variables into the OCI images. |
That's correct. We'll research how to get environment variables passed to the JVM in the built image. |
After discussions with the Cloud Native Buildpacks team, there currently isn't a way to pass environment variables to a builder and request that the builder set the variable in the resulting image. In order to support this, CNB builder clients like the As an alternative to setting something like
|
@scottfrederick do you have a reference on CNB for this feature request? Thank you |
There's not an issue opened with CNB or Paketo for this feature yet, but you can join the discussion in the Paketo slack. |
what if we deploy the images in something like hashi corp Nomad? Any tricks for passing jvm options there? |
@bmd007 The Paketo documentation now has information on passing arguments run running an app in an image. See https://paketo.io/docs/buildpacks/language-family-buildpacks/java/. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements. This is a question that would be better suited to Stack Overflow. |
I think it's now possible to burn runtime arguments into the JVM at build time. Via @ekcasey, the environment variables buildpack can be used like this:
We should try it out and perhaps make some documentation updates if it works as hoped. |
There is an open issue to document the environment variables buildpack on the Paketo documentation site. Once this is done, the Spring Boot documentation should link to this Paketo documentation and embellish it with examples of setting |
Thanks for the pointers. I used the following options:
And it works well:
|
Near as I can tell, this doesn't actually work for other general image environment variables does it?
|
@kulack The Paketo environment variables buildpack will get that configuration, and it's up to the buildpack to decide what to do with it. |
Yeah, I had tried both DEFAULT and OVERRIDE and wasn't having great luck. I'll dig into see what the build pack actually does. |
Passing the JVM parameters to your Spring boot-based application doesn't help directly and does not reflect with your applications deployment configuration if you are using docker/Opensift/Kubernetes based platform. You need to the he following changes bypassing the parameters through the environment variable if S2I or by setting these parameters in deployment.yaml file through jenkins pipeline.
spec:
Note: After deploying your service over OpenShift/Kernates validate the deployment configuration file(deployment.yml) for these parameters. In case not not reflecting then delete your pods completly and reploy the application. You can follow this link to get more detail on it. [https://facingissuesonit.com/2021/10/23/openshift-metaspace-issue-with-springboot-based-micro-services/] |
Hi
I'm using Spring Boot 2.3.0 and JDK 14.0.1 and want to pack my application using new buildpack feature in Spring Boot Maven plugin.
Since I use preview features I have to add "--enable-preview" flag as JVM argument (JAVA_OPTS environment variable).
So here's my Spring Boot Maven plugin configuration:
Docker image is built successfully but container fails to start with exception:
Exception in thread "main" java.lang.UnsupportedClassVersionError: Preview features are not enabled for demo/Application (class file version 58.65535). Try running with '--enable-preview'
And resulting JAVA_OPTS environment variable in the image is missing my argument:
-Djava.security.properties=/layers/paketo-buildpacks_bellsoft-liberica/java-security-properties/java-security.properties -agentpath:/layers/paketo-buildpacks_bellsoft-liberica/jvmkill/jvmkill-1.16.0-RELEASE.so=printHeapHistogram=1 -XX:ActiveProcessorCount=2 -XX:MaxDirectMemorySize=10M -XX:MaxMetaspaceSize=104953K -XX:ReservedCodeCacheSize=240M -Xss1M -Xmx431622K -Dio.paketo.openssl.ca-certificates=/etc/ssl/certs/ca-certificates.crt
The text was updated successfully, but these errors were encountered: