forked from PinSpace-Org/GistPin
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit-container-ordering.yaml
More file actions
82 lines (82 loc) 路 1.88 KB
/
Copy pathinit-container-ordering.yaml
File metadata and controls
82 lines (82 loc) 路 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
apiVersion: v1
kind: ConfigMap
metadata:
name: init-container-scripts
namespace: gistpin
data:
wait-for-db.sh: |
#!/bin/sh
until pg_isready -h postgres-service -p 5432; do
echo "Waiting for database..."
sleep 2
done
echo "Database is ready."
wait-for-redis.sh: |
#!/bin/sh
until redis-cli -h redis-service ping | grep -q PONG; do
echo "Waiting for redis..."
sleep 2
done
echo "Redis is ready."
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: gistpin-backend
namespace: gistpin
spec:
replicas: 3
selector:
matchLabels:
app: gistpin-backend
template:
metadata:
labels:
app: gistpin-backend
spec:
initContainers:
- name: init-db-check
image: postgres:16-alpine
command: ["sh", "/scripts/wait-for-db.sh"]
volumeMounts:
- name: init-scripts
mountPath: /scripts
- name: init-redis-check
image: redis:7-alpine
command: ["sh", "/scripts/wait-for-redis.sh"]
volumeMounts:
- name: init-scripts
mountPath: /scripts
- name: init-migrations
image: gistpin/migrate:latest
env:
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: backend-secrets
key: database_url
containers:
- name: backend
image: gistpin/backend:latest
ports:
- containerPort: 8080
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: gistpin-backend-hpa
namespace: gistpin
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: gistpin-backend
minReplicas: 3
maxReplicas: 15
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70