Companion code for "Deploying Spring Boot 4 on Kubernetes: Probes, Graceful Shutdown, Limits and JVM Ergonomics". A dependency outage under three probe-group setups, a rolling restart under load four ways (three runs each), the JVM's ergonomic choices for nine pod shapes, one GC-heavy load under five CPU limits with throttling counters, and an HPA driven by a Micrometer gauge through prometheus-adapter. Measured on k3s v1.36.4. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C3TETMrqVUWeFkNtz3Jbo3
31 lines
1.0 KiB
Bash
31 lines
1.0 KiB
Bash
#!/usr/bin/env bash
|
|
MODULE_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
|
|
OUT="$MODULE_DIR/docs/output"
|
|
NS=demo
|
|
IMAGE="${IMAGE:-sbd/k8s-demo:1}"
|
|
mkdir -p "$OUT"
|
|
export KUBECONFIG="${KUBECONFIG:-/etc/rancher/k3s/k3s.yaml}"
|
|
# Run a one-off pod from the app image with an arbitrary command and resources; print its logs.
|
|
# oneoff <name> '<resources-json>' <command...>
|
|
oneoff() {
|
|
local name="$1" resources="$2"; shift 2
|
|
local cmd; cmd=$(printf '"%s",' "$@"); cmd="[${cmd%,}]"
|
|
kubectl -n "$NS" delete pod "$name" --ignore-not-found --wait=true > /dev/null
|
|
kubectl -n "$NS" apply -f - > /dev/null <<YAML
|
|
apiVersion: v1
|
|
kind: Pod
|
|
metadata: {name: $name, namespace: $NS, labels: {role: oneoff}}
|
|
spec:
|
|
restartPolicy: Never
|
|
containers:
|
|
- name: app
|
|
image: $IMAGE
|
|
imagePullPolicy: Never
|
|
command: $cmd
|
|
resources: $resources
|
|
YAML
|
|
kubectl -n "$NS" wait --for=jsonpath='{.status.phase}'=Succeeded "pod/$name" --timeout=120s > /dev/null
|
|
kubectl -n "$NS" logs "$name"
|
|
kubectl -n "$NS" delete pod "$name" --wait=false > /dev/null
|
|
}
|