This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
Microservices-Beispiel
Code: m300 – Example Service
Dies ist ein einfaches Beispiel für eine Microservices-Architektur unter Verwendung von Docker, Kubernetes und Helm.
Dieses Microservices-Beispiel wird automatisch mittels einer CI/CD-Pipeline gebaut und in ein Container-Registry veröffentlicht, um anschliessend mit FluxCD bereitgestellt zu werden.
Service A
Service A ist der exportierte Microservice, der eine Nachricht von Service B anzeigt (sofern dieser läuft/konfiguriert ist).
GET / (text/html
)
200
Antwort:Service A received: <message_from_service_b>
500
Antwort:Error connecting to Service B: <error_message>
GET /api/service-b (application/json
)
200
Antwort: JSON-Objekt mit Nachricht und Zeitstempel.
{
"message": "Hello from Service B!",
"timestamp": "2025-07-09T11:48:21.281Z",
"currentService": "service-a",
"health": "healthy"
}
500
Antwort: JSON-Objekt mit Fehlermeldung.
{
"error": "<error_message>",
"health": "unhealthy"
}
Service B
Service B ist ein interner Microservice, der die Nachricht für anfragende Services – in diesem Fall Service A – bereitstellt.
GET /message
-
200
Antwort: JSON-Objekt mit Nachricht und Zeitstempel.{ "message": "Hallo von Service B!", "timestamp": "2025-07-09T11:48:21.281Z", "currentService": "service-b", "health": "healthy" }
Automatisierte Build-Pipeline
Die folgende Pipeline (sollte) mithilfe von Podman unsere Container Images bauen und auf unser Forgejo Registry pushen.
Die eigentliche Logik zum Bauen und veröffentlichen vom Image sollte funktionieren, da sie eine adaptierte Version von einer ähnlichen Build-Pipeline für meine persönliche Website (Stelian) ist, nur haben wir nicht herausgefunden, wie wir fehlerfrei Podman im Runner installieren, da uns die Zeit gefehlt hat.
# Trigger workflow on tag push
on:
push:
branches:
- "main"
tags:
- "v*"
jobs:
publish:
runs-on: docker
container:
image: ghcr.io/catthehacker/ubuntu:act-latest
defaults:
run:
working-directory: /tmp
steps:
- name: ⬇️ Checkout Repository
uses: actions/checkout@v4
- name: 📝 Set Tag Variable
id: vars
run: echo "TAG=${GITHUB_REF#refs/tags/}" >> $GITHUB_ENV
- name: podman install
run: |
# Add the Podman repository
source /etc/os-release
echo "deb https://download.opensuse.org/repositories/devel:/kubic:/libcontainers:/stable/xUbuntu_${VERSION_ID}/ /" | sudo tee /etc/apt/sources.list.d/devel:kubic:libcontainers:stable.list
# Import the repository GPG key
curl -fsSL https://download.opensuse.org/repositories/devel:kubic:libcontainers:stable/xUbuntu_${VERSION_ID}/Release.key | gpg --dearmor | sudo tee /etc/apt/trusted.gpg.d/libcontainers.gpg > /dev/null
# Update and install Podman
sudo apt update
sudo apt install -y podman
- name: 🔑 Login to Container Registry
run: |
podman login git.m300.cpu.cafe -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }}
- name: 🛠️ Build and Push service-a
run: |
podman build -t git.m300.cpu.cafe/m300/example-microservice-a:${TAG} ./service-a
podman tag git.m300.cpu.cafe/m300/example-microservice-a:${TAG} git.m300.cpu.cafe/m300/example-microservice-a:latest
podman push git.m300.cpu.cafe/m300/example-microservice-a:${TAG}
podman push git.m300.cpu.cafe/m300/example-microservice-a:latest
- name: 🛠️ Build and Push service-b
run: |
podman build -t git.m300.cpu.cafe/m300/example-microservice-b:${TAG} ./service-b
podman tag git.m300.cpu.cafe/m300/example-microservice-b:${TAG} git.m300.cpu.cafe/m300/example-microservice-b:latest
podman push git.m300.cpu.cafe/m300/example-microservice-b:${TAG}
podman push git.m300.cpu.cafe/m300/example-microservice-b:latest