Version 4 · Migration
EAR/WAR zum Container-Zielbild
Aus serverzentriertem Deployment wird ein reproduzierbares Image mit klarer Konfiguration, Health Checks, Ressourcenlimits und OpenShift Deployment.
Aus serverzentriertem Deployment wird ein reproduzierbares Image mit klarer Konfiguration, Health Checks, Ressourcenlimits und OpenShift Deployment.
Warum reines Lift-and-Shift oft nicht reicht
Ein EAR läuft nicht automatisch gut im Container, nur weil es irgendwie startet. Klassische Application Server speichern Konfiguration oft außerhalb der Anwendung: DataSources, JMS, Security Realms, Thread Pools, Work Manager, Keystores und Bindings. Im Container müssen diese Abhängigkeiten explizit, versionierbar und überprüfbar werden.
Vorher/Nachher Zielbild
| Aspekt | Vorher | Nachher |
|---|---|---|
| Deployment | EAR in zentralem Application Server | Image + Deployment + Service + Route |
| Konfiguration | Admin Console, wsadmin, JNDI | ConfigMap, Secret, Environment, Volume |
| Betrieb | Server-Instanz mit vielen Anwendungen | Pod pro Anwendung oder fachlichem Slice |
| Update | manuelles Deploymentfenster | Pipeline + GitOps + Rollback |
| Diagnose | Serverlogs, JVM Dumps | Containerlogs, Events, Metrics, Traces |
Containerfile Beispiel
Containerfile für modernes Java-Runtime-Image
# Pattern: Immutable Infrastructure - das Laufzeitimage wird reproduzierbar gebaut.
FROM registry.access.redhat.com/ubi9/openjdk-21-runtime:latest
WORKDIR /deployments
COPY target/billing-modern-api.jar app.jar
ENV JAVA_OPTS="-XX:MaxRAMPercentage=75 -Dfile.encoding=UTF-8"
EXPOSE 8080
ENTRYPOINT ["sh", "-c", "java $JAVA_OPTS -jar /deployments/app.jar"]
OpenShift Deployment-Grundlage
Deployment, Service und Route mit Probes
apiVersion: apps/v1
kind: Deployment
metadata:
name: billing-modern-api
labels:
app: billing-modern-api
spec:
replicas: 2
selector:
matchLabels:
app: billing-modern-api
template:
metadata:
labels:
app: billing-modern-api
spec:
containers:
- name: app
image: image-registry.openshift-image-registry.svc:5000/legacy-v4/billing-modern-api:1.0.0
ports:
- containerPort: 8080
envFrom:
- configMapRef:
name: billing-config
- secretRef:
name: billing-secrets
readinessProbe:
httpGet:
path: /q/health/ready
port: 8080
initialDelaySeconds: 10
periodSeconds: 10
livenessProbe:
httpGet:
path: /q/health/live
port: 8080
initialDelaySeconds: 30
periodSeconds: 20
---
apiVersion: v1
kind: Service
metadata:
name: billing-modern-api
spec:
selector:
app: billing-modern-api
ports:
- name: http
port: 8080
targetPort: 8080
---
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: billing-modern-api
spec:
to:
kind: Service
name: billing-modern-api
port:
targetPort: http
tls:
termination: edge