diff --git a/deploy.sh b/deploy.sh index 4eeee35..f63d9cf 100644 --- a/deploy.sh +++ b/deploy.sh @@ -5,7 +5,6 @@ if [ "$GITHUB_USERNAME" == "your_github_username" ]; then echo "you buffoon change your github username in the file." exit 1 fi - replace_placeholders() { sed -i "s|ghcr.io/informaticker/zli-counter-frontend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-frontend:${VERSION}|g" deployment/frontend.yaml sed -i "s|ghcr.io/informaticker/zli-counter-backend:v1|ghcr.io/${GITHUB_USERNAME}/zli-counter-backend:${VERSION}|g" deployment/backend.yaml @@ -18,7 +17,9 @@ replace_placeholders oc apply -f deployment/configmap.yaml oc apply -f deployment/secrets.yaml oc apply -f deployment/database.yaml +oc apply -f deployment/pvc.yaml oc apply -f deployment/backend.yaml oc apply -f deployment/frontend.yaml +oc apply -f deployment/hpa.yaml echo "Deployment completed successfully! ^w^" \ No newline at end of file diff --git a/deployment/database.yaml b/deployment/database.yaml index 4a61c35..6afde39 100644 --- a/deployment/database.yaml +++ b/deployment/database.yaml @@ -35,6 +35,13 @@ spec: secretKeyRef: name: counter-database key: database-name + volumeMounts: + - name: postgresql-data + mountPath: /var/lib/pgsql/data + volumes: + - name: postgresql-data + persistentVolumeClaim: + claimName: counter-database-pvc --- apiVersion: v1 @@ -47,4 +54,4 @@ spec: ports: - protocol: TCP port: 5432 - targetPort: 5432 + targetPort: 5432 \ No newline at end of file diff --git a/deployment/hpa.yaml b/deployment/hpa.yaml new file mode 100644 index 0000000..19a9128 --- /dev/null +++ b/deployment/hpa.yaml @@ -0,0 +1,39 @@ +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: counter-backend +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: counter-backend + minReplicas: 2 + maxReplicas: 8 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 + +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: counter-frontend +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: counter-frontend + minReplicas: 2 + maxReplicas: 12 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 50 \ No newline at end of file diff --git a/deployment/pvc.yaml b/deployment/pvc.yaml new file mode 100644 index 0000000..29404c9 --- /dev/null +++ b/deployment/pvc.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: counter-database-pvc +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi