Skip to content

Commit bf3723d

Browse files
committed
fix: ha on mongodb
1 parent 2077bb6 commit bf3723d

File tree

7 files changed

+68
-27
lines changed

7 files changed

+68
-27
lines changed
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
dependencies:
22
- name: mongodb
3-
repository: https://cloudpirates-io.github.io/helm-charts
4-
version: 0.6.6
3+
repository: https://groundhog2k.github.io/helm-charts/
4+
version: 0.7.6
55
- name: valkey
66
repository: https://cloudpirates-io.github.io/helm-charts
77
version: 0.10.3
8-
digest: sha256:8a6b533942832deab6ba228fd6f94a665609601d19f02e80c19fd81f2fe494ea
9-
generated: "2025-12-03T16:48:29.358826904+01:00"
8+
digest: sha256:b6e79bcd1fade97969b990ce190ec6fc1a696b196d11e4278577164e102028b8
9+
generated: "2025-12-03T18:59:17.633294114+01:00"

charts/no-package-malware/Chart.yaml

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,12 @@ sources:
1919
maintainers:
2020
- name: SocialGouv
2121

22-
# MongoDB and Valkey subcharts for HA setups (CloudPirates charts)
22+
# MongoDB and Valkey subcharts for HA setups
2323
dependencies:
2424
- name: mongodb
25-
alias: mongodbha
26-
version: 0.6.6
27-
repository: https://cloudpirates-io.github.io/helm-charts
28-
condition: mongodbha.enabled
25+
version: 0.7.6
26+
repository: https://groundhog2k.github.io/helm-charts/
27+
condition: mongodb.enabled
2928
- name: valkey
3029
alias: valkeyha
3130
version: 0.10.3
-26.3 KB
Binary file not shown.
15 KB
Binary file not shown.

charts/no-package-malware/templates/_helpers.tpl

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,18 @@ app.kubernetes.io/instance: {{ .Release.Name }}
3939
"no-package-malware.local"
4040
{{- end -}}
4141
{{- end -}}
42+
43+
{{/* Build a MongoDB replica set connection URI for the embedded mongodb subchart */}}
44+
{{- define "no-package-malware.mongodb.replUri" -}}
45+
{{- $name := printf "%s-mongodb" .Release.Name -}}
46+
{{- $svcSuffix := default "internal" .Values.mongodb.service.headlessServiceSuffix -}}
47+
{{- $replName := default "repl" .Values.mongodb.replicaSet.name -}}
48+
{{- $secondaries := int (default 0 .Values.mongodb.replicaSet.secondaries) -}}
49+
{{- $members := add 1 $secondaries -}} {{/* primary + secondaries */}}
50+
{{- $hosts := list -}}
51+
{{- range $i, $_ := until $members -}}
52+
{{- $host := printf "%s-%d.%s-%s:27017" $name $i $name $svcSuffix -}}
53+
{{- $hosts = append $hosts $host -}}
54+
{{- end -}}
55+
{{- printf "mongodb://%s/?replicaSet=%s" (join "," $hosts) $replName -}}
56+
{{- end -}}

charts/no-package-malware/templates/api.deployment.yaml

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,13 +31,16 @@ spec:
3131
imagePullPolicy: {{ .Values.image.api.pullPolicy }}
3232
env:
3333
{{/* Derive Mongo and Valkey connection settings with sensible defaults.
34-
Defaults point at the CloudPirates subcharts (mongodbha / valkeyha)
34+
Defaults point at the embedded subcharts (mongodb / valkeyha)
3535
but can be overridden via .Values.mongo.uri and .Values.valkey.*
3636
for external clusters. */}}
3737
{{- $release := .Release.Name }}
3838

39-
{{- $mongoDefaultHost := printf "%s-mongodbha" $release }}
40-
{{- $mongoDefaultUri := printf "mongodb://%s:27017" $mongoDefaultHost }}
39+
{{- /* Default Mongo URI: in-cluster mongodb service when enabled */ -}}
40+
{{- $mongoDefaultUri := printf "mongodb://%s-mongodb:27017" $release }}
41+
{{- if and .Values.mongodb.enabled .Values.mongodb.replicaSet.enabled }}
42+
{{- $mongoDefaultUri = include "no-package-malware.mongodb.replUri" . }}
43+
{{- end }}
4144
{{- $mongoUri := default $mongoDefaultUri .Values.mongo.uri }}
4245

4346
{{- $valkeyDefaultHost := printf "%s-valkeyha" $release }}
@@ -52,7 +55,7 @@ spec:
5255
- name: SECURITY_DB_URI
5356
value: {{ $mongoUri | quote }}
5457
- name: SECURITY_DB_NAME
55-
value: {{ .Values.app.securityDbName | quote }}
58+
value: {{ .Values.mongo.dbName | quote }}
5659
- name: REDIS_URL
5760
value: {{ printf "redis://%s:%d" $valkeyHost (int $valkeyPort) | quote }}
5861
- name: AUDIT_RATE_LIMIT_REDIS_URL

charts/no-package-malware/values.yaml

Lines changed: 38 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ image:
1717

1818
# Global settings for the application.
1919
app:
20-
securityDbName: secure_registry
21-
2220
ports:
2321
decisionApi: 4000
2422
accessAdminApi: 4100
@@ -46,6 +44,16 @@ app:
4644
registryStrictUrl: "http://localhost:4873"
4745
registryLenientUrl: "http://localhost:4874"
4846

47+
# MongoDB connection settings used by the application.
48+
mongo:
49+
# Connection URI for MongoDB.
50+
# Must be set in environment-specific values (dev/prod) if you want a DB.
51+
# If left empty and mongodb.enabled=true, we’ll default to the in-cluster mongodb service.
52+
uri: ""
53+
54+
# Logical database name for the app
55+
dbName: secure_registry
56+
4957
# Admin credentials for the access-admin API (login to the admin dashboard)
5058
accessAdmin:
5159
# Default bootstrap credentials (dev/demo only). These are only used when
@@ -81,14 +89,6 @@ openai:
8189
# Key in the secret that stores the API key.
8290
secretKey: OPENAI_API_KEY
8391

84-
# MongoDB connection used by the application.
85-
# MongoDB itself is provided by the CloudPirates mongodb subchart (mongodbha)
86-
# or by an external service.
87-
mongo:
88-
# Connection URI for MongoDB.
89-
# Defaults to mongodb://<release>-mongodbha:27017 when empty and mongodbha.enabled=true.
90-
uri: ""
91-
9292
# Valkey (Redis-compatible) connection used by the application.
9393
# Valkey itself is provided by the CloudPirates valkey subchart (valkeyha)
9494
# or by an external service.
@@ -105,13 +105,37 @@ valkey:
105105
host: ""
106106
port: 26379
107107

108-
# CloudPirates MongoDB subchart configuration (see charts/mongodb values for details).
108+
# Groundhog2k MongoDB subchart configuration (see charts/mongodb values for details).
109109
# Enable this to deploy MongoDB as part of this release.
110-
mongodbha:
110+
mongodb:
111111
enabled: false
112-
replicaCount: 1
113-
auth:
112+
113+
# High-availability / replica set mode.
114+
replicaSet:
114115
enabled: false
116+
name: repl
117+
secondaries: 2
118+
arbiter:
119+
enabled: false
120+
121+
# Storage configuration for primary and all secondaries.
122+
storage:
123+
requestedSize: 10Gi
124+
className: ""
125+
accessModes:
126+
- ReadWriteOnce
127+
keepPvc: false
128+
129+
# Optional authentication (disabled by default).
130+
settings:
131+
rootUsername: ""
132+
rootPassword: ""
133+
134+
# Optional user database created on first start-up.
135+
userDatabase: {}
136+
# name: secure_registry
137+
# user: app
138+
# password: change-me
115139

116140
# CloudPirates Valkey subchart configuration (see charts/valkey values for details).
117141
# Enable this to deploy Valkey as part of this release.

0 commit comments

Comments
 (0)