Skip to content

Commit feda3e9

Browse files
feat: add mongodb subchart (#132)
1 parent 1865b2c commit feda3e9

8 files changed

Lines changed: 203 additions & 0 deletions

File tree

charts/mongodb/.helmignore

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Patterns to ignore when building packages.
2+
# This supports shell glob matching, relative path matching, and
3+
# negation (prefixed with !). Only one pattern per line.
4+
.DS_Store
5+
# Common VCS dirs
6+
.git/
7+
.gitignore
8+
.bzr/
9+
.bzrignore
10+
.hg/
11+
.hgignore
12+
.svn/
13+
# Common backup files
14+
*.swp
15+
*.bak
16+
*.tmp
17+
*.orig
18+
*~
19+
# Various IDEs
20+
.project
21+
.idea/
22+
*.tmproj
23+
.vscode/

charts/mongodb/Chart.yaml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
apiVersion: v2
2+
name: mongodb
3+
description: MongoDB database Helm chart
4+
version: 0.1.0
5+
appVersion: "7.0"
6+
type: application
7+
keywords:
8+
- mongodb
9+
- database
10+
- nosql
11+
home: https://codefresh.io/
12+
maintainers:
13+
- name: codefresh
14+
url: https://codefresh-io.github.io/
15+
dependencies:
16+
- name: cf-common
17+
repository: oci://quay.io/codefresh/charts
18+
version: "0.31.0"
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.configmaps" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.controller" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
{{- if .Values.config.net.tls }}
2+
apiVersion: batch/v1
3+
kind: Job
4+
metadata:
5+
name: mongodb-tls-init
6+
annotations:
7+
helm.sh/hook: post-install,post-upgrade
8+
helm.sh/hook-weight: "-5"
9+
helm.sh/hook-delete-policy: before-hook-creation
10+
spec:
11+
template:
12+
metadata:
13+
name: mongodb-tls-init
14+
spec:
15+
restartPolicy: Never
16+
containers:
17+
- name: mongodb-tls-init
18+
image: {{ printf "%s/%s:%s" .Values.container.image.registry .Values.container.image.repository .Values.container.image.tag }}
19+
imagePullPolicy: {{ .Values.container.image.pullPolicy }}
20+
env:
21+
- name: MONGO_INITDB_ROOT_USERNAME
22+
value: {{ .Values.auth.rootUser }}
23+
- name: MONGO_INITDB_ROOT_PASSWORD
24+
value: {{ .Values.auth.rootPassword }}
25+
- name: MONGO_HOSTNAME
26+
value: {{ .Values.fullnameOverride }}
27+
command:
28+
- /bin/bash
29+
- -c
30+
- |
31+
MONGO_URI="mongodb://$MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD@$MONGO_HOSTNAME:27017/?authSource=admin"
32+
33+
mongosh "$MONGO_URI" --eval 'db.getSiblingDB("\$external").runCommand( { createUser: "O=CfClients,CN=cfuser", roles: [ { role: "readWrite", db: "test" }, { role: "userAdminAnyDatabase", db: "admin" }, { role: "readWrite", db: "codefresh" }, { role: "readWrite", db: "pipeline-manager" }, { role: "readWrite", db: "runtime-environment-manager" }, { role: "readWrite", db: "context-manager" }, { role: "readWrite", db: "cluster-providers" }, { role: "readWrite", db: "charts-manager" }, { role: "readWrite", db: "k8s-monitor" }, { role: "readWrite", db: "read-models" }, { role: "readWrite", db: "audit" }, { role: "readWrite", db: "platform-analytics-postgres" } ], writeConcern: { w: "majority" , wtimeout: 5000 } } )'
34+
{{- end }}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.secrets" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
{{ $templateName := printf "cf-common-%s.service" (index .Subcharts "cf-common").Chart.Version }}
2+
{{- include $templateName . -}}

charts/mongodb/values.yaml

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
1+
fullnameOverride: mongodb
2+
3+
auth:
4+
rootUser: root
5+
rootPassword: password
6+
database: ""
7+
8+
config:
9+
storage:
10+
dbPath: /data/db
11+
net:
12+
port: 27017
13+
bindIp: 0.0.0.0
14+
15+
global: {}
16+
17+
controller:
18+
enabled: true
19+
type: statefulset
20+
replicas: 1
21+
podManagementPolicy: OrderedReady
22+
23+
container:
24+
image:
25+
registry: docker.io
26+
repository: mongo
27+
tag: "7.0"
28+
pullPolicy: IfNotPresent
29+
30+
args:
31+
- "--config"
32+
- "/etc/mongod.conf"
33+
34+
probes:
35+
liveness:
36+
enabled: true
37+
type: exec
38+
exec:
39+
command:
40+
- mongosh
41+
- --eval
42+
- "db.adminCommand('ping')"
43+
spec:
44+
initialDelaySeconds: 30
45+
periodSeconds: 20
46+
timeoutSeconds: 10
47+
successThreshold: 1
48+
failureThreshold: 6
49+
readiness:
50+
enabled: true
51+
type: exec
52+
exec:
53+
command:
54+
- mongosh
55+
- --eval
56+
- "db.adminCommand('ping')"
57+
spec:
58+
initialDelaySeconds: 5
59+
periodSeconds: 10
60+
timeoutSeconds: 5
61+
successThreshold: 1
62+
failureThreshold: 6
63+
64+
resources:
65+
requests:
66+
cpu: 100m
67+
memory: 256Mi
68+
limits:
69+
cpu: 500m
70+
memory: 512Mi
71+
72+
volumeMounts:
73+
config:
74+
path:
75+
- mountPath: /etc/mongod.conf
76+
subPath: mongod.conf
77+
78+
volumeClaimTemplates:
79+
data:
80+
mountPath: /data/db
81+
accessMode: ReadWriteOnce
82+
size: 10Gi
83+
storageClass:
84+
85+
secrets:
86+
secret:
87+
enabled: true
88+
stringData: |
89+
MONGO_INITDB_ROOT_USERNAME: "{{ .Values.auth.rootUser }}"
90+
MONGO_INITDB_ROOT_PASSWORD: "{{ required ".Values.auth.rootPassword is required" .Values.auth.rootPassword }}"
91+
{{- if .Values.auth.database }}
92+
MONGO_INITDB_DATABASE: "{{ .Values.auth.database }}"
93+
{{- end }}
94+
95+
configMaps:
96+
config:
97+
enabled: true
98+
data:
99+
mongod.conf: |
100+
{{- toYaml .Values.config | nindent 2 }}
101+
102+
volumes:
103+
config:
104+
enabled: true
105+
type: configMap
106+
107+
service:
108+
main:
109+
enabled: true
110+
primary: true
111+
type: ClusterIP
112+
ports:
113+
mongodb:
114+
port: 27017
115+
protocol: TCP
116+
117+
podSecurityContext: {}
118+
nodeSelector: {}
119+
tolerations: []
120+
affinity: {}

0 commit comments

Comments
 (0)