Moved from using Kubernetes' internal Cron scheduler to a pod based one due to unforeseen hangups. Also added a check if the MySQL server is available before continuing
This commit is contained in:
1 parent
5f131c3bd9
commit
7674a9c64b
10 files changed
+237
No files matched your search
@@ -16,6 +16,23 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-secret
|
- name: ghcr-secret
|
||||||
initContainers:
|
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
|
- name: copy-secrets
|
||||||
image: busybox
|
image: busybox
|
||||||
command:
|
command:
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-secret
|
- name: ghcr-secret
|
||||||
initContainers:
|
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
|
- name: copy-secrets
|
||||||
image: busybox
|
image: busybox
|
||||||
command:
|
command:
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-secret
|
- name: ghcr-secret
|
||||||
initContainers:
|
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
|
- name: copy-secrets
|
||||||
image: busybox
|
image: busybox
|
||||||
command:
|
command:
|
||||||
|
|||||||
@@ -0,0 +1,55 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: Deployment
|
||||||
|
metadata:
|
||||||
|
name: service-docker-repository-query
|
||||||
|
namespace: app-notifications
|
||||||
|
spec:
|
||||||
|
replicas: 1
|
||||||
|
selector:
|
||||||
|
matchLabels:
|
||||||
|
app: service-docker-repository-query
|
||||||
|
template:
|
||||||
|
metadata:
|
||||||
|
labels:
|
||||||
|
app: service-docker-repository-query
|
||||||
|
spec:
|
||||||
|
imagePullSecrets:
|
||||||
|
- name: ghcr-secret
|
||||||
|
initContainers:
|
||||||
|
- 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-docker-repository-query-secrets
|
||||||
|
mountPath: /secrets
|
||||||
|
- name: writable-secrets
|
||||||
|
mountPath: /etc/secrets
|
||||||
|
containers:
|
||||||
|
- name: service-docker-repository-query
|
||||||
|
image: ghcr.io/gansejunge/app-notifications-service-docker-repository-query:19
|
||||||
|
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"
|
||||||
|
volumeMounts:
|
||||||
|
- name: writable-secrets
|
||||||
|
mountPath: /etc/secrets
|
||||||
|
volumes:
|
||||||
|
- name: service-docker-repository-query-secrets
|
||||||
|
secret:
|
||||||
|
secretName: service-docker-repository-query
|
||||||
|
- name: writable-secrets
|
||||||
|
emptyDir: {}
|
||||||
@@ -16,6 +16,23 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-secret
|
- name: ghcr-secret
|
||||||
initContainers:
|
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
|
- name: copy-secrets
|
||||||
image: busybox
|
image: busybox
|
||||||
command:
|
command:
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: service-docker-repository-query-cron-pihole
|
||||||
|
namespace: app-notifications
|
||||||
|
spec:
|
||||||
|
serviceName: service-docker-repository-query-cron-pihole
|
||||||
|
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-docker-repository-query-internal:5000/pihole
|
||||||
|
echo
|
||||||
|
echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"curl end\"}"
|
||||||
|
sleep 21600
|
||||||
|
done
|
||||||
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: service-docker-repository-query-cron-suwayomi
|
||||||
|
namespace: app-notifications
|
||||||
|
spec:
|
||||||
|
serviceName: service-docker-repository-query-cron-suwayomi
|
||||||
|
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-docker-repository-query-internal:5000/suwayomi
|
||||||
|
echo
|
||||||
|
echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"curl end\"}"
|
||||||
|
sleep 21600
|
||||||
|
done
|
||||||
@@ -6,9 +6,11 @@ metadata:
|
|||||||
spec:
|
spec:
|
||||||
schedule: "5-59/10 * * * *"
|
schedule: "5-59/10 * * * *"
|
||||||
successfulJobsHistoryLimit: 1
|
successfulJobsHistoryLimit: 1
|
||||||
|
concurrencyPolicy: Forbid
|
||||||
failedJobsHistoryLimit: 1
|
failedJobsHistoryLimit: 1
|
||||||
jobTemplate:
|
jobTemplate:
|
||||||
spec:
|
spec:
|
||||||
|
activeDeadlineSeconds: 120
|
||||||
template:
|
template:
|
||||||
spec:
|
spec:
|
||||||
containers:
|
containers:
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ spec:
|
|||||||
imagePullSecrets:
|
imagePullSecrets:
|
||||||
- name: ghcr-secret
|
- name: ghcr-secret
|
||||||
initContainers:
|
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
|
- name: copy-secrets
|
||||||
image: busybox
|
image: busybox
|
||||||
command:
|
command:
|
||||||
@@ -44,6 +61,8 @@ spec:
|
|||||||
value: "mysql.app-notifications.svc.cluster.local"
|
value: "mysql.app-notifications.svc.cluster.local"
|
||||||
- name: BACKEND_API_URL
|
- name: BACKEND_API_URL
|
||||||
value: "http://backend-api-internal.app-notifications.svc.cluster.local:8101/internal/receive-notifications"
|
value: "http://backend-api-internal.app-notifications.svc.cluster.local:8101/internal/receive-notifications"
|
||||||
|
- name: LOG_LEVEL
|
||||||
|
value: "INFO"
|
||||||
volumeMounts:
|
volumeMounts:
|
||||||
- name: writable-secrets
|
- name: writable-secrets
|
||||||
mountPath: /etc/secrets
|
mountPath: /etc/secrets
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
apiVersion: apps/v1
|
||||||
|
kind: StatefulSet
|
||||||
|
metadata:
|
||||||
|
name: service-royalroad-chapters-cron
|
||||||
|
namespace: app-notifications
|
||||||
|
spec:
|
||||||
|
serviceName: service-royalroad-chapters-cron
|
||||||
|
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-royalroad-chapters-internal:5000/royalroad
|
||||||
|
echo
|
||||||
|
echo "{\"timestamp\":\"$(date '+%Y-%m-%dT%H:%M:%S%z')\",\"event\":\"curl end\"}"
|
||||||
|
sleep 300
|
||||||
|
done
|
||||||
Reference in new issue
Block a user