Save 37% off PRO during our Black Friday Sale! »

Cloud Native with Spring Boot and Kubernetes

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.

C20b9829daddbee16e359b0a750660a5?s=128

Thomas Vitale

November 01, 2021
Tweet

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. Cloud Native thomasvitale.com @vitalethomas

  4. 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
  5. 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
  6. From Development to Production Cloud native journey in less than

    45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment
  7. Cloud Native Development thomasvitale.com @vitalethomas

  8. 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
  9. Packaging Spring Boot Standalone JAR thomasvitale.com @vitalethomas JAR Gradle bootJar

    Maven spring-boot:repackage
  10. Containerization thomasvitale.com @vitalethomas

  11. buildpacks.io

  12. paketo.io

  13. 1 Don’t use fat JARs 2 Optimize build/runtime performance 3

    Don’t run as root or include secrets thomasvitale.com @vitalethomas
  14. Containerize Java Applications Docker fi les Cloud Native Buildpacks Jib

    thomasvitale.com @vitalethomas
  15. 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
  16. Spring Boot on Kubernetes thomasvitale.com @vitalethomas

  17. tanzucommunityedition.io

  18. knative.dev

  19. Configuring Resources CPU & Memory thomasvitale.com @vitalethomas CPU Memory When

    limit hit Throttle Compressible Resource When limit hit OOMKilled Non Compressible Resource
  20. Externalized Configuration thomasvitale.com @vitalethomas

  21. Code, Configuration, Credentials Code Con fi guration Deploy Credentials thomasvitale.com

    @vitalethomas
  22. 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
  23. 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
  24. Graceful Shutdown thomasvitale.com @vitalethomas

  25. 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
  26. Health Probes thomasvitale.com @vitalethomas

  27. 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
  28. 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
  29. 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
  30. Spring Native thomasvitale.com @vitalethomas

  31. Spring Native Native executables with GraalVM Slower Heavier Build Instant

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

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

    Spring Boot and Kubernetes From development to production @vitalethomas