RU | EN | DE

1. Deployment von Spring Boot in AWS

Variante 1: AWS Elastic Beanstalk Am einfachsten → nimmt deinen jar/war und deployt ihn.📌 Befehl:

eb init -p java-17 demo-app
eb create demo-env
eb deploy

Variante 2: AWS ECS (Container)

  1. Wir erstellen einen Docker-Image.
  2. Wir laden es in Amazon Elastic Container Registry (ECR) hoch:
aws ecr create-repository --repository-name demo-app
docker tag demo-app:latest <aws-account-id>.dkr.ecr.region.amazonaws.com/demo-app:latest
docker push <aws-account-id>.dkr.ecr.region.amazonaws.com/demo-app:latest
  1. Wir starten es in ECS (Fargate).

Variante 3: AWS EKS (Kubernetes)

  • Wir starten einen EKS-Cluster.
  • Wir deployen ihn wie einen normalen Kubernetes-Manifest (siehe DevOps-Block).

2. Deployment von Spring Boot in GCP

Variante 1: Google App Engine 📌 app.yaml:

runtime: java17
instance_class: F1

Hochladen:

gcloud app deploy

Variante 2: Google Cloud Run (Serverlose Container)

  • Nimmt ein Docker-Image.
  • Skaliert von 0 bis N (kostenlos, solange kein Traffic vorhanden ist).
gcloud run deploy demo-app --image gcr.io/PROJECT-ID/demo-app --platform managed

Variante 3: GKE (Google Kubernetes Engine)

  • Deployment wie ein normaler K8s + Helm.

3. Deployment von Spring Boot in Azure

Variante 1: Azure App Service

  • Du lädst ein jar/Docker-Image hoch.
  • Azure startet es selbst.

Variante 2: Azure AKS (Kubernetes)

  • Analogon zu GKE/EKS.
  • Helm Charts funktionieren direkt.

Variante 3: Azure Functions (Serverless)

  • Wenn die Anwendung in Funktionen aufgeteilt werden kann → Spring Cloud Function.

4. Kubernetes Helm Charts

📌 Helm = Paketmanager für Kubernetes.

📄 Chart.yaml:

apiVersion: v2
name: demo-app
version: 0.1.0

📄 values.yaml:

replicaCount: 2
image:
  repository: demo-app
  tag: latest
service:
  type: LoadBalancer
  port: 80

📌 Installation: helm install demo ./charts/demo-app

5. Spring Cloud Config

📌 Für zentrale Konfiguration (eine Konfiguration für mehrere Services).

Config Server 📄 Abhängigkeit:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-config-server</artifactId>
</dependency>

📄 Start:

@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {
    public static void main(String[] args) {
        SpringApplication.run(ConfigServerApplication.class, args);
    }
}

📄 application.yml:

spring:
  cloud:
    config:
      server:
        git:
          uri: https://github.com/my-org/config-repo

Client 📄 Abhängigkeit:

<dependency>
  <groupId>org.springframework.cloud</groupId>
  <artifactId>spring-cloud-starter-config</artifactId>
</dependency>

📄 bootstrap.yml:

spring:
  application:
    name: demo-app
  cloud:
    config:
      uri: http://localhost:8888

Jetzt werden die Konfigurationseinstellungen aus dem git-Repository der Konfiguration bezogen.

6. Serverless + Spring

📌 Mit Spring Cloud Function kann man Lambdas schreiben.

Beispiel AWS Lambda:

@Bean
public Function<String, String> uppercase() {
    return value -> value.toUpperCase();
}

📌 Deployment in AWS Lambda über den Adapter spring-cloud-function-adapter-aws.

7. CI/CD in der Cloud

  • AWS → CodePipeline / CodeBuild.
  • GCP → Cloud Build.
  • Azure → DevOps Pipelines.
  • Überall kann man GitHub Actions verwenden (die beliebteste Option).

8. Best Practices

  • ✅ Für MVP → Heroku, App Engine, Cloud Run (schnell und einfach).
  • ✅ Für Enterprise → Kubernetes (EKS/GKE/AKS) + Helm + Spring Cloud Config.
  • ✅ Speichere Geheimnisse in Vault / Secret Manager / Kubernetes Secrets.
  • ✅ Trenne Umgebungen (dev/test/prod) und Konfigurationen.
  • ✅ Verwende einen Observability Stack (Prometheus + Grafana + Loki/ELK).
  • ✅ Führe blue-green oder canary deployments durch → sichere Updates.