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

Cloud Native with Java, Spring Boot and Kubernetes

Cloud Native with Java, Spring Boot and Kubernetes

C20b9829daddbee16e359b0a750660a5?s=128

Thomas Vitale

July 02, 2021
Tweet

Transcript

  1. Thomas Vitale Incontro DevOps Italia July 2nd, 2021 Cloud Native

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

    Spring, Cloud Native, DevOps, Kubernetes, Application Security. • Author of “Cloud Native Spring in Action” (Manning). About Me
  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 (“fat-JAR”) • Externalized con fi guration • Property fi les for default values • JVM system variables • Environment variables thomasvitale.com @vitalethomas
  9. Containerization thomasvitale.com @vitalethomas

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

    Don’t run as root or include secrets thomasvitale.com @vitalethomas
  11. Containerize Spring Boot Applications Docker fi les Cloud Native Buildpacks

    Jib thomasvitale.com @vitalethomas
  12. Spring Boot on Kubernetes thomasvitale.com @vitalethomas

  13. Spring Boot on Kubernetes Kubernetes manifests for deploying applications •

    Deployment -> deploy the application (with replicas) • Service -> expose the application to the inside of the cluster • Ingress -> expose the application to the Internet thomasvitale.com @vitalethomas
  14. Deploying Spring Boot Applications Computational resource con fi guration •

    Requests are the resources guaranteed to the application container. • Limits de fi ne the maximum resources an application container can get. • CPU is compressible. • When limit hit: throttle. • For JVM containers, no limit for startup boost. • Memory is non-compressible. • When limit hit: OOMKilled • For JMV containers, same value for requests and limits. thomasvitale.com @vitalethomas
  15. Externalized Configuration thomasvitale.com @vitalethomas

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

    @vitalethomas
  17. ConfigMaps and Secrets Con fi guration and credentials • Con

    fi gMaps • Environment variables • Volume mounts • Secrets • Environment variables • Consider a backend like Vault for actual encryption or Sealed Secrets thomasvitale.com @vitalethomas
  18. Graceful Shutdown thomasvitale.com @vitalethomas

  19. 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
  20. Health Probes thomasvitale.com @vitalethomas

  21. 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
  22. 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
  23. Spring Native thomasvitale.com @vitalethomas

  24. Spring Native Native executables with GraalVM • Bene fi ts

    • Instant startup • Instant peak performance • Reduced memory consumption • Tradeo ff s • Slower and heavier build process • Fewer runtime optimizations thomasvitale.com @vitalethomas
  25. From Development to Production Cloud native journey in less than

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

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

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

    git.user=$GITHUB_USER \ --set git.email=$GITHUB_USER@users.noreply.github.com \ --set git.url=git@github.com:$GITHUB_USER/spring-boot- kubernetes-incontro-devops-2021 \ --set git.path="k8s" \ --set git.branch="main" \ --namespace flux thomasvitale.com @vitalethomas
  29. Observability thomasvitale.com @vitalethomas

  30. Thomas Vitale Incontro DevOps Italia July 2nd, 2021 Cloud Native

    with Java, Spring Boot and Kubernetes From development to production @vitalethomas