Upgrade to PRO for Only $50/Year—Limited-Time Offer! 🔥

Cloud Native with Spring Boot and Kubernetes

Thomas Vitale
November 01, 2021

Cloud Native with Spring Boot and Kubernetes

The Spring ecosystem provides you with all you need to build cloud native applications, focusing on productivity, simplicity and speed. It’s ready to leverage cloud environment features and integrates with Kubernetes natively. In this session, I’ll cover common patterns and best practices to build cloud native applications using Reactive Spring, which provides better performance, resilience, and efficiency. You’ll then see how to containerize them, configure them through the natively supported ConfigMaps and Secrets, and deploy them to a Kubernetes cluster. Finally, I’ll show how to use Spring Native to build GraalVM native executables.

Thomas Vitale

November 01, 2021
Tweet

More Decks by Thomas Vitale

Other Decks in Technology

Transcript

  1. Thomas Vitale Devoxx UK Nov 1st, 2021 Cloud Native with

    Spring Boot and Kubernetes From development to production @vitalethomas
  2. Thomas Vitale • Senior Software Engineer at Systematic, Denmark. •

    Author of “Cloud Native Spring in Action” (Manning). • Spring Security and Spring Cloud contributor. About Me thomasvitale.com
  3. Why Cloud Native? Speed Faster and fl exible delivery Cost

    Ef fi ciency and cost optimisation Scale Elasticity and dynamic scaling Resilience Availability and stability thomasvitale.com @vitalethomas
  4. The Three P’s of Cloud Native Applications Properties Place Practices

    Private Cloud Public Cloud Hybrid Cloud Scalability Loose Coupling Resilience Manageability Observability Security Automation Continuous Delivery DevOps thomasvitale.com @vitalethomas
  5. From Development to Production Cloud native journey in less than

    45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment
  6. Cloud Native Development Development principles with Spring Boot • Self-contained

    application • Embedded server • No external dependencies • JAR packaging (“uber-JAR”) • Externalized con fi guration • Property fi les for default values • JVM system variables • Environment variables thomasvitale.com @vitalethomas
  7. 1 Don’t use fat JARs 2 Optimize build/runtime performance 3

    Don’t run as root or include secrets thomasvitale.com @vitalethomas
  8. Packaging Spring Boot JAR & Container Image thomasvitale.com @vitalethomas JAR

    Container Image Gradle bootJar Maven spring-boot:repackage Gradle bootBuildImage Maven spring-boot:build-image
  9. Configuring Resources CPU & Memory thomasvitale.com @vitalethomas CPU Memory When

    limit hit Throttle Compressible Resource When limit hit OOMKilled Non Compressible Resource
  10. Configuration Options thomasvitale.com @vitalethomas Spring Boot Properties ‣Property fi les

    ‣Command line arguments ‣Environment variables Con fi guration Services ‣Spring Cloud Con fi g Server ‣Spring Cloud Consul Con fi g ‣Spring Cloud Vault ‣Spring Cloud Zookeeper Con fi g Cloud Platform Services ‣Spring Cloud Alibaba ‣Spring Cloud AWS ‣Spring Cloud Azure ‣Spring Cloud GCP Kubernetes Platform ‣Con fi gMaps ‣Secrets ‣Environment variables
  11. ConfigMaps & Secrets thomasvitale.com @vitalethomas Mount the volume to the

    /config path, where Spring Boot will automatically read property fi les. Load the Con fi gMap In a volume
  12. Graceful shutdown Spring Boot and Kubernetes • Spring Boot •

    Enable graceful shutdown • De fi ne a grace period • Kubernetes • Add pre-stop hook • De fi ne a grace period thomasvitale.com @vitalethomas
  13. Liveness and Readiness Probes Application ALIVE? READY? NO NO Restart

    might help. Restart won’t help. Don’t send any tra ffi c until it’s ready. thomasvitale.com @vitalethomas
  14. Health Probes Liveness and readiness • Spring Boot • Use

    Spring Boot Actuator • Liveness and readiness health endpoints are automatically exposed when Kubernetes is detected. • Kubernetes • Con fi gure liveness probe • Con fi gure readiness probe thomasvitale.com @vitalethomas
  15. Liveness and Readiness Probes thomasvitale.com @vitalethomas When not available, Kubernetes

    will restart the container When not ready, Kubernetes will not send any tra ff i c to the container
  16. Spring Native Native executables with GraalVM Slower Heavier Build Instant

    Startup Reduced Memory Consumption Instant Peak Performance Fewer Runtime Optimizations thomasvitale.com @vitalethomas
  17. From Development to Production Cloud native journey in less than

    45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment
  18. Thomas Vitale Devoxx UK Nov 1st, 2021 Cloud Native with

    Spring Boot and Kubernetes From development to production @vitalethomas