Slide 1

Slide 1 text

Thomas Vitale Incontro DevOps Italia July 2nd, 2021 Cloud Native with Java, Spring Boot and Kubernetes From development to production @vitalethomas

Slide 2

Slide 2 text

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

Slide 3

Slide 3 text

Cloud Native thomasvitale.com @vitalethomas

Slide 4

Slide 4 text

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

Slide 5

Slide 5 text

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

Slide 6

Slide 6 text

From Development to Production Cloud native journey in less than 45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment

Slide 7

Slide 7 text

Cloud Native Development thomasvitale.com @vitalethomas

Slide 8

Slide 8 text

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

Slide 9

Slide 9 text

Containerization thomasvitale.com @vitalethomas

Slide 10

Slide 10 text

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

Slide 11

Slide 11 text

Containerize Spring Boot Applications Docker fi les Cloud Native Buildpacks Jib thomasvitale.com @vitalethomas

Slide 12

Slide 12 text

Spring Boot on Kubernetes thomasvitale.com @vitalethomas

Slide 13

Slide 13 text

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

Slide 14

Slide 14 text

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

Slide 15

Slide 15 text

Externalized Configuration thomasvitale.com @vitalethomas

Slide 16

Slide 16 text

Code, Configuration, Credentials Code Con fi guration Deploy Credentials thomasvitale.com @vitalethomas

Slide 17

Slide 17 text

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

Slide 18

Slide 18 text

Graceful Shutdown thomasvitale.com @vitalethomas

Slide 19

Slide 19 text

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

Slide 20

Slide 20 text

Health Probes thomasvitale.com @vitalethomas

Slide 21

Slide 21 text

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

Slide 22

Slide 22 text

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

Slide 23

Slide 23 text

Spring Native thomasvitale.com @vitalethomas

Slide 24

Slide 24 text

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

Slide 25

Slide 25 text

From Development to Production Cloud native journey in less than 45 minutes thomasvitale.com @vitalethomas Spring Boot Development Cloud Native Buildpacks Containerization Kubernetes Deployment

Slide 26

Slide 26 text

GitOps & Kubernetes thomasvitale.com @vitalethomas

Slide 27

Slide 27 text

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

Slide 28

Slide 28 text

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

Slide 29

Slide 29 text

Observability thomasvitale.com @vitalethomas

Slide 30

Slide 30 text

Thomas Vitale Incontro DevOps Italia July 2nd, 2021 Cloud Native with Java, Spring Boot and Kubernetes From development to production @vitalethomas