From 736fd94f01bcda437af2d9f12fd6b7c5ca8ad2d9 Mon Sep 17 00:00:00 2001 From: Florian Date: Sat, 17 Oct 2026 16:55:45 +0200 Subject: [PATCH] Added Seadex service --- service-seadex/cron-update.yaml | 31 ++++++++++++ service-seadex/deployment.yaml | 74 ++++++++++++++++++++++++++++ service-seadex/service-internal.yaml | 14 ++++++ service-seadex/service-metrics.yaml | 15 ++++++ 4 files changed, 134 insertions(+) create mode 100644 service-seadex/cron-update.yaml create mode 100644 service-seadex/deployment.yaml create mode 100644 service-seadex/service-internal.yaml create mode 100644 service-seadex/service-metrics.yaml diff --git a/service-seadex/cron-update.yaml b/service-seadex/cron-update.yaml new file mode 100644 index 0000000..08ea176 --- /dev/null +++ b/service-seadex/cron-update.yaml @@ -0,0 +1,31 @@ +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: service-royalroad-chapters-cron-gitea + namespace: app-notifications +spec: + serviceName: service-royalroad-chapters-cron-gitea + replicas: 1 + selector: + matchLabels: + app: service-royalroad-chapters-cron + template: + metadata: + labels: + app: service-royalroad-chapters-cron + spec: + containers: + - name: cron + image: curlimages/curl:latest + command: + - /bin/sh + - -c + - | + echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"startup\"}" + while true; do + echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"curl start\"}" + curl -s -X GET --max-time 150 http://service-seadex-internal:5000/update + echo + echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"curl end\"}" + sleep 300 + done diff --git a/service-seadex/deployment.yaml b/service-seadex/deployment.yaml new file mode 100644 index 0000000..4ad6d65 --- /dev/null +++ b/service-seadex/deployment.yaml @@ -0,0 +1,74 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: service-seadex + namespace: app-notifications +spec: + replicas: 1 + selector: + matchLabels: + app: service-seadex + template: + metadata: + labels: + app: service-seadex + spec: + imagePullSecrets: + - name: ghcr-secret + initContainers: + - name: wait-for-mysql + image: busybox + command: + - sh + - -c + - | + until nslookup mysql.app-notifications.svc.cluster.local; do + echo "Waiting for MySQL DNS..." + sleep 2 + done + + until nc -z mysql.app-notifications.svc.cluster.local 3306; do + echo "Waiting for MySQL..." + sleep 2 + done + + echo "MySQL is available" + - name: copy-secrets + image: busybox + command: + - sh + - -c + - | + for f in /secrets/*; do + cp "$f" /etc/secrets/ + chmod 666 "/etc/secrets/$(basename $f)" + done + volumeMounts: + - name: service-seadex-secrets + mountPath: /secrets + - name: writable-secrets + mountPath: /etc/secrets + containers: + - name: service-seadex + image: ghcr.io/gansejunge/app-notifications-service-seadex:1 + ports: + - containerPort: 5000 + name: fastapi + - containerPort: 9000 + name: metrics + env: + - name: DB_HOST + value: "mysql.app-notifications.svc.cluster.local" + - name: BACKEND_API_URL + value: "http://backend-api-internal.app-notifications.svc.cluster.local:8101/internal/receive-notifications" + - name: LOG_LEVEL + value: "INFO" + volumeMounts: + - name: writable-secrets + mountPath: /etc/secrets + volumes: + - name: service-seadex-secrets + secret: + secretName: service-seadex + - name: writable-secrets + emptyDir: {} diff --git a/service-seadex/service-internal.yaml b/service-seadex/service-internal.yaml new file mode 100644 index 0000000..c7b8a08 --- /dev/null +++ b/service-seadex/service-internal.yaml @@ -0,0 +1,14 @@ +apiVersion: v1 +kind: Service +metadata: + name: service-royalroad-chapters-internal + namespace: app-notifications +spec: + selector: + app: service-royalroad-chapters + ports: + - protocol: TCP + port: 5000 + targetPort: 5000 + name: fastapi + type: ClusterIP diff --git a/service-seadex/service-metrics.yaml b/service-seadex/service-metrics.yaml new file mode 100644 index 0000000..9d9b5a0 --- /dev/null +++ b/service-seadex/service-metrics.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: Service +metadata: + name: service-seadex-prometheus-metrics + namespace: app-notifications +spec: + selector: + app: service-seadex + ports: + - protocol: TCP + port: 9000 + targetPort: 9000 + nodePort: 30906 + name: prometheus-metrics + type: NodePort