Add Autoscalers and PVC for DB

This commit is contained in:
root 2024-07-02 12:09:47 +00:00
parent db97a4715f
commit fdf9ff9198
4 changed files with 60 additions and 2 deletions

View File

@ -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^"

View File

@ -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

39
deployment/hpa.yaml Normal file
View File

@ -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

11
deployment/pvc.yaml Normal file
View File

@ -0,0 +1,11 @@
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: counter-database-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi