-
-
Notifications
You must be signed in to change notification settings - Fork 123
Expand file tree
/
Copy pathdeployment.yaml
More file actions
341 lines (340 loc) · 8.34 KB
/
Copy pathdeployment.yaml
File metadata and controls
341 lines (340 loc) · 8.34 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
# audiomuse-ai-deployment.yaml
---
apiVersion: v1
kind: Namespace
metadata:
name: playlist
---
apiVersion: v1
kind: Secret
metadata:
name: postgres-credentials
namespace: playlist
type: Opaque
stringData:
POSTGRES_USER: "audiomuse" # As used in app.py
POSTGRES_PASSWORD: "audiomusepassword" # As used in app.py
POSTGRES_DB: "audiomusedb" # As used in app.py
---
apiVersion: v1
kind: ConfigMap
metadata:
name: audiomuse-ai-config
namespace: playlist
data:
POSTGRES_HOST: "postgres-service.playlist" # Database host
POSTGRES_PORT: "5432" # Database port
REDIS_URL: "redis://redis-service.playlist:6379/0"
# Timezone applied inside containers. Default is UTC but you may set this in the ConfigMap or via deployment overrides
TZ: "UTC"
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-master
namespace: playlist
labels:
app: redis
tier: backend
spec:
replicas: 1
selector:
matchLabels:
app: redis
tier: backend
template:
metadata:
labels:
app: redis
tier: backend
spec:
containers:
- name: master
image: redis:7-alpine # Lightweight Redis image
env:
- name: TZ
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: TZ
resources:
limits:
cpu: 2000m
memory: 8000Mi
requests:
cpu: 2000m
memory: 8000Mi
ports:
- containerPort: 6379
---
apiVersion: v1
kind: Service
metadata:
name: redis-service
namespace: playlist
labels:
app: redis
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
tier: backend
type: ClusterIP # Internal service only
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: postgres-pvc
namespace: playlist
spec:
accessModes:
- ReadWriteOnce # Suitable for a single PostgreSQL instance
resources:
requests:
storage: 5Gi # Adjust storage size as needed
# storageClassName: "your-storage-class" # Uncomment and specify if you have a specific storage class
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: postgres-deployment
namespace: playlist
labels:
app: postgres
tier: database
spec:
replicas: 1
selector:
matchLabels:
app: postgres
tier: database
template:
metadata:
labels:
app: postgres
tier: database
spec:
containers:
- name: postgres
image: postgres:15-alpine # Using PostgreSQL 15
imagePullPolicy: "IfNotPresent"
ports:
- containerPort: 5432
env:
- name: TZ
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: TZ
envFrom:
- secretRef:
name: postgres-credentials
volumeMounts:
- name: postgres-storage
mountPath: /var/lib/postgresql/data
resources:
limits:
cpu: "1"
memory: "8Gi"
requests:
cpu: "250m"
memory: "256Mi"
volumes:
- name: postgres-storage
persistentVolumeClaim:
claimName: postgres-pvc
---
apiVersion: v1
kind: Service
metadata:
name: postgres-service # Service name used in DATABASE_URL
namespace: playlist
spec:
selector:
app: postgres
ports:
- protocol: TCP
port: 5432 # Default PostgreSQL port
targetPort: 5432
type: ClusterIP # Internal service
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: audiomuse-ai-flask
namespace: playlist
labels:
app: audiomuse-ai
component: flask
spec:
replicas: 1
selector:
matchLabels:
app: audiomuse-ai
component: flask
template:
metadata:
labels:
app: audiomuse-ai
component: flask
spec:
securityContext:
runAsUser: 0 # Or a non-root user if your image supports it
runAsGroup: 0 # Added fsGroup for consistency if needed by volumes
fsGroup: 0
containers:
- name: flask-app
image: ghcr.io/neptunehub/audiomuse-ai:latest # Your image from GHCR
imagePullPolicy: Always
ports:
- containerPort: 8000 # Flask app listens on 8000
env:
- name: SERVICE_TYPE
value: "flask" # Tells the container to run the Flask app
- name: TZ
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: TZ
# --- Load PostgreSQL Credentials from Secret ---
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_USER
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_PASSWORD
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_DB
# --- Load non-sensitive DB parts from ConfigMap ---
- name: POSTGRES_HOST
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: POSTGRES_HOST
- name: POSTGRES_PORT
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: POSTGRES_PORT
# --- Load minimal connection configuration from the ConfigMap ---
envFrom:
- configMapRef:
name: audiomuse-ai-config
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
volumeMounts:
- name: app-temp-audio
mountPath: /app/temp_audio
volumes:
- name: app-temp-audio
emptyDir: {}
---
apiVersion: v1
kind: Service
metadata:
name: audiomuse-ai-flask-service
namespace: playlist
labels:
app: audiomuse-ai
component: flask
spec:
selector:
app: audiomuse-ai
component: flask
ports:
- protocol: TCP
port: 8000 # Service port (what you connect to)
targetPort: 8000 # Container port (what the app listens on)
type: LoadBalancer # Or NodePort/ClusterIP depending on your K3S setup
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: audiomuse-ai-worker
namespace: playlist
labels:
app: audiomuse-ai
component: worker
spec:
replicas: 3 # Scale as needed. Each replica runs both a high-priority and a default-priority worker process.
selector:
matchLabels:
app: audiomuse-ai
component: worker
template:
metadata:
labels:
app: audiomuse-ai
component: worker
spec:
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0
containers:
- name: rq-worker
image: ghcr.io/neptunehub/audiomuse-ai:latest # Your image from GHCR
imagePullPolicy: Always
env:
- name: SERVICE_TYPE
value: "worker" # Tells the container to run the RQ worker
- name: TZ
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: TZ
# --- Load PostgreSQL Credentials from Secret ---
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_USER
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_PASSWORD
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: postgres-credentials
key: POSTGRES_DB
# --- Load non-sensitive DB parts from ConfigMap ---
- name: POSTGRES_HOST
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: POSTGRES_HOST
- name: POSTGRES_PORT
valueFrom:
configMapKeyRef:
name: audiomuse-ai-config
key: POSTGRES_PORT
# --- Load minimal connection configuration from the ConfigMap ---
envFrom:
- configMapRef:
name: audiomuse-ai-config
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop:
- ALL
volumeMounts:
- name: app-temp-audio
mountPath: /app/temp_audio
volumes:
- name: app-temp-audio
emptyDir: {}