Deployment patterns
Deployment patterns for Java Spring Boot — Docker, Kubernetes, CI/CD, health probes, graceful shutdown. Use when writing Dockerfiles, K8s manifests (Deployment/Service/HPA/ConfigMap), CI/CD pipelines (GitHub Actions, GitLab CI), configuring health probes (liveness/readiness/startup), setting up graceful shutdown, sizing container resources, or containerizing Spring Boot applications.From its SKILL.md
npx -y skills add taipt1504/agent-skills --skill deployment-patternsAssembled from the repository path, not quoted from the project. Check it against their README if it does not work.
2 things to look at
- no licenseNo license file was found in the repository. Code published without one is not open source by default, so using it at work is a question for whoever answers licensing questions where you are.
- 3 stars3 stars. Stars are a popularity signal and not a quality one, but at this level it is likely that nobody has read this closely except its author, and you would be relying on your own review.
SKILL.md
5.0 KB, as published. Nobody here has run it
Deployment Patterns — Docker, K8s, CI/CD
Quick Decision Matrix
| Need | Reference | When to read |
|---|---|---|
| Dockerfile | references/dockerfile.md | Creating/reviewing Docker images |
| K8s manifests | references/kubernetes.md | Writing Deployment, Service, HPA, ConfigMap |
| CI/CD pipeline | references/cicd.md | Setting up GitHub Actions or GitLab CI |
| Health probes | references/health-probes.md | Configuring liveness/readiness/startup probes |
| Generate Dockerfile | scripts/generate-dockerfile.sh | Scaffold a production Dockerfile |
Core Principles
- Separate build/runtime — multi-stage builds (JDK build, JRE runtime)
- Never root —
USER appuserin production images - Container-aware JVM —
-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 - Probe semantics — liveness = internal only, readiness = external deps
- Graceful shutdown —
terminationGracePeriodSeconds>timeout-per-shutdown-phase - No secrets in images — K8s Secrets, SealedSecrets, or Vault
Dockerfile Essentials
# Build
FROM eclipse-temurin:17-jdk-jammy AS builder
WORKDIR /app
COPY gradle/ gradle/
COPY gradlew build.gradle.kts settings.gradle.kts ./
RUN ./gradlew dependencies --no-daemon || true
COPY src/ src/
RUN ./gradlew bootJar --no-daemon -x test
# Runtime
FROM eclipse-temurin:17-jre-jammy
RUN groupadd -r appuser && useradd -r -g appuser appuser
WORKDIR /app
COPY --from=builder /app/build/libs/*.jar app.jar
USER appuser
ENV JAVA_OPTS="-XX:+UseContainerSupport -XX:MaxRAMPercentage=75.0 -XX:InitialRAMPercentage=50.0"
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar app.jar"]
Layered JAR, Maven, JVM flags → references/dockerfile.md.
Health Probes Summary
# application.yml
management:
endpoint.health:
probes.enabled: true
group:
liveness:
include: livenessState
readiness:
include: readinessState, db, redis
server:
shutdown: graceful
spring:
lifecycle:
timeout-per-shutdown-phase: 30s
| Probe | Endpoint | Checks | Failure → |
|---|---|---|---|
| Liveness | /actuator/health/liveness | App alive | Pod restart |
| Readiness | /actuator/health/readiness | DB, Redis | Remove from Service |
| Startup | /actuator/health/liveness | Init done | Wait |
Custom HealthIndicators, composite readiness, shutdown sequence → references/health-probes.md.
Resource Sizing
| Type | Mem Request | Mem Limit | CPU Request | CPU Limit |
|---|---|---|---|---|
| Lightweight API | 256Mi | 512Mi | 100m | 500m |
| Standard API | 512Mi | 1Gi | 250m | 1000m |
| Heavy Processing | 1Gi | 2Gi | 500m | 2000m |
Full K8s manifests (Deployment, Service, HPA, ConfigMap, NetworkPolicy) → references/kubernetes.md.
CI/CD Pipeline Quick Reference
Stages: build & test → security scan → Docker build + Trivy scan → deploy staging → deploy production. Full YAML, strategies → references/cicd.md.
Graceful Shutdown Checklist
server.shutdown: gracefulspring.lifecycle.timeout-per-shutdown-phase: 30sterminationGracePeriodSeconds: 45(must be > shutdown timeout)- Readiness probe fails first → K8s stops new traffic
- In-flight requests drain within timeout
- Kafka consumers commit offsets, DB pool drains
Related Skills
- observability-patterns — Prometheus metrics, structured logging, tracing
- spring-webflux-patterns — Spring Boot configuration, profiles
- architecture — Hexagonal structure mapping to Docker layers