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

Cloud Native with Java, Spring Boot and Kubernetes

Cloud Native with Java, Spring Boot and Kubernetes

Thomas Vitale

July 02, 2021
Tweet

More Decks by Thomas Vitale

Other Decks in Programming

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. 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 (“fat-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. 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
  9. 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
  10. 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
  11. 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
  12. 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
  13. 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
  14. 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
  15. From Development to Production Cloud native journey in less than

    45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment
  16. GitOps - Configuration helm upgrade -i flux fluxcd/flux \ --set

    git.user=$GITHUB_USER \ --set [email protected] \ --set [email protected]:$GITHUB_USER/spring-boot- kubernetes-incontro-devops-2021 \ --set git.path="k8s" \ --set git.branch="main" \ --namespace flux thomasvitale.com @vitalethomas
  17. Thomas Vitale Incontro DevOps Italia July 2nd, 2021 Cloud Native

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