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

Cloud Native with Spring Boot and Kubernetes

Thomas Vitale
February 10, 2021
170

Cloud Native with Spring Boot and Kubernetes

Principles and patterns for building cloud native application using Spring Boot, containerizing them with Cloud Native Buildpacks, and deploying them on a Kubernetes cluster through a GitOps workflow.

Thomas Vitale

February 10, 2021
Tweet

Transcript

  1. Thomas Vitale @vitalethomas thomasvitale.com
    Cloud Native
    With Spring Boot and Kubernetes
    Systematic - 10/02/2021
    systematic.com

    View full-size 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 full-size slide

  3. Why Cloud Native?
    @SystematicGroup @vitalethomas

    View full-size slide

  4. The Three P’s of Cloud Native Applications
    Place
    Private Cloud


    Public Cloud


    Hybrid Cloud
    Properties
    Scalability


    Loose Coupling


    Resilience


    Manageability


    Observability


    Security
    Practices
    Automation


    Continuous Delivery


    DevOps
    @SystematicGroup @vitalethomas

    View full-size slide

  5. The Goals
    Speed
    Faster and
    fl
    exible delivery
    Cost


    Ef
    fi
    ciency and cost optimisation
    Scale
    Elasticity and dynamic scaling
    Resilience
    Availability and stability
    @SystematicGroup @vitalethomas

    View full-size slide

  6. 1. Application Server
    @SystematicGroup @vitalethomas

    View full-size slide

  7. 2 Embedded server
    3 Imperative vs. Reactive
    @SystematicGroup @vitalethomas
    1 “Make JAR, not WAR” (Josh Long)

    View full-size slide

  8. @SystematicGroup @vitalethomas
    Embedded Server + JAR Packaging
    Embedded Server


    Blocking + Servlet API


    (Tomcat, Undertow, Jetty)


    Spring Web
    Embedded Server


    Non-Blocking + Project Reactor


    (Netty)


    Spring WebFlux
    Serverless


    Functions


    (AWS, Azure, GCP, Knative)


    Spring Cloud Functions

    View full-size slide

  9. Demo
    Embedded Server + JAR Packaging
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  10. 2. Containerization
    @SystematicGroup @vitalethomas

    View full-size slide

  11. 1 Don’t use fat JARs
    2 Optimize build/runtime performance
    3 Don’t run as root or include secrets
    @SystematicGroup @vitalethomas

    View full-size slide

  12. Containerize Spring Boot Applications
    @SystematicGroup @vitalethomas
    Docker
    fi
    les
    Cloud Native Buildpacks
    Jib

    View full-size slide

  13. Demo
    Containerizing Spring Boot
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  14. 3. Kubernetes Deployment
    @SystematicGroup @vitalethomas

    View full-size slide

  15. 1 Define a Namespace manifest
    2 Define a Deployment manifest
    3 Define a Service manifest
    @SystematicGroup @vitalethomas

    View full-size slide

  16. Demo
    Kubernetes Deployment
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  17. 4. Application Lifecycle
    @SystematicGroup @vitalethomas

    View full-size slide

  18. 1
    2
    3
    Fast start-up, graceful shutdown
    Liveness and readiness probes
    Stateless and horizontally scalable
    @SystematicGroup @vitalethomas

    View full-size slide

  19. Liveness and Readiness Probes
    Application
    ALIVE?
    READY?
    NO
    NO
    Restart might help
    Restart won’t help
    @SystematicGroup @vitalethomas

    View full-size slide

  20. Demo
    Application Lifecycle
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  21. 5. Configuration
    @SystematicGroup @vitalethomas

    View full-size slide

  22. Code, Configuration, Credentials
    Code
    Con
    fi
    guration Deploy
    Credentials
    @SystematicGroup @vitalethomas

    View full-size slide

  23. Configuration Strategies
    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
    @SystematicGroup @vitalethomas

    View full-size slide

  24. Demo
    Con
    fi
    guration
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  25. Bonus: GitOps
    @SystematicGroup @vitalethomas

    View full-size slide

  26. GitOps - Cloud Native Operations
    https://www.weave.works/technologies/gitops/

    View full-size slide

  27. Demo
    GitOps
    https://github.com/ThomasVitale/cloud-native-spring-webinar-feb-2021
    @SystematicGroup @vitalethomas

    View full-size slide

  28. GitOps - Configuration
    helm upgrade -i flux fluxcd/flux \


    --set git.user=$GITHUB_USER \


    --set [email protected] \


    --set [email protected]:$GITHUB_USER/cloud-native-spring-
    webinar-feb-2021 \


    --set git.path="deployment" \


    --set git.branch="main" \


    --namespace flux


    @SystematicGroup @vitalethomas

    View full-size slide

  29. What’s next?
    @SystematicGroup @vitalethomas

    View full-size slide

  30. II. Dependency
    management
    I. One codebase, one
    application
    III. Con
    fi
    guration,
    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
    fi
    rst
    XV. Authentication
    and authorization
    Beyond 12-Factors

    View full-size slide

  31. More Spring and Kubernetes
    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
    @SystematicGroup @vitalethomas

    View full-size slide

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

    • mtpsystematic21


    • mng.bz/8N5D
    Cloud Native Spring in Action
    www.thomasvitale.com @vitalethomas

    View full-size slide

  33. Thomas Vitale @vitalethomas thomasvitale.com
    Cloud Native
    With Spring Boot and Kubernetes
    Systematic - 10/02/2021
    systematic.com

    View full-size slide