Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Cloud Native Spring - Migrating Traditional Applications

Cloud Native Spring - Migrating Traditional Applications

The Spring ecosystem provides you with all you need to build cloud native applications, focusing on productivity, simplicity, and speed. If you decided that moving to the cloud will help your business, you’d need a strategy to migrate your existing applications. Luckily, Spring got you covered.

In this session, I’ll cover the main technical steps of migrating a traditional Spring application to be cloud native. You’ll learn best practices and common patterns to build self-contained apps by using embedded servers and packaging them as Docker images, use externalized configuration for immutable artifacts, and make the apps observable with logs, metrics, and traces. Drawing from real examples, you’ll have a roadmap to follow in your journey to the cloud with Spring Boot and Spring Cloud.

Thomas Vitale

November 07, 2020
Tweet

More Decks by Thomas Vitale

Other Decks in Programming

Transcript

  1. Thomas Vitale @vitalethomas thomasvitale.com
    Cloud Native Spring
    Migrating traditional applications
    Devoxx Ukraine 2020

    View Slide

  2. Thomas Vitale
    • Senior Software Engineer at
    Systematic, Denmark.

    • Spring, Cloud Native, DevOps,
    Application Security.

    • Author of “Cloud Native Spring in
    Action - With Spring Boot and
    Kubernetes” (Manning).
    About Me

    View Slide

  3. Agenda
    • 5 essential migration steps

    • Application server

    • Containerization

    • Configuration

    • Application lifecycle

    • Logging and monitoring
    #DevoxxUA @vitalethomas

    View Slide

  4. 1. Application Server
    #DevoxxUA @vitalethomas

    View Slide

  5. Application Server - Traditional
    WAR/EAR artifacts deployed to an application server
    #DevoxxUA @vitalethomas
    A lica i Se e
    (T ca , W d , J )
    A 1
    (WAR)
    A 2
    (WAR)
    A 3
    (WAR)
    A 4
    (WAR)

    View Slide

  6. #DevoxxUA @vitalethomas
    Application Server - Cloud Native
    Embedded Server
    Blocking + Servlet API
    (Tomcat, Undertow, Jetty)
    Spring Web
    Embedded Server
    Non-Blocking + Project Reactor
    (Netty)
    Spring WebFlux
    Serverless
    Functions
    (AWS Lambda, Azure Functions, GCP Functions)
    Spring Cloud Functions

    View Slide

  7. Application Server - Cloud Native
    Executable JAR artifacts with embedded server
    #DevoxxUA @vitalethomas
    A 1
    ( A )
    A 2
    ( A )
    A 3
    ( A )
    A 4
    ( A )

    View Slide

  8. Demo
    Embedded Server + JAR
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  9. 2. Containerization
    #DevoxxUA @vitalethomas

    View Slide

  10. Containerization
    Packaging Spring Boot apps as Docker images
    #DevoxxUA @vitalethomas
    Dockerfiles
    Cloud Native Buildpacks
    Jib

    View Slide

  11. Working with Docker Images
    Don’t use fat JARs
    Leverage layered JARs
    Security
    Don’t run as root or include secrets
    Performance
    Optimize build and runtime performance
    Maintenance
    Use up-to-date libraries
    #DevoxxUA @vitalethomas

    View Slide

  12. Demo
    Containerizing Spring Boot
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  13. 3. Configuration
    #DevoxxUA @vitalethomas

    View Slide

  14. Code and Configuration
    #DevoxxUA @vitalethomas
    Code
    Configuration
    Deploy

    View Slide

  15. Configuration - Traditional
    Configuration files and environment variables
    #DevoxxUA @vitalethomas
    Property files
    Environment variables
    XML files

    View Slide

  16. Configuration - Cloud Native
    #DevoxxUA @vitalethomas
    Spring Boot Properties
    Property files
    Command line arguments
    Environment variables
    Configuration Services
    Spring Cloud Config Server
    Spring Cloud Consul Config
    Spring Cloud Vault
    Spring Cloud Zookeeper Config
    Cloud Platform Services
    Spring Cloud Alibaba
    Spring Cloud AWS
    Spring Cloud Azure
    Spring Cloud GCP
    Kubernetes Platform
    ConfigMaps
    Secrets
    Environment Variables

    View Slide

  17. Server Configuration
    #DevoxxUA @vitalethomas
    Spring Boot
    Autoconfiguration
    Properties WebServerFactoryCustomizer

    View Slide

  18. Demo
    Configuration Strategies
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  19. 4. Application Lifecycle
    #DevoxxUA @vitalethomas

    View Slide

  20. Application Lifecycle - Traditional
    #DevoxxUA @vitalethomas
    Vertical scaling
    Extra care for each instance
    Slow startup time

    View Slide

  21. Application Lifecycle - Cloud Native
    Disposable and stateless applications
    #DevoxxUA @vitalethomas
    Horizontal scaling
    Disposable instances
    Fast startup time

    View Slide

  22. Demo
    Disposability and scalability
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  23. 5. Logging & Monitoring
    #DevoxxUA @vitalethomas

    View Slide

  24. Logs - Now and Then
    From log files to event streams
    #DevoxxUA @vitalethomas
    Log to files
    File naming
    File sizing
    File rotation
    Log to stdout
    Event stream
    External log collection
    External log aggregation

    View Slide

  25. Health Checks
    Liveness and readiness probes
    Application
    #DevoxxUA @vitalethomas
    ALIVE?
    READY?
    NO
    NO
    Restart might help
    Restart won’t help

    View Slide

  26. Metrics - Now and Then
    Towards observable applications
    #DevoxxUA @vitalethomas
    External agents
    Outside the application
    Internal agents
    The application exposes metrics

    View Slide

  27. Demo
    Logging and Monitoring
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  28. What’s next?
    #DevoxxUA @vitalethomas

    View Slide

  29. II. Dependency
    management
    I. One codebase, one
    application
    III. Configuration,
    credentials, and code
    V. Design, build,
    release, run
    IV. Backing services
    VI. Stateless
    processes
    VIII. Concurrency
    VII. Port binding IX. Disposability
    XI. Logs
    X. Environment
    parity
    XII. Administrative
    processes
    XIV. Telemetry
    XIII. API first
    XV. Authentication and
    authorization

    View Slide

  30. What’s next?
    #DevoxxUA @vitalethomas
    Resilience
    Resilience4J
    Spring Cloud Circuit Breaker
    Distributed systems
    Spring Cloud Gateway
    Spring Cloud Stream
    Spring Security OAuth
    Reactive
    Spring WebFlux
    R2DBC
    Project Reactor
    Kubernetes
    Spring Boot
    Spring Cloud Kubernetes
    Skaffold

    View Slide

  31. With Spring Boot and Kubernetes
    • 35% discount code, valid for all
    products in all format

    • ctwdevoxxukr20
    • manning.com

    • 5 free e-book codes

    • join Q&A for the raffle
    Cloud Native Spring in Action

    View Slide

  32. Bonus Demo
    Spring Boot on Kubernetes
    #DevoxxUA @vitalethomas
    https://github.com/ThomasVitale/devoxx-ua-2020

    View Slide

  33. Thomas Vitale @vitalethomas thomasvitale.com
    Cloud Native Spring
    Migrating traditional applications
    Devoxx Ukraine 2020

    View Slide