Skip to content

Commit 0278871

Browse files
committed
feat(documentdb): Add FerretDB gateway deployment support
Signed-off-by: P-Louw <[email protected]>
1 parent e7ae872 commit 0278871

File tree

2 files changed

+111
-0
lines changed

2 files changed

+111
-0
lines changed
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
{{ if and (eq .Values.type "documentdb") .Values.ferretdb.enabled }}
2+
{{- $dbOwner := .Values.cluster.initdb.owner | default .Values.cluster.initdb.database | default "app" }}
3+
{{- $dbName := .Values.cluster.initdb.database | default "app" }}
4+
---
5+
apiVersion: apps/v1
6+
kind: Deployment
7+
metadata:
8+
name: {{ include "cluster.fullname" . }}-ferretdb
9+
namespace: {{ include "cluster.namespace" . }}
10+
labels:
11+
{{- include "cluster.labels" . | nindent 4 }}
12+
app.kubernetes.io/component: ferretdb
13+
spec:
14+
replicas: {{ .Values.ferretdb.instances }}
15+
selector:
16+
matchLabels:
17+
{{- include "cluster.selectorLabels" . | nindent 6 }}
18+
app.kubernetes.io/component: ferretdb
19+
template:
20+
metadata:
21+
labels:
22+
{{- include "cluster.selectorLabels" . | nindent 8 }}
23+
app.kubernetes.io/component: ferretdb
24+
spec:
25+
containers:
26+
- name: ferretdb
27+
image: {{ .Values.ferretdb.image | default "ghcr.io/ferretdb/ferretdb" }}:{{ .Values.ferretdb.tag | default .Values.version.ferretdb }}
28+
imagePullPolicy: {{ .Values.cluster.imagePullPolicy }}
29+
ports:
30+
- name: mongodb
31+
containerPort: 27017
32+
protocol: TCP
33+
command: ["/ferretdb"]
34+
args:
35+
- "--listen-addr=:27017"
36+
- "--postgresql-url=postgres://{{ $dbOwner }}@{{ include "cluster.fullname" . }}-rw:5432/{{ $dbName }}"
37+
- "--telemetry=disable"
38+
- "--log-level=info"
39+
env:
40+
{{- if .Values.cluster.initdb.secret }}
41+
- name: PGPASSWORD
42+
valueFrom:
43+
secretKeyRef:
44+
name: {{ .Values.cluster.initdb.secret.name }}
45+
key: password
46+
{{- else }}
47+
- name: PGPASSWORD
48+
valueFrom:
49+
secretKeyRef:
50+
name: {{ include "cluster.fullname" . }}-app
51+
key: password
52+
{{- end }}
53+
{{- with .Values.ferretdb.env }}
54+
{{- toYaml . | nindent 8 }}
55+
{{- end }}
56+
{{- with .Values.ferretdb.resources }}
57+
resources:
58+
{{- toYaml . | nindent 10 }}
59+
{{- end }}
60+
livenessProbe:
61+
tcpSocket:
62+
port: 27017
63+
initialDelaySeconds: 10
64+
periodSeconds: 10
65+
readinessProbe:
66+
tcpSocket:
67+
port: 27017
68+
initialDelaySeconds: 5
69+
periodSeconds: 5
70+
---
71+
apiVersion: v1
72+
kind: Service
73+
metadata:
74+
name: {{ include "cluster.fullname" . }}-ferretdb
75+
namespace: {{ include "cluster.namespace" . }}
76+
labels:
77+
{{- include "cluster.labels" . | nindent 4 }}
78+
app.kubernetes.io/component: ferretdb
79+
spec:
80+
type: ClusterIP
81+
ports:
82+
- name: mongodb
83+
port: 27017
84+
targetPort: 27017
85+
protocol: TCP
86+
selector:
87+
{{- include "cluster.selectorLabels" . | nindent 4 }}
88+
app.kubernetes.io/component: ferretdb
89+
{{- end }}

charts/cluster/values.yaml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -487,6 +487,28 @@ imageCatalog:
487487
# - image: ghcr.io/your_repo/your_image:your_tag
488488
# major: 16
489489

490+
# -- FerretDB gateway (DocumentDB only)
491+
# Provides MongoDB wire protocol (port 27017) for existing MongoDB applications
492+
ferretdb:
493+
# -- Enable FerretDB gateway (only for type: documentdb)
494+
enabled: false
495+
# -- Number of FerretDB instances
496+
instances: 1
497+
# -- FerretDB image (defaults to ghcr.io/ferretdb/ferretdb)
498+
image: ""
499+
# -- FerretDB image tag (defaults to version.ferretdb)
500+
tag: ""
501+
# -- Container resources
502+
resources: {}
503+
# limits:
504+
# cpu: 500m
505+
# memory: 512Mi
506+
# requests:
507+
# cpu: 250m
508+
# memory: 256Mi
509+
# -- Additional environment variables
510+
env: []
511+
490512
# -- List of PgBouncer poolers
491513
poolers: []
492514
# -

0 commit comments

Comments
 (0)