Madhura Bhave at SpringOne 2020

VMware Tanzu
VMware TanzuVMware Tanzu
Confidential │ ©2020 VMware, Inc.
Madhura Bhave
The New Center of the Universe
Spring Boot ♥ Kubernetes
©2020 VMware, Inc.
Center of the Universe
©2020 VMware, Inc.
Unit of DeploymentCenter of the JVM Universe
©2020 VMware, Inc.
👩💻 🧑💻
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
01
02
03
04
05
06
07
$ mvn package
©2020 VMware, Inc.
$ java -jar application.jar
©2020 VMware, Inc.
The only constant is change
©2020 VMware, Inc.
👩💻 🧑💻
🤔
©2020 VMware, Inc.
©2020 VMware, Inc.
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/my-application.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
01
02
03
04
05
©2020 VMware, Inc.
👩💻 🧑💻
$ docker build .
FROM openjdk:8-jdk-alpine
EXPOSE 8080
ARG JAR_FILE=target/my-application.jar
ADD ${JAR_FILE} app.jar
ENTRYPOINT ["java","-jar","/app.jar"]
01
02
03
04
05
©2020 VMware, Inc.
my-application.jar
JDK
OS
©2020 VMware, Inc.
my-application.jar
JDK
OS
Fat jar overhead
Single layer for jar
Not optimal
©2020 VMware, Inc.
Application
Snapshot Dependencies
OS
Spring Boot Loader
Dependencies
JDK
©2020 VMware, Inc.
FROM adoptopenjdk:11-jre-hotspot as builder
WORKDIR application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM adoptopenjdk:11-jre-hotspot
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
2.3
layertools
©2020 VMware, Inc.
FROM adoptopenjdk:11-jre-hotspot as builder
WORKDIR application
ARG JAR_FILE=target/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract
FROM adoptopenjdk:11-jre-hotspot
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
COPY --from=builder application/snapshot-dependencies/ ./
COPY --from=builder application/application/ ./
ENTRYPOINT ["java", "org.springframework.boot.loader.JarLauncher"]
2.3
layertools
layers.idx
custom layers
©2020 VMware, Inc.
©2020 VMware, Inc.
👩💻 🧑💻 Is this another tool I need to learn about?
Not really 😃
©2020 VMware, Inc.
♥
2.3
layers.idx
custom layers
$ mvn spring-boot:build-image
©2020 VMware, Inc.
Journey to Production
2.3
Graceful Shutdown
Health Checks
/actuator/liveness 🔮
ConfigMaps and Secrets
🚀
/actuator/readiness
2.4
©2020 VMware, Inc.
2.3
©2020 VMware, Inc.
Spring Boot loves K8s
👩💻 🧑💻
🤔
Stephane Nicoll
Brian Clozel
1 of 21

More Related Content

Madhura Bhave at SpringOne 2020