From 8f470c0020e64f3bda22e0436dac981614740cdc Mon Sep 17 00:00:00 2001 From: Pavel Grancharov Date: Sun, 28 Jan 2024 14:15:28 +0200 Subject: [PATCH] Add db set up to application. --- README.md | 10 ++-- application/k8s/db-deployment.yaml | 42 +++++++++++++ application/k8s/db-volume.yaml | 26 +++++++++ application/k8s/deployment.yaml | 2 +- master/docker/entrypoint.sh | 65 +++++++++++++++++++++ master/k8s/delete-expired-deployments.yaml | 3 +- master/routes/web.php | 2 + img.png => readme/img.png | Bin img_1.png => readme/img_1.png | Bin img_2.png => readme/img_2.png | Bin img_3.png => readme/img_3.png | Bin img_4.png => readme/img_4.png | Bin 12 files changed, 143 insertions(+), 7 deletions(-) create mode 100644 application/k8s/db-deployment.yaml create mode 100644 application/k8s/db-volume.yaml create mode 100644 master/docker/entrypoint.sh rename img.png => readme/img.png (100%) rename img_1.png => readme/img_1.png (100%) rename img_2.png => readme/img_2.png (100%) rename img_3.png => readme/img_3.png (100%) rename img_4.png => readme/img_4.png (100%) diff --git a/README.md b/README.md index 6a8c5e9..a4a8ebd 100644 --- a/README.md +++ b/README.md @@ -33,21 +33,21 @@ Main focus is to provide the development team strong CI: Example with leaked api key: -![img.png](img.png) +![img.png](readme/img.png) Notification in slack: -![img_1.png](img_1.png) +![img_1.png](readme/img_1.png) ### Code linter -![img_3.png](img_3.png) +![img_3.png](readme/img_3.png) -![img_2.png](img_2.png) +![img_2.png](readme/img_2.png) ### Code coverage -![img_4.png](img_4.png) +![img_4.png](readme/img_4.png) ## Control plane diff --git a/application/k8s/db-deployment.yaml b/application/k8s/db-deployment.yaml new file mode 100644 index 0000000..6d71e24 --- /dev/null +++ b/application/k8s/db-deployment.yaml @@ -0,0 +1,42 @@ +apiVersion: v1 +kind: Service +metadata: + name: mysql +spec: + ports: + - port: 3306 + selector: + app: mysql + clusterIP: None +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mysql +spec: + selector: + matchLabels: + app: mysql + strategy: + type: Recreate + template: + metadata: + labels: + app: mysql + spec: + containers: + - image: mysql:latest + name: mysql + env: + - name: MYSQL_ROOT_PASSWORD + value: password + ports: + - containerPort: 3306 + name: mysql + volumeMounts: + - name: mysql-persistent-storage + mountPath: /var/lib/mysql + volumes: + - name: mysql-persistent-storage + persistentVolumeClaim: + claimName: mysql-pv-claim \ No newline at end of file diff --git a/application/k8s/db-volume.yaml b/application/k8s/db-volume.yaml new file mode 100644 index 0000000..a776af6 --- /dev/null +++ b/application/k8s/db-volume.yaml @@ -0,0 +1,26 @@ +apiVersion: v1 +kind: PersistentVolume +metadata: + name: mysql-pv-volume + labels: + type: local +spec: + storageClassName: manual + capacity: + storage: 1Gi + accessModes: + - ReadWriteOnce + hostPath: + path: "/mnt/data" +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: mysql-pv-claim +spec: + storageClassName: manual + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi \ No newline at end of file diff --git a/application/k8s/deployment.yaml b/application/k8s/deployment.yaml index 7cb0b1a..7141839 100644 --- a/application/k8s/deployment.yaml +++ b/application/k8s/deployment.yaml @@ -14,7 +14,7 @@ spec: spec: containers: - name: branch-deploy-application - image: dvdty/branch-deploy-application:test + image: dvdty/branch-deploy-application:latest imagePullPolicy: "Always" ports: - containerPort: 80 diff --git a/master/docker/entrypoint.sh b/master/docker/entrypoint.sh new file mode 100644 index 0000000..15d74eb --- /dev/null +++ b/master/docker/entrypoint.sh @@ -0,0 +1,65 @@ +#!/bin/sh +Red='\033[0;31m' # Red +Green='\033[0;32m' # Green +echo "" +echo "***********************************************************" +echo " Starting LARAVEL PHP-FPM Container " +echo "***********************************************************" + +set -e + +## Check if the artisan file exists +if [ -f /var/www/html/artisan ]; then + echo "${Green} artisan file found, creating laravel supervisor config..." + ##Create Laravel Scheduler process + TASK=/etc/supervisor/conf.d/laravel-worker.conf + touch $TASK + cat > "$TASK" <getDeployments()); + if ($request->has('branch') && $request->has('time')) { $kubectl->createInstance($request->input('branch'), (int) $request->input('time')); } diff --git a/img.png b/readme/img.png similarity index 100% rename from img.png rename to readme/img.png diff --git a/img_1.png b/readme/img_1.png similarity index 100% rename from img_1.png rename to readme/img_1.png diff --git a/img_2.png b/readme/img_2.png similarity index 100% rename from img_2.png rename to readme/img_2.png diff --git a/img_3.png b/readme/img_3.png similarity index 100% rename from img_3.png rename to readme/img_3.png diff --git a/img_4.png b/readme/img_4.png similarity index 100% rename from img_4.png rename to readme/img_4.png