Version 4 · Migration

EAR/WAR zum Container-Zielbild

Aus serverzentriertem Deployment wird ein reproduzierbares Image mit klarer Konfiguration, Health Checks, Ressourcenlimits und OpenShift Deployment.

Migration-ÜbersichtStartseite
EAR/WAR zum Container-Zielbild
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
AspektVorherNachher
DeploymentEAR in zentralem Application ServerImage + Deployment + Service + Route
KonfigurationAdmin Console, wsadmin, JNDIConfigMap, Secret, Environment, Volume
BetriebServer-Instanz mit vielen AnwendungenPod pro Anwendung oder fachlichem Slice
Updatemanuelles DeploymentfensterPipeline + GitOps + Rollback
DiagnoseServerlogs, JVM DumpsContainerlogs, 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
⌂ Cockpit