ci: Updated manifest.yaml

This commit is contained in:
Noah Lancien 2025-02-05 18:06:00 +01:00
parent 058979eb04
commit a0ca50ad4e
3 changed files with 102 additions and 50 deletions

View file

@ -6,6 +6,7 @@ APP_URL=http://localhost
APP_URL_FRONT=
LOG_CHANNEL=stack
LOG_LEVEL=debug
DB_HOST=127.0.0.1
DB_DATABASE=laravel

30
k8s-queues.sh Normal file
View file

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# From https://stackoverflow.com/a/76488746/17320077
work=true
function stopQueues() {
echo "Stopping queues..."
work=false
php artisan queue:restart
sleep 45s
exit 0
}
# handle graceful shutdown
trap "" SIGPIPE
trap stopQueues EXIT
echo "Starting PHP queue workers..."
while $work; do
php artisan queue:work database --queue=default,database --sleep=3 --tries=3 --max-time=3600 --no-interaction
sleep 1
done
# Si besoin de plusieurs threads puis terminer par un done sans &
#(while $work; do
# php artisan queue:work --queue="$(grep -oP 'SQS_QUEUE=\K.*' .env)" --no-interaction
# sleep 1
#done &)

View file

@ -10,6 +10,7 @@ data:
APP_URL: "https://${APP_DOMAIN}"
APP_URL_FRONT: "${APP_APP_URL_FRONT}"
LOG_CHANNEL: "k8s"
LOG_LEVEL: "${APP_LOG_LEVEL}"
DB_HOST: "mariadb.common-services"
DB_DATABASE: "${APP_DB_DATABASE}"
DB_USERNAME: "${APP_DB_USERNAME}"
@ -23,6 +24,7 @@ data:
MAIL_FROM_NAME: "${APP_APP_NAME}"
LDC_WEB_API_KEY: "${APP_LDC_WEB_API_KEY}"
SENTRY_LARAVEL_DSN: "${APP_SENTRY_LARAVEL_DSN}"
QUEUE_CONNECTION: "${APP_QUEUE_CONNECTION}"
---
apiVersion: v1
@ -32,7 +34,7 @@ metadata:
spec:
storageClassName: "csi-cinder-classic"
accessModes:
- ReadWriteOnce
- ReadWriteOnce
resources:
requests:
storage: $APP_PVC_SIZE
@ -53,28 +55,47 @@ spec:
app: ${CI_PROJECT_PATH_SLUG}-app
spec:
containers:
- name: ${CI_PROJECT_PATH_SLUG}-container
image: $IMAGE_TAG
imagePullPolicy: Always
envFrom:
- configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map
volumeMounts:
- name: storage
mountPath: /app/srcs/storage/app/public
- name: ${CI_PROJECT_PATH_SLUG}-container
image: $IMAGE_TAG
envFrom:
- configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map
volumeMounts:
- name: storage
mountPath: /app/srcs/storage/app/public
- name: ${CI_PROJECT_PATH_SLUG}-queue-worker
image: $IMAGE_TAG
lifecycle:
preStop:
exec:
command:
[
"/bin/sh",
"-c",
"kill -s TERM 1; while test $(ps ax | grep -v grep | grep bash | wc -l) -gt 0; do sleep 2s; done",
]
command:
- "bash"
args:
- "k8s-queues.sh"
envFrom:
- configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map
volumeMounts:
- name: storage
mountPath: /app/srcs/storage
imagePullSecrets:
- name: docker-registry-credentials
- name: docker-registry-credentials
volumes:
- name: storage
persistentVolumeClaim:
claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage
- name: storage
persistentVolumeClaim:
claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage
securityContext:
runAsUser: 33
runAsGroup: 33
fsGroup: 33
fsGroupChangePolicy: "OnRootMismatch"
---
apiVersion: v1
kind: Service
@ -84,8 +105,8 @@ spec:
selector:
app: ${CI_PROJECT_PATH_SLUG}-app
ports:
- port: 80
targetPort: 443
- port: 80
targetPort: 443
---
apiVersion: traefik.io/v1alpha1
@ -94,14 +115,14 @@ metadata:
name: ${CI_PROJECT_PATH_SLUG}-ingress-route
spec:
entryPoints:
- web
- websecure
- web
- websecure
routes:
- match: Host(`$APP_DOMAIN`)
kind: Rule
services:
- name: ${CI_PROJECT_PATH_SLUG}-service
port: 80
- match: Host(`$APP_DOMAIN`)
kind: Rule
services:
- name: ${CI_PROJECT_PATH_SLUG}-service
port: 80
tls:
secretName: ${CRT_TLS_NAME}
@ -120,35 +141,35 @@ spec:
affinity:
podAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- ${CI_PROJECT_PATH_SLUG}-app
topologyKey: "kubernetes.io/hostname"
namespaces: [$KUBE_NAMESPACE]
- labelSelector:
matchExpressions:
- key: app
operator: In
values:
- ${CI_PROJECT_PATH_SLUG}-app
topologyKey: "kubernetes.io/hostname"
namespaces: [$KUBE_NAMESPACE]
containers:
- name: ${CI_PROJECT_PATH_SLUG}-scheduled
image: $IMAGE_TAG
imagePullPolicy: Always
command:
- "php"
args:
- "artisan"
- "schedule:run"
envFrom:
- configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map
volumeMounts:
- name: storage
mountPath: /app/srcs/storage/app/public
- name: ${CI_PROJECT_PATH_SLUG}-scheduled
image: $IMAGE_TAG
imagePullPolicy: IfNotPresent
command:
- "php"
args:
- "artisan"
- "schedule:run"
envFrom:
- configMapRef:
name: ${CI_PROJECT_PATH_SLUG}-config-map
volumeMounts:
- name: storage
mountPath: /app/srcs/storage/app/public
imagePullSecrets:
- name: docker-registry-credentials
- name: docker-registry-credentials
volumes:
- name: storage
persistentVolumeClaim:
claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage
- name: storage
persistentVolumeClaim:
claimName: ${CI_PROJECT_PATH_SLUG}-pvc-storage
securityContext:
runAsUser: 33
runAsGroup: 33