SlideShare a Scribd company logo
Spring Boot loves k8s
September 2–3, 2020
springone.io
#session-spring-boot-loves-k8s on Slack
1
Stéphane Nicoll @snicoll
Brian Clozel @bclozel
Safe Harbor Statement
The following is intended to outline the general direction of VMware's offerings. It is intended for
information purposes only and may not be incorporated into any contract. Any information regarding
pre-release of VMware offerings, future updates or other planned modifications is subject to ongoing
evaluation by VMware and is subject to change. This information is provided without warranty or any
kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and
should not be relied upon in making purchasing decisions regarding VMware's offerings. These
purchasing decisions should only be based on features currently available. The development, release,
and timing of any features or functionality described for VMware's offerings in this presentation remain
at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this
presentation.
2
k8s implementation details
Distributed systems best practices
Natural deployment to k8s
Agenda
Showcasing Spring Boot 2.3 features during a live coding session
● The “Scribe” application
● Efficient Container images
● Liveness and Readiness
● Graceful Shutdown
● Next in Spring Boot 2.4+
6
Markdown editor with spell check
7
Markdown editor with spell check
7
Markdown editor with spell check
7
Markdown editor with spell check
7
A distributed system!
8
Scribe MarkdownConverter
● Web UI
● Spell check
● Calls Converter +
Fallback
● HTTP endpoint
● Markdown to
HTML
Efficient Container images
Very Basic Dockerfile for Java apps
10
FROM openjdk:8-jre-alpine
WORKDIR application
ARG JAR_FILE=scribe/target/scribe-*.jar
COPY ${JAR_FILE} application.jar
ENTRYPOINT ["java","-jar","application.jar"]
Layers in Container images
11
FROM … [FROM CACHE]
COPY … [FROM CACHE]
COPY … [REBUILDING]
RUN …
Layers represent changes/intermediate images (like git commits)
When rebuilding an image, layers
can be cached and reused if their
content did not change.
Optimizing Container images
12
FROM … [FROM CACHE]
COPY application.jar [REBUILDING]
Regrouping resources with similar lifecycle will improve
image build time and storage efficiency.
In our current Dockerfile, the entire
layer needs to be rebuilt for any
change in the application
https://github.com/wagoodman/dive
13
https://github.com/wagoodman/dive
13
14
Anatomy of a Spring Boot Jar
6
.
├── BOOT-INF
│   ├── classes
│   │   ├── application.properties
│   │   ├── io/spring/sample/scribe
│   │   │  ├── EditorController.class
│   │   │   ├── ScribeApplication.class
│   │   │   ├── …
│   └── lib
│   ├── bulma-0.9.0.jar
│   ├── jackson-databind-2.11.2.jar
│   ├── spring-boot-2.3.3.RELEASE.jar
14
Anatomy of a Spring Boot Jar
6
│   │   │   ├── ScribeApplication.class
│   │   │   ├── …
│   └── lib
│   ├── bulma-0.9.0.jar
│   ├── jackson-databind-2.11.2.jar
│   ├── spring-boot-2.3.3.RELEASE.jar
│   ├── …
├── META-INF
│   ├── MANIFEST.MF
│   └── spring-configuration-metadata.json
└── org/springframework/boot/loader
├── ClassPathIndexFile.class
├── JarLauncher.class
├── …
Layered container images
15
FROM …
COPY --from=builder source/snapshot-dependencies/ ./
COPY --from=builder source/spring-boot-loader/ ./
COPY --from=builder source/dependencies/ ./
Spring Boot can build efficient container images.
Developers can customize
the layer arrangement and
reorder, add their own…
Using the Maven/Gradle
build plugins.
COPY --from=builder source/application/ ./
Spring Boot + Buildpacks
No Dockerfile required!
Build locally with the CLI:
16
./mvnw spring-boot:build-image
./gradlew bootBuildImage
Also, delegate to your company’s builder instance in your build pipeline.
Cloud Native Buildpacks
With buildpacks.io, you can delegate container image building for:
• Balanced control between app devs and platform operators
• Security and compliance requirements handled in one place
• Easier maintenance/upgrades
17
What about other solutions?
Buildpacks, Dockerfiles, Jib, s2i, ko…
They have different approaches and features,
see https://buildpacks.io/features/
Choose what fits best for your team!
18
Next: Spring to image
Later today, check out the “Spring to image” session with Ben Hale.
https://springone.io/2020/sessions/spring-to-image
This session will cover Spring Boot build plugins, the pack CLI, the kpack
Kubernetes service and more!
19
Liveness and Readiness
20
Liveness and Readiness
1. New concepts supported in Spring Boot core.
2. Complement the existing application Health support in Actuator.
3.Empower developers with ApplicationAvailability.
21
Liveness and Readiness states
Liveness
“CORRECT” if the internal state of
the app is fine. External
dependencies or the service
itself might not respond
correctly still.
“BROKEN” if the internal state of
the application is broken and
restarting is the only way to fix
it.
22
Readiness
“ACCEPTING_TRAFFIC” is a way
to tell load balancers that the
app is ready to serve requests.
The app is “REFUSING_TRAFFIC”
if it considers that its load is too
high, or depending on its
lifecycle stage (starting up,
shutting down).
Liveness and Readiness Probes
Liveness and Readiness states are available as health groups.
Enabled automatically on k8s, or with the config property:
23
https://example.org/actuator/health/liveness
https://example.org/actuator/health/readiness
Probes are available here and in sync with the application lifecycle:
management.endpoint.health.probes.enabled=true
Probes as Health Groups
Liveness and readiness probes are using the Health Groups feature.
You can configure additional checks to a probe:
24
management.endpoint.health.group.readiness.include=readinessState,customCheck
⚠ You should be careful about checking for external state in probes.
ApplicationAvailability
25
@Component
public class LocalCacheVerifier {
private final ApplicationEventPublisher eventPublisher;
public void checkLocalCache() {
try { //...
} catch (CacheCompletelyBrokenException ex) {
AvailabilityChangeEvent.publish(this.eventPublisher, ex, LivenessState.BROKEN);
}
}
} // see more in reference docs
Graceful Shutdown
26
Shutting down app with active requests
27
Scribe
MarkdownConverter
MarkdownConverter
MarkdownConverter
HTTP POST /convert
1. Processing…
Shutting down app with active requests
27
Scribe
MarkdownConverter
MarkdownConverter
MarkdownConverter
HTTP POST /convert
1. Processing…
2. Shutdown!
Graceful Shutdown
28
Scribe
MarkdownConverter
HTTP POST /convert
1. Processing…
MarkdownConverter
MarkdownConverter
Graceful Shutdown
28
Scribe
MarkdownConverter
HTTP POST /convert
1. Processing…
2. Stop accepting
MarkdownConverter
MarkdownConverter
Graceful Shutdown
28
Scribe
MarkdownConverter
HTTP POST /convert
1. Processing…
3. Done
2. Stop accepting
MarkdownConverter
MarkdownConverter
Graceful Shutdown
28
Scribe
MarkdownConverter
HTTP POST /convert
1. Processing…
3. Done
2. Stop accepting
MarkdownConverter
MarkdownConverter
4.Shutdown!
Configuring Graceful Shutdown
Enabling Graceful Shutdown and configuring the grace period:
29
server.shutdown=graceful
spring.lifecycle.timeout-per-shutdown-phase=20s
Next in Spring Boot 2.4+
30
Config file processing
Volume mounted configuration trees, multi-document properties files,
profile groups, etc. See config file processing blog post.
31
spring.config.activate.on-cloud-platform=kubernetes
spring.config.import=configtree:/etc/config
spring.config.activate.on-cloud-platform=kubernetes
spring.config.import=configtree:/etc/config
spring.config.activate.on-cloud-platform=kubernetes
spring.config.import=configtree:/etc/config
spring.config.activate.on-cloud-platform=kubernetes
spring.config.import=configtree:/etc/config
spring.config.activate.on-cloud-platform=kubernetes
spring.config.import=configtree:/etc/config
etc/
+- config/
+- my/
| +- application
+- test
Graceful shutdown improvements
The team is considering adding a shutdown delay option because most
platforms still route traffic to while routing state is converging.
Currently you can use a PreStop hook to delay the shutdown sequence.
32
Layered JARs enabled by default
As of 2.4.0, Spring Boot JARs will ship with the layers.idx by default.
Useful metadata for tools in your CI/CD pipeline.
33
Stay Connected.
Q&A #session-spring-boot-loves-k8s on Slack
“Spring to Image” session with Ben Hale
Slides and code:
https://springone.io/2020/sessions/spring-boot-loves-k8s
https://github.com/snicoll/spring-boot-loves-k8s
#springone@s1p

More Related Content

What's hot (20)

PDF
The Path Towards Spring Boot Native Applications
VMware Tanzu
 
PDF
What’s New in Spring Data MongoDB
VMware Tanzu
 
PPTX
State of Steeltoe 2020
VMware Tanzu
 
PDF
What Is Spring?
VMware Tanzu
 
PDF
Developers Are Users, Too
VMware Tanzu
 
PDF
Full Steam Ahead, R2DBC!
VMware Tanzu
 
PDF
Spring: Your Next Java Micro-Framework
VMware Tanzu
 
PDF
Not Just Initializing
VMware Tanzu
 
PDF
Accelerate Spring Apps to Cloud at Scale
Asir Selvasingh
 
PDF
Fundamental Spring Boot: Keep it Simple, Get it Right, Be Productive and Have...
VMware Tanzu
 
PDF
Spring Data JDBC: Beyond the Obvious
VMware Tanzu
 
PDF
PKS: The What and How of Enterprise-Grade Kubernetes
VMware Tanzu
 
PPTX
Bulletproof Microservices with Spring and Kubernetes
VMware Tanzu
 
PDF
DevOps KPIs as a Service: Daimler’s Solution
VMware Tanzu
 
PDF
Next-Generation Cloud Native Apps with Spring Cloud and Kubernetes
VMware Tanzu
 
PDF
Spring to Image
VMware Tanzu
 
PDF
From Monolith to K8s - Spring One 2020
Mauricio (Salaboy) Salatino
 
PDF
Spring Tools 4: Bootiful Spring Tooling for the Masses
VMware Tanzu
 
PDF
Delivering Essentials for Albertsons: VMware TAS’s Critical Role During the C...
VMware Tanzu
 
PDF
VMware Tanzu Introduction- June 11, 2020
VMware Tanzu
 
The Path Towards Spring Boot Native Applications
VMware Tanzu
 
What’s New in Spring Data MongoDB
VMware Tanzu
 
State of Steeltoe 2020
VMware Tanzu
 
What Is Spring?
VMware Tanzu
 
Developers Are Users, Too
VMware Tanzu
 
Full Steam Ahead, R2DBC!
VMware Tanzu
 
Spring: Your Next Java Micro-Framework
VMware Tanzu
 
Not Just Initializing
VMware Tanzu
 
Accelerate Spring Apps to Cloud at Scale
Asir Selvasingh
 
Fundamental Spring Boot: Keep it Simple, Get it Right, Be Productive and Have...
VMware Tanzu
 
Spring Data JDBC: Beyond the Obvious
VMware Tanzu
 
PKS: The What and How of Enterprise-Grade Kubernetes
VMware Tanzu
 
Bulletproof Microservices with Spring and Kubernetes
VMware Tanzu
 
DevOps KPIs as a Service: Daimler’s Solution
VMware Tanzu
 
Next-Generation Cloud Native Apps with Spring Cloud and Kubernetes
VMware Tanzu
 
Spring to Image
VMware Tanzu
 
From Monolith to K8s - Spring One 2020
Mauricio (Salaboy) Salatino
 
Spring Tools 4: Bootiful Spring Tooling for the Masses
VMware Tanzu
 
Delivering Essentials for Albertsons: VMware TAS’s Critical Role During the C...
VMware Tanzu
 
VMware Tanzu Introduction- June 11, 2020
VMware Tanzu
 

Similar to Spring Boot Loves K8s (20)

PDF
Part 4: Custom Buildpacks and Data Services (Pivotal Cloud Platform Roadshow)
VMware Tanzu
 
PDF
Spring Native and Spring AOT
VMware Tanzu
 
PPTX
Jenkins advance topic
Kalkey
 
PDF
Spring Boot - Microservice Metrics Monitoring
DonghuKIM2
 
PDF
Spring boot microservice metrics monitoring
Oracle Korea
 
PDF
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld
 
PDF
給 RD 的 Kubernetes 初體驗
William Yeh
 
PDF
Pivotal Platform - December Release A First Look
VMware Tanzu
 
PPTX
JOIN 2022: Patching 3rd party software Like a boss
Pieter Vincken
 
PDF
2015 JavaOne LAD JSF 2.3 & MVC 1.0
mnriem
 
PDF
Extending Kubernetes with Operators
peychevi
 
PDF
A Deep Dive into the Liberty Buildpack on IBM BlueMix
Rohit Kelapure
 
PDF
You've Made Kubernetes Available to Your Developers, Now What?
cornelia davis
 
PPTX
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
Oleg Shalygin
 
PDF
Whats new in Enterprise 5.0 Product Suite
Micro Focus
 
PPTX
Kubernetes for the VI Admin
Kendrick Coleman
 
PDF
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Codemotion
 
PDF
Technology Primer: Closing the DevOps Loop by Integrating CA Application Perf...
CA Technologies
 
PDF
HDinsight Workshop - Prerequisite Activity
Idan Tohami
 
PPTX
Run Stateful Apps on Kubernetes with VMware PKS - Highlight WebLogic Server
Simone Morellato
 
Part 4: Custom Buildpacks and Data Services (Pivotal Cloud Platform Roadshow)
VMware Tanzu
 
Spring Native and Spring AOT
VMware Tanzu
 
Jenkins advance topic
Kalkey
 
Spring Boot - Microservice Metrics Monitoring
DonghuKIM2
 
Spring boot microservice metrics monitoring
Oracle Korea
 
VMworld Europe 2014: A DevOps Story - Unlocking the Power of Docker with the ...
VMworld
 
給 RD 的 Kubernetes 初體驗
William Yeh
 
Pivotal Platform - December Release A First Look
VMware Tanzu
 
JOIN 2022: Patching 3rd party software Like a boss
Pieter Vincken
 
2015 JavaOne LAD JSF 2.3 & MVC 1.0
mnriem
 
Extending Kubernetes with Operators
peychevi
 
A Deep Dive into the Liberty Buildpack on IBM BlueMix
Rohit Kelapure
 
You've Made Kubernetes Available to Your Developers, Now What?
cornelia davis
 
GCP - Continuous Integration and Delivery into Kubernetes with GitHub, Travis...
Oleg Shalygin
 
Whats new in Enterprise 5.0 Product Suite
Micro Focus
 
Kubernetes for the VI Admin
Kendrick Coleman
 
Salvatore Incandela, Fabio Marinelli - Using Spinnaker to Create a Developmen...
Codemotion
 
Technology Primer: Closing the DevOps Loop by Integrating CA Application Perf...
CA Technologies
 
HDinsight Workshop - Prerequisite Activity
Idan Tohami
 
Run Stateful Apps on Kubernetes with VMware PKS - Highlight WebLogic Server
Simone Morellato
 
Ad

More from VMware Tanzu (20)

PDF
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
PDF
What AI Means For Your Product Strategy And What To Do About It
VMware Tanzu
 
PDF
Make the Right Thing the Obvious Thing at Cardinal Health 2023
VMware Tanzu
 
PPTX
Enhancing DevEx and Simplifying Operations at Scale
VMware Tanzu
 
PDF
Spring Update | July 2023
VMware Tanzu
 
PPTX
Platforms, Platform Engineering, & Platform as a Product
VMware Tanzu
 
PPTX
Building Cloud Ready Apps
VMware Tanzu
 
PDF
Spring Boot 3 And Beyond
VMware Tanzu
 
PDF
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
VMware Tanzu
 
PPTX
tanzu_developer_connect.pptx
VMware Tanzu
 
PDF
Tanzu Virtual Developer Connect Workshop - French
VMware Tanzu
 
PDF
Tanzu Developer Connect Workshop - English
VMware Tanzu
 
PDF
Virtual Developer Connect Workshop - English
VMware Tanzu
 
PDF
Tanzu Developer Connect - French
VMware Tanzu
 
PDF
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
VMware Tanzu
 
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
PDF
SpringOne Tour: The Influential Software Engineer
VMware Tanzu
 
PDF
SpringOne Tour: Domain-Driven Design: Theory vs Practice
VMware Tanzu
 
Spring into AI presented by Dan Vega 5/14
VMware Tanzu
 
What AI Means For Your Product Strategy And What To Do About It
VMware Tanzu
 
Make the Right Thing the Obvious Thing at Cardinal Health 2023
VMware Tanzu
 
Enhancing DevEx and Simplifying Operations at Scale
VMware Tanzu
 
Spring Update | July 2023
VMware Tanzu
 
Platforms, Platform Engineering, & Platform as a Product
VMware Tanzu
 
Building Cloud Ready Apps
VMware Tanzu
 
Spring Boot 3 And Beyond
VMware Tanzu
 
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
VMware Tanzu
 
tanzu_developer_connect.pptx
VMware Tanzu
 
Tanzu Virtual Developer Connect Workshop - French
VMware Tanzu
 
Tanzu Developer Connect Workshop - English
VMware Tanzu
 
Virtual Developer Connect Workshop - English
VMware Tanzu
 
Tanzu Developer Connect - French
VMware Tanzu
 
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
VMware Tanzu
 
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
VMware Tanzu
 
SpringOne Tour: The Influential Software Engineer
VMware Tanzu
 
SpringOne Tour: Domain-Driven Design: Theory vs Practice
VMware Tanzu
 
Ad

Recently uploaded (20)

PDF
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
PPTX
Presentation about variables and constant.pptx
kr2589474
 
PDF
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
PDF
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
PDF
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
PDF
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
PPTX
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
PPTX
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
PDF
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
PPT
Brief History of Python by Learning Python in three hours
adanechb21
 
PPTX
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
PDF
Protecting the Digital World Cyber Securit
dnthakkar16
 
PDF
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
PDF
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
PDF
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
PDF
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
PPTX
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
PDF
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
PDF
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
PDF
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 
How Agentic AI Networks are Revolutionizing Collaborative AI Ecosystems in 2025
ronakdubey419
 
Presentation about variables and constant.pptx
kr2589474
 
Step-by-Step Guide to Install SAP HANA Studio | Complete Installation Tutoria...
SAP Vista, an A L T Z E N Company
 
Salesforce Pricing Update 2025: Impact, Strategy & Smart Cost Optimization wi...
GetOnCRM Solutions
 
SAP GUI Installation Guide for macOS (iOS) | Connect to SAP Systems on Mac
SAP Vista, an A L T Z E N Company
 
Enhancing Healthcare RPM Platforms with Contextual AI Integration
Cadabra Studio
 
Contractor Management Platform and Software Solution for Compliance
SHEQ Network Limited
 
Web Testing.pptx528278vshbuqffqhhqiwnwuq
studylike474
 
Generating Union types w/ Static Analysis
K. Matthew Dupree
 
Brief History of Python by Learning Python in three hours
adanechb21
 
TRAVEL APIs | WHITE LABEL TRAVEL API | TOP TRAVEL APIs
philipnathen82
 
Protecting the Digital World Cyber Securit
dnthakkar16
 
Why Are More Businesses Choosing Partners Over Freelancers for Salesforce.pdf
Cymetrix Software
 
Infrastructure planning and resilience - Keith Hastings.pptx.pdf
Safe Software
 
ChatPharo: an Open Architecture for Understanding How to Talk Live to LLMs
ESUG
 
Salesforce Implementation Services Provider.pdf
VALiNTRY360
 
Farrell__10e_ch04_PowerPoint.pptx Programming Logic and Design slides
bashnahara11
 
Enhancing Security in VAST: Towards Static Vulnerability Scanning
ESUG
 
MiniTool Power Data Recovery Crack New Pre Activated Version Latest 2025
imang66g
 
Using licensed Data Loss Prevention (DLP) as a strategic proactive data secur...
Q-Advise
 

Spring Boot Loves K8s

  • 1. Spring Boot loves k8s September 2–3, 2020 springone.io #session-spring-boot-loves-k8s on Slack 1 Stéphane Nicoll @snicoll Brian Clozel @bclozel
  • 2. Safe Harbor Statement The following is intended to outline the general direction of VMware's offerings. It is intended for information purposes only and may not be incorporated into any contract. Any information regarding pre-release of VMware offerings, future updates or other planned modifications is subject to ongoing evaluation by VMware and is subject to change. This information is provided without warranty or any kind, express or implied, and is not a commitment to deliver any material, code, or functionality, and should not be relied upon in making purchasing decisions regarding VMware's offerings. These purchasing decisions should only be based on features currently available. The development, release, and timing of any features or functionality described for VMware's offerings in this presentation remain at the sole discretion of Pivotal. Pivotal has no obligation to update forward looking information in this presentation. 2
  • 6. Agenda Showcasing Spring Boot 2.3 features during a live coding session ● The “Scribe” application ● Efficient Container images ● Liveness and Readiness ● Graceful Shutdown ● Next in Spring Boot 2.4+ 6
  • 7. Markdown editor with spell check 7
  • 8. Markdown editor with spell check 7
  • 9. Markdown editor with spell check 7
  • 10. Markdown editor with spell check 7
  • 11. A distributed system! 8 Scribe MarkdownConverter ● Web UI ● Spell check ● Calls Converter + Fallback ● HTTP endpoint ● Markdown to HTML
  • 13. Very Basic Dockerfile for Java apps 10 FROM openjdk:8-jre-alpine WORKDIR application ARG JAR_FILE=scribe/target/scribe-*.jar COPY ${JAR_FILE} application.jar ENTRYPOINT ["java","-jar","application.jar"]
  • 14. Layers in Container images 11 FROM … [FROM CACHE] COPY … [FROM CACHE] COPY … [REBUILDING] RUN … Layers represent changes/intermediate images (like git commits) When rebuilding an image, layers can be cached and reused if their content did not change.
  • 15. Optimizing Container images 12 FROM … [FROM CACHE] COPY application.jar [REBUILDING] Regrouping resources with similar lifecycle will improve image build time and storage efficiency. In our current Dockerfile, the entire layer needs to be rebuilt for any change in the application
  • 18. 14 Anatomy of a Spring Boot Jar 6 . ├── BOOT-INF │   ├── classes │   │   ├── application.properties │   │   ├── io/spring/sample/scribe │   │   │  ├── EditorController.class │   │   │   ├── ScribeApplication.class │   │   │   ├── … │   └── lib │   ├── bulma-0.9.0.jar │   ├── jackson-databind-2.11.2.jar │   ├── spring-boot-2.3.3.RELEASE.jar
  • 19. 14 Anatomy of a Spring Boot Jar 6 │   │   │   ├── ScribeApplication.class │   │   │   ├── … │   └── lib │   ├── bulma-0.9.0.jar │   ├── jackson-databind-2.11.2.jar │   ├── spring-boot-2.3.3.RELEASE.jar │   ├── … ├── META-INF │   ├── MANIFEST.MF │   └── spring-configuration-metadata.json └── org/springframework/boot/loader ├── ClassPathIndexFile.class ├── JarLauncher.class ├── …
  • 20. Layered container images 15 FROM … COPY --from=builder source/snapshot-dependencies/ ./ COPY --from=builder source/spring-boot-loader/ ./ COPY --from=builder source/dependencies/ ./ Spring Boot can build efficient container images. Developers can customize the layer arrangement and reorder, add their own… Using the Maven/Gradle build plugins. COPY --from=builder source/application/ ./
  • 21. Spring Boot + Buildpacks No Dockerfile required! Build locally with the CLI: 16 ./mvnw spring-boot:build-image ./gradlew bootBuildImage Also, delegate to your company’s builder instance in your build pipeline.
  • 22. Cloud Native Buildpacks With buildpacks.io, you can delegate container image building for: • Balanced control between app devs and platform operators • Security and compliance requirements handled in one place • Easier maintenance/upgrades 17
  • 23. What about other solutions? Buildpacks, Dockerfiles, Jib, s2i, ko… They have different approaches and features, see https://buildpacks.io/features/ Choose what fits best for your team! 18
  • 24. Next: Spring to image Later today, check out the “Spring to image” session with Ben Hale. https://springone.io/2020/sessions/spring-to-image This session will cover Spring Boot build plugins, the pack CLI, the kpack Kubernetes service and more! 19
  • 26. Liveness and Readiness 1. New concepts supported in Spring Boot core. 2. Complement the existing application Health support in Actuator. 3.Empower developers with ApplicationAvailability. 21
  • 27. Liveness and Readiness states Liveness “CORRECT” if the internal state of the app is fine. External dependencies or the service itself might not respond correctly still. “BROKEN” if the internal state of the application is broken and restarting is the only way to fix it. 22 Readiness “ACCEPTING_TRAFFIC” is a way to tell load balancers that the app is ready to serve requests. The app is “REFUSING_TRAFFIC” if it considers that its load is too high, or depending on its lifecycle stage (starting up, shutting down).
  • 28. Liveness and Readiness Probes Liveness and Readiness states are available as health groups. Enabled automatically on k8s, or with the config property: 23 https://example.org/actuator/health/liveness https://example.org/actuator/health/readiness Probes are available here and in sync with the application lifecycle: management.endpoint.health.probes.enabled=true
  • 29. Probes as Health Groups Liveness and readiness probes are using the Health Groups feature. You can configure additional checks to a probe: 24 management.endpoint.health.group.readiness.include=readinessState,customCheck ⚠ You should be careful about checking for external state in probes.
  • 30. ApplicationAvailability 25 @Component public class LocalCacheVerifier { private final ApplicationEventPublisher eventPublisher; public void checkLocalCache() { try { //... } catch (CacheCompletelyBrokenException ex) { AvailabilityChangeEvent.publish(this.eventPublisher, ex, LivenessState.BROKEN); } } } // see more in reference docs
  • 32. Shutting down app with active requests 27 Scribe MarkdownConverter MarkdownConverter MarkdownConverter HTTP POST /convert 1. Processing…
  • 33. Shutting down app with active requests 27 Scribe MarkdownConverter MarkdownConverter MarkdownConverter HTTP POST /convert 1. Processing… 2. Shutdown!
  • 34. Graceful Shutdown 28 Scribe MarkdownConverter HTTP POST /convert 1. Processing… MarkdownConverter MarkdownConverter
  • 35. Graceful Shutdown 28 Scribe MarkdownConverter HTTP POST /convert 1. Processing… 2. Stop accepting MarkdownConverter MarkdownConverter
  • 36. Graceful Shutdown 28 Scribe MarkdownConverter HTTP POST /convert 1. Processing… 3. Done 2. Stop accepting MarkdownConverter MarkdownConverter
  • 37. Graceful Shutdown 28 Scribe MarkdownConverter HTTP POST /convert 1. Processing… 3. Done 2. Stop accepting MarkdownConverter MarkdownConverter 4.Shutdown!
  • 38. Configuring Graceful Shutdown Enabling Graceful Shutdown and configuring the grace period: 29 server.shutdown=graceful spring.lifecycle.timeout-per-shutdown-phase=20s
  • 39. Next in Spring Boot 2.4+ 30
  • 40. Config file processing Volume mounted configuration trees, multi-document properties files, profile groups, etc. See config file processing blog post. 31 spring.config.activate.on-cloud-platform=kubernetes spring.config.import=configtree:/etc/config spring.config.activate.on-cloud-platform=kubernetes spring.config.import=configtree:/etc/config spring.config.activate.on-cloud-platform=kubernetes spring.config.import=configtree:/etc/config spring.config.activate.on-cloud-platform=kubernetes spring.config.import=configtree:/etc/config spring.config.activate.on-cloud-platform=kubernetes spring.config.import=configtree:/etc/config etc/ +- config/ +- my/ | +- application +- test
  • 41. Graceful shutdown improvements The team is considering adding a shutdown delay option because most platforms still route traffic to while routing state is converging. Currently you can use a PreStop hook to delay the shutdown sequence. 32
  • 42. Layered JARs enabled by default As of 2.4.0, Spring Boot JARs will ship with the layers.idx by default. Useful metadata for tools in your CI/CD pipeline. 33
  • 43. Stay Connected. Q&A #session-spring-boot-loves-k8s on Slack “Spring to Image” session with Ben Hale Slides and code: https://springone.io/2020/sessions/spring-boot-loves-k8s https://github.com/snicoll/spring-boot-loves-k8s #springone@s1p