[stable/mongodb-replicaset] Namespace override (#21203)

Signed-off-by: Mohammad Forutan <mforutan@users.noreply.github.com>
This commit is contained in:
Kubernetes Prow Robot
2020-03-05 11:04:38 -08:00
committed by GitHub
parent 681aa0790d
commit 3b17d7b9ee
17 changed files with 32 additions and 4 deletions
+1 -1
View File
@@ -1,7 +1,7 @@
apiVersion: v1
name: mongodb-replicaset
home: https://github.com/mongodb/mongo
version: 3.12.0
version: 3.13.0
appVersion: 3.6
description: NoSQL document-oriented database that stores JSON-like documents with
dynamic schemas, simplifying the integration of data in content-driven applications.
+1
View File
@@ -111,6 +111,7 @@ The following table lists the configurable parameters of the mongodb chart and t
| `extraVars` | Set environment variables for the main container | `{}` |
| `extraLabels` | Additional labels to add to resources | `{}` |
| `extraVolumes` | Additional volumes to add to the resources | `[]` |
| `global.namespaceOverride` | Override the deployment namespace | Not set (`Release.Namespace`) |
*MongoDB config file*
@@ -1,14 +1,14 @@
1. After the statefulset is created completely, one can check which instance is primary by running:
$ for ((i = 0; i < {{ .Values.replicas }}; ++i)); do kubectl exec --namespace {{ .Release.Namespace }} {{ template "mongodb-replicaset.fullname" . }}-$i -- sh -c 'mongo --eval="printjson(rs.isMaster())"'; done
$ for ((i = 0; i < {{ .Values.replicas }}; ++i)); do kubectl exec --namespace {{ template "mongodb-replicaset.namespace" . }} {{ template "mongodb-replicaset.fullname" . }}-$i -- sh -c 'mongo --eval="printjson(rs.isMaster())"'; done
2. One can insert a key into the primary instance of the mongodb replica set by running the following:
MASTER_POD_NAME must be replaced with the name of the master found from the previous step.
$ kubectl exec --namespace {{ .Release.Namespace }} MASTER_POD_NAME -- mongo --eval="printjson(db.test.insert({key1: 'value1'}))"
$ kubectl exec --namespace {{ template "mongodb-replicaset.namespace" . }} MASTER_POD_NAME -- mongo --eval="printjson(db.test.insert({key1: 'value1'}))"
3. One can fetch the keys stored in the primary or any of the slave nodes in the following manner.
POD_NAME must be replaced by the name of the pod being queried.
$ kubectl exec --namespace {{ .Release.Namespace }} POD_NAME -- mongo --eval="rs.slaveOk(); db.test.find().forEach(printjson)"
$ kubectl exec --namespace {{ template "mongodb-replicaset.namespace" . }} POD_NAME -- mongo --eval="rs.slaveOk(); db.test.find().forEach(printjson)"
@@ -76,3 +76,14 @@ Create the name for the key secret.
{{- printf $string | quote -}}
{{- end -}}
{{- end -}}
{{/*
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
*/}}
{{- define "mongodb-replicaset.namespace" -}}
{{- if and ((hasKey .Values "global") .Values.global.namespaceOverride) -}}
{{- .Values.global.namespaceOverride -}}
{{- else -}}
{{- .Release.Namespace -}}
{{- end -}}
{{- end -}}
@@ -11,6 +11,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.adminSecret" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
type: Opaque
data:
user: {{ .Values.auth.adminUser | b64enc }}
@@ -12,6 +12,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}-ca
namespace: {{ template "mongodb-replicaset.namespace" . }}
data:
tls.key: {{ .Values.tls.cakey }}
tls.crt: {{ .Values.tls.cacert }}
@@ -10,6 +10,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}-init
namespace: {{ template "mongodb-replicaset.namespace" . }}
data:
on-start.sh: |
{{ .Files.Get "init/on-start.sh" | indent 4 }}
@@ -11,6 +11,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.keySecret" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
type: Opaque
data:
key.txt: {{ .Values.auth.key | b64enc }}
@@ -11,6 +11,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.metricsSecret" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
type: Opaque
data:
user: {{ .Values.auth.metricsUser | b64enc }}
@@ -10,6 +10,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}-mongodb
namespace: {{ template "mongodb-replicaset.namespace" . }}
data:
mongod.conf: |
{{ toYaml .Values.configmap | indent 4 }}
@@ -11,6 +11,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
spec:
selector:
matchLabels:
@@ -15,6 +15,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}-client
namespace: {{ template "mongodb-replicaset.namespace" . }}
spec:
type: ClusterIP
clusterIP: None
@@ -13,6 +13,7 @@ metadata:
{{ toYaml .Values.extraLabels | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
spec:
type: ClusterIP
clusterIP: None
@@ -14,6 +14,7 @@ metadata:
{{ toYaml .Values.statefulSetAnnotations | indent 4 }}
{{- end }}
name: {{ template "mongodb-replicaset.fullname" . }}
namespace: {{ template "mongodb-replicaset.namespace" . }}
spec:
selector:
matchLabels:
@@ -7,6 +7,7 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "mongodb-replicaset.fullname" . }}-tests
namespace: {{ template "mongodb-replicaset.namespace" . }}
data:
mongodb-up-test.sh: |
{{ .Files.Get "tests/mongodb-up-test.sh" | indent 4 }}
@@ -7,6 +7,7 @@ metadata:
heritage: {{ .Release.Service }}
release: {{ .Release.Name }}
name: {{ template "mongodb-replicaset.fullname" . }}-test
namespace: {{ template "mongodb-replicaset.namespace" . }}
annotations:
"helm.sh/hook": test-success
spec:
+4
View File
@@ -2,6 +2,10 @@
nameOverride: ""
fullnameOverride: ""
# Override the deployment namespace
# global:
# namespaceOverride: ""
replicas: 3
port: 27017