Skip to content

Commit ffcd3b9

Browse files
Regen mongodb: make patch
Issue: ZENKO-5034
1 parent 44cc161 commit ffcd3b9

12 files changed

+136
-32
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../scripts/create-app-user.sh
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
../../../../scripts/set-default-write-concern-majority.sh

solution-base/mongodb/charts/mongodb-sharded/templates/_helpers.tpl

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,33 @@ Usage:
2929
{{- end }}
3030
{{- end -}}
3131
32+
{{/*
33+
Init container definition to recover log dir.
34+
*/}}
35+
{{- define "mongodb-sharded.initContainer.prepareLogDir" }}
36+
- name: log-dir
37+
image: {{ include "mongodb-sharded.image" $ }}
38+
imagePullPolicy: {{ $.Values.image.pullPolicy | quote }}
39+
command:
40+
- /bin/bash
41+
args:
42+
- -ec
43+
- |
44+
ln -sf /dev/stdout "/opt/bitnami/mongodb/logs/mongodb.log"
45+
{{- if and $.Values.volumePermissions $.Values.volumePermissions.containerSecurityContext $.Values.volumePermissions.containerSecurityContext.enabled }}
46+
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" $.Values.volumePermissions.containerSecurityContext "context" $) | nindent 4 }}
47+
{{- end }}
48+
{{- if and $.Values.volumePermissions $.Values.volumePermissions.resources }}
49+
resources: {{- toYaml $.Values.volumePermissions.resources | nindent 4 }}
50+
{{- else if and $.Values.volumePermissions $.Values.volumePermissions.resourcesPreset (ne $.Values.volumePermissions.resourcesPreset "none") }}
51+
resources: {{- include "common.resources.preset" (dict "type" $.Values.volumePermissions.resourcesPreset) | nindent 4 }}
52+
{{- end }}
53+
volumeMounts:
54+
- name: empty-dir
55+
mountPath: /opt/bitnami/mongodb/logs
56+
subPath: app-logs-dir
57+
{{- end -}}
58+
3259
{{- define "mongodb-sharded.configServer.primaryHost" -}}
3360
{{- if .Values.configsvr.external.host -}}
3461
{{- .Values.configsvr.external.host }}
@@ -37,6 +64,10 @@ Usage:
3764
{{- end -}}
3865
{{- end -}}
3966
67+
{{- define "mongodb-sharded.configServer.serviceName" -}}
68+
{{- printf "%s-configsvr.%s.svc.%s" (include "common.names.fullname" .) .Release.Namespace .Values.clusterDomain -}}
69+
{{- end -}}
70+
4071
{{- define "mongodb-sharded.configServer.rsName" -}}
4172
{{- if .Values.configsvr.external.replicasetName -}}
4273
{{- .Values.configsvr.external.replicasetName }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
apiVersion: v1
2+
kind: Service
3+
metadata:
4+
name: {{ printf "%s-configsvr" (include "common.names.fullname" .) }}
5+
namespace: {{ include "common.names.namespace" . | quote }}
6+
labels: {{ include "common.labels.standard" . | nindent 4 }}
7+
app.kubernetes.io/component: configsvr
8+
{{- if .Values.commonLabels }}
9+
{{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
10+
{{- end }}
11+
{{- if .Values.commonAnnotations }}
12+
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
13+
{{- end }}
14+
spec:
15+
type: {{ .Values.service.type }}
16+
{{- if and .Values.service.loadBalancerIP (eq .Values.service.type "LoadBalancer") }}
17+
loadBalancerIP: {{ .Values.service.loadBalancerIP }}
18+
{{- end }}
19+
{{- if and (eq .Values.service.type "LoadBalancer") .Values.service.loadBalancerSourceRanges }}
20+
loadBalancerSourceRanges:
21+
{{ with .Values.service.loadBalancerSourceRanges }}
22+
{{ toYaml . | indent 4 }}
23+
{{- end }}
24+
{{- end }}
25+
{{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }}
26+
clusterIP: {{ .Values.service.clusterIP }}
27+
{{- end }}
28+
ports:
29+
- name: mongodb
30+
port: {{ .Values.service.ports.mongodb }}
31+
targetPort: mongodb
32+
{{- if .Values.service.nodePorts.mongodb }}
33+
nodePort: {{ .Values.service.nodePorts.mongodb }}
34+
{{- else if eq .Values.service.type "ClusterIP" }}
35+
nodePort: null
36+
{{- end }}
37+
{{- if .Values.metrics.enabled }}
38+
- name: metrics
39+
port: 9216
40+
targetPort: metrics
41+
{{- end }}
42+
{{- if .Values.service.extraPorts }}
43+
{{- include "common.tplvalues.render" (dict "value" .Values.service.extraPorts "context" $) | nindent 4 }}
44+
{{- end }}
45+
selector: {{ include "common.labels.matchLabels" . | nindent 4 }}
46+
app.kubernetes.io/component: configsvr
47+
sessionAffinity: {{ default "None" .Values.service.sessionAffinity }}

solution-base/mongodb/charts/mongodb-sharded/templates/config-server/config-server-statefulset.yaml

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,14 +78,7 @@ spec:
7878
- name: volume-permissions
7979
image: {{ include "mongodb-sharded.volumePermissions.image" . }}
8080
imagePullPolicy: {{ .Values.volumePermissions.image.pullPolicy | quote }}
81-
command:
82-
- /bin/bash
83-
args:
84-
- -ec
85-
- |
86-
mkdir -p {{ .Values.configsvr.persistence.mountPath }}{{- if .Values.configsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}{{- end }}
87-
chown {{ .Values.configsvr.containerSecurityContext.runAsUser }}:{{ .Values.configsvr.podSecurityContext.fsGroup }} {{ .Values.configsvr.persistence.mountPath }}{{- if .Values.configsvr.persistence.subPath }}/{{ include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.subPath "context" $) }}{{- end }}
88-
find {{ .Values.configsvr.persistence.mountPath }} -mindepth 1 -maxdepth 1 -not -name ".snapshot" -not -name "lost+found" | xargs -r chown -R {{ .Values.configsvr.containerSecurityContext.runAsUser }}:{{ .Values.configsvr.podSecurityContext.fsGroup }}
81+
command: ["chown", "-R", "{{ .Values.configsvr.containerSecurityContext.runAsUser }}:{{ .Values.configsvr.podSecurityContext.fsGroup }}", "{{ .Values.configsvr.persistence.mountPath }}"]
8982
securityContext:
9083
runAsUser: 0
9184
{{- if .Values.volumePermissions.resources }}
@@ -109,6 +102,7 @@ spec:
109102
{{- with .Values.common.initContainers }}
110103
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
111104
{{- end }}
105+
{{- include "mongodb-sharded.initContainer.prepareLogDir" $ | nindent 8 }}
112106
containers:
113107
- name: mongodb
114108
image: {{ include "mongodb-sharded.image" . }}
@@ -456,7 +450,7 @@ spec:
456450
storage: {{ .Values.configsvr.persistence.size | quote }}
457451
{{- with .Values.configsvr.persistence.selector }}
458452
selector:
459-
{{- include "common.tplvalues.render" (dict "value" .Values.configsvr.persistence.selector "context" $) | nindent 10 }}
453+
{{ toYaml $.Values.configsvr.persistence.selector | indent 10 }}
460454
{{- end }}
461455
{{- include "common.storage.class" (dict "persistence" .Values.configsvr.persistence "global" .Values.global) | nindent 8 }}
462456
{{- end }}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{{ if (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]") }}
2+
apiVersion: v1
3+
kind: ConfigMap
4+
metadata:
5+
name: mongodb-sharded-init-scripts
6+
labels: {{- include "common.labels.standard" . | nindent 4 }}
7+
data:
8+
{{ tpl (.Files.Glob "files/docker-entrypoint-initdb.d/*[sh|js|json]").AsConfig . | indent 2 }}
9+
{{ end }}

solution-base/mongodb/charts/mongodb-sharded/templates/mongos/mongos-dep-sts.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ spec:
8585
{{- with $.Values.common.initContainers }}
8686
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
8787
{{- end }}
88+
{{- include "mongodb-sharded.initContainer.prepareLogDir" $ | nindent 8 }}
8889
{{- end }}
8990
containers:
9091
- name: mongos
@@ -93,6 +94,9 @@ spec:
9394
{{- if .Values.mongos.containerSecurityContext.enabled }}
9495
securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.mongos.containerSecurityContext "context" $) | nindent 12 }}
9596
{{- end }}
97+
command:
98+
- /bin/bash
99+
- /entrypoint/mongos-entrypoint.sh
96100
env:
97101
- name: MONGODB_ENABLE_NUMACTL
98102
value: {{ ternary "yes" "no" $.Values.common.mongodbEnableNumactl | quote }}
@@ -136,7 +140,7 @@ spec:
136140
- name: MONGODB_PORT_NUMBER
137141
value: {{ $.Values.common.containerPorts.mongodb | quote }}
138142
- name: MONGODB_CFG_PRIMARY_HOST
139-
value: {{ include "mongodb-sharded.configServer.primaryHost" . }}
143+
value: {{ include "mongodb-sharded.configServer.serviceName" . }}
140144
- name: MONGODB_CFG_REPLICA_SET_NAME
141145
value: {{ include "mongodb-sharded.configServer.rsName" . }}
142146
- name: MONGODB_SYSTEM_LOG_VERBOSITY
@@ -232,6 +236,8 @@ spec:
232236
lifecycle: {{- include "common.tplvalues.render" (dict "value" .Values.mongos.lifecycleHooks "context" $) | nindent 12 }}
233237
{{- end }}
234238
volumeMounts:
239+
- name: replicaset-entrypoint-configmap
240+
mountPath: /entrypoint
235241
- name: empty-dir
236242
mountPath: /tmp
237243
subPath: tmp-dir
@@ -350,6 +356,9 @@ spec:
350356
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
351357
{{- end }}
352358
volumes:
359+
- name: replicaset-entrypoint-configmap
360+
configMap:
361+
name: {{ include "common.names.fullname" . }}-replicaset-entrypoint
353362
- name: empty-dir
354363
emptyDir: {}
355364
{{- if .Values.auth.usePasswordFiles }}

solution-base/mongodb/charts/mongodb-sharded/templates/replicaset-entrypoint-configmap.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,13 @@ metadata:
1313
annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
1414
{{- end }}
1515
data:
16+
mongos-entrypoint.sh: |-
17+
#!/bin/bash
18+
. /liblog.sh
19+
# Disable MongoSH telemetry to support offline deployments
20+
mongosh --nodb --eval "disableTelemetry()"
21+
info "MongoDB Telemetry is now disabled."
22+
exec /entrypoint.sh /run.sh
1623
replicaset-entrypoint.sh: |-
1724
#!/bin/bash
1825
@@ -36,4 +43,8 @@ data:
3643
{{- end }}
3744
fi
3845
46+
# Disable MongoSH telemetry to support offline deployments
47+
mongosh --nodb --eval "disableTelemetry()"
48+
info "MongoDB Telemetry is now disabled."
49+
3950
exec /entrypoint.sh /run.sh

solution-base/mongodb/charts/mongodb-sharded/templates/shard/shard-arbiter-statefulset.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ spec:
8484
{{- with $.Values.common.initContainers }}
8585
{{- include "common.tplvalues.render" ( dict "value" . "context" $ ) | nindent 8 }}
8686
{{- end }}
87+
{{- include "mongodb-sharded.initContainer.prepareLogDir" $ | nindent 8 }}
8788
{{- end }}
8889
containers:
8990
- name: {{ printf "%s-arbiter" (include "common.names.fullname" $) }}

solution-base/mongodb/charts/mongodb-sharded/templates/shard/shard-data-podmonitor.yaml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ SPDX-License-Identifier: APACHE-2.0
44
*/}}
55

66
{{- if and .Values.shards .Values.metrics.enabled .Values.metrics.podMonitor.enabled }}
7-
{{- $replicas := .Values.shards | int }}
8-
{{- range $i, $e := until $replicas }}
7+
{{- $i := 0 }}
98
apiVersion: monitoring.coreos.com/v1
109
kind: PodMonitor
1110
metadata:
@@ -36,7 +35,4 @@ spec:
3635
selector:
3736
matchLabels: {{- include "common.labels.matchLabels" ( dict "customLabels" $podLabels "context" $ ) | nindent 6 }}
3837
app.kubernetes.io/component: shardsvr
39-
shard: {{ $i | quote }}
40-
---
41-
{{- end }}
4238
{{- end }}

0 commit comments

Comments
 (0)