Skip to content

Commit 124ba03

Browse files
Merge pull request #9 from iosifnicolae2/main
various improvements
2 parents 6e77cb9 + c855375 commit 124ba03

File tree

6 files changed

+101
-7
lines changed

6 files changed

+101
-7
lines changed

components/postgresql_instance/main.py

-6
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,13 @@ class S3BackupConfig(TypedDict, total=False):
2727
region: S3 region
2828
access_key: S3 access key
2929
secret_key: S3 secret key
30-
path: Path within the bucket (optional)
3130
"""
3231
enabled: bool
3332
endpoint: str
3433
bucket: str
3534
region: str
3635
access_key: str
3736
secret_key: str
38-
path: Optional[str]
3937

4038

4139
class S3BootstrapConfig(TypedDict, total=False):
@@ -49,15 +47,13 @@ class S3BootstrapConfig(TypedDict, total=False):
4947
region: S3 region
5048
access_key: S3 access key
5149
secret_key: S3 secret key
52-
path: Path within the bucket
5350
"""
5451
enabled: bool
5552
endpoint: str
5653
bucket: str
5754
region: str
5855
access_key: str
5956
secret_key: str
60-
path: str
6157

6258

6359
def create_postgres_instance(
@@ -338,7 +334,6 @@ def create_postgres_instance(
338334

339335
# Add S3 backup configuration if enabled
340336
**({
341-
"repo2-path": s3_backup["path"],
342337
"repo2-s3-uri-style": "path",
343338
"repo2-s3-key": s3_backup["access_key"],
344339
"repo2-s3-key-secret": s3_backup["secret_key"],
@@ -350,7 +345,6 @@ def create_postgres_instance(
350345

351346
# Add S3 bootstrap configuration if enabled
352347
**({
353-
"repo3-path": s3_bootstrap["path"],
354348
"repo3-s3-uri-style": "path",
355349
"repo3-s3-key": s3_bootstrap["access_key"],
356350
"repo3-s3-key-secret": s3_bootstrap["secret_key"],

components/whatsapp_waha/charts/whatsapp-waha/templates/deployment.yaml

+26
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,8 @@ spec:
1414
metadata:
1515
labels:
1616
{{- include "whatsapp-waha.selectorLabels" . | nindent 8 }}
17+
annotations:
18+
checksum/config: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }}
1719
spec:
1820
{{- with .Values.imagePullSecrets }}
1921
imagePullSecrets:
@@ -37,6 +39,17 @@ spec:
3739
name: {{ include "whatsapp-waha.fullname" . }}-env
3840
resources:
3941
{{- toYaml .Values.resources | nindent 12 }}
42+
{{- if or .Values.persistence.sessions.enabled .Values.persistence.media.enabled }}
43+
volumeMounts:
44+
{{- if .Values.persistence.sessions.enabled }}
45+
- name: {{ include "whatsapp-waha.fullname" . }}-sessions
46+
mountPath: /app/.sessions
47+
{{- end }}
48+
{{- if .Values.persistence.media.enabled }}
49+
- name: {{ include "whatsapp-waha.fullname" . }}-media
50+
mountPath: /app/.media
51+
{{- end }}
52+
{{- end }}
4053
{{- with .Values.nodeSelector }}
4154
nodeSelector:
4255
{{- toYaml . | nindent 8 }}
@@ -49,3 +62,16 @@ spec:
4962
tolerations:
5063
{{- toYaml . | nindent 8 }}
5164
{{- end }}
65+
{{- if or .Values.persistence.sessions.enabled .Values.persistence.media.enabled }}
66+
volumes:
67+
{{- if .Values.persistence.sessions.enabled }}
68+
- name: {{ include "whatsapp-waha.fullname" . }}-sessions
69+
persistentVolumeClaim:
70+
claimName: {{ include "whatsapp-waha.fullname" . }}-sessions-pvc
71+
{{- end }}
72+
{{- if .Values.persistence.media.enabled }}
73+
- name: {{ include "whatsapp-waha.fullname" . }}-media
74+
persistentVolumeClaim:
75+
claimName: {{ include "whatsapp-waha.fullname" . }}-media-pvc
76+
{{- end }}
77+
{{- end }}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
apiVersion: v1
2+
kind: PersistentVolumeClaim
3+
metadata:
4+
name: {{ include "whatsapp-waha.fullname" . }}-sessions-pvc
5+
labels:
6+
{{- include "whatsapp-waha.labels" . | nindent 4 }}
7+
namespace: {{ include "whatsapp-waha.namespace" . }}
8+
spec:
9+
accessModes:
10+
- ReadWriteOnce
11+
resources:
12+
requests:
13+
storage: {{ .Values.persistence.sessions.size }}
14+
{{- if .Values.persistence.sessions.storageClass }}
15+
{{- if (eq "-" .Values.persistence.sessions.storageClass) }}
16+
storageClassName: ""
17+
{{- else }}
18+
storageClassName: {{ .Values.persistence.sessions.storageClass }}
19+
{{- end }}
20+
{{- end }}
21+
22+
---
23+
apiVersion: v1
24+
kind: PersistentVolumeClaim
25+
metadata:
26+
name: {{ include "whatsapp-waha.fullname" . }}-media-pvc
27+
labels:
28+
{{- include "whatsapp-waha.labels" . | nindent 4 }}
29+
namespace: {{ include "whatsapp-waha.namespace" . }}
30+
spec:
31+
accessModes:
32+
- ReadWriteOnce
33+
resources:
34+
requests:
35+
storage: {{ .Values.persistence.media.size }}
36+
{{- if .Values.persistence.media.storageClass }}
37+
{{- if (eq "-" .Values.persistence.media.storageClass) }}
38+
storageClassName: ""
39+
{{- else }}
40+
storageClassName: {{ .Values.persistence.media.storageClass }}
41+
{{- end }}
42+
{{- end }}

components/whatsapp_waha/charts/whatsapp-waha/values.yaml

+13
Original file line numberDiff line numberDiff line change
@@ -76,3 +76,16 @@ nodeSelector: {}
7676
tolerations: []
7777

7878
affinity: {}
79+
80+
# Persistence configuration for WhatsApp sessions and media
81+
persistence:
82+
# Sessions volume configuration
83+
sessions:
84+
enabled: true
85+
size: "1Gi"
86+
storageClass: ""
87+
# Media volume configuration
88+
media:
89+
enabled: true
90+
size: "10Gi"
91+
storageClass: ""

components/whatsapp_waha/main.py

+20
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ def create_whatsapp_waha(
5050
username: Optional[str] = None,
5151
password: Optional[str] = None,
5252
basic_auth_realm: str = "Authentication Required",
53+
persistence_enabled: bool = True,
54+
sessions_volume_size: str = "10Gi",
55+
media_volume_size: str = "20Gi",
56+
storage_class: str = "",
5357
depends_on: Optional[List[Component]] = None
5458
) -> Component:
5559
"""
@@ -72,6 +76,10 @@ def create_whatsapp_waha(
7276
username: Username for basic auth (required if basic_auth_enabled is True)
7377
password: Password for basic auth (required if basic_auth_enabled is True)
7478
basic_auth_realm: Realm for basic auth
79+
persistence_enabled: Whether to enable persistent volumes for sessions and media
80+
sessions_volume_size: Size of the sessions volume (e.g., "1Gi")
81+
media_volume_size: Size of the media volume (e.g., "10Gi")
82+
storage_class: Storage class to use for persistent volumes
7583
depends_on: List of dependencies for Fleet
7684
7785
Returns:
@@ -146,6 +154,18 @@ def create_whatsapp_waha(
146154
"enabled": basic_auth_enabled,
147155
"secretName": basic_auth_secret,
148156
"realm": basic_auth_realm
157+
},
158+
"persistence": {
159+
"sessions": {
160+
"enabled": persistence_enabled,
161+
"size": sessions_volume_size,
162+
"storageClass": storage_class
163+
},
164+
"media": {
165+
"enabled": persistence_enabled,
166+
"size": media_volume_size,
167+
"storageClass": storage_class
168+
}
149169
}
150170
}
151171

environments/sample_environment/secrets/config_env.yaml.example

-1
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ components:
7979
region: us-east-1
8080
key: your-access-key
8181
key_secret: your-secret-key
82-
repo_path: /path/to/backup
8382
# Optional S3 storage configuration for WhatsApp data
8483
s3_storage:
8584
bucket: your-whatsapp-data-bucket

0 commit comments

Comments
 (0)