How to manage custom common libraries built in maven for my Application in kubernetes How to manage custom common libraries built in maven for my Application in kubernetes kubernetes kubernetes

How to manage custom common libraries built in maven for my Application in kubernetes


The images that you use to build the containers that run on Kubernetes should contain everything that's needed to run the application.

When you create the JAR file for your application, this JAR should contain the dependencies. There are different ways to achieve this, using both Maven or Gradle. This is an example using Maven and its Apache Maven Assembly Plugin. This is another good user guide on how to achieve it.

Then, you need to create a container image that can run that JAR file, something like

FROM openjdk:8-jdk-alpineEXPOSE 8080WORKDIR /opt/appCMD ["java", "-jar", "app.jar"]COPY build/libs/app.jar /opt/app

Once this container image is published on a registry, whenever Kubernetes needs to schedule and create a container, it will just use that image: there is no need to re-compile the application and its dependencies.