[bitnami/mongodb-sharded] Allow only deploying mongos. (#2901)

* [bitnami/mongodb-sharded] Allow only deploying mongos.

* update production

* Fix helper

* [bitnami/mongodb-sharded] Update components versions

Signed-off-by: Bitnami Containers <containers@bitnami.com>

Co-authored-by: Bitnami Containers <containers@bitnami.com>
This commit is contained in:
Javier J. Salmerón-García
2020-06-24 13:20:10 +02:00
committed by GitHub
parent 1a0b53bb26
commit ea945f2f5c
15 changed files with 130 additions and 23 deletions

View File

@@ -1,6 +1,6 @@
apiVersion: v1
name: mongodb-sharded
version: 1.4.4
version: 1.5.0
appVersion: 4.2.8
description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications. Sharded topology.
keywords:

View File

@@ -157,6 +157,10 @@ The following table lists the configurable parameters of the MongoDB chart and t
| `configsvr.persistence.accessModes` | Use volume as ReadOnly or ReadWrite | `[ReadWriteOnce]` |
| `configsvr.persistence.size` | Size of data volume | `8Gi` |
| `configsvr.persistence.annotations` | Persistent Volume annotations | `{}` |
| `configsvr.external.host` | Primary node of an external config server replicaset | `nil` |
| `configsvr.external.rootPassword` | Root passworrd of the external config server replicaset | `nil` |
| `configsvr.external.replicasetName` | Replicaset name of an external config server | `nil` |
| `configsvr.external.replicasetKey` | Replicaset key of an external config server | `nil` |
### Mongos configuration
@@ -392,6 +396,10 @@ extraEnvVars:
Alternatively, you can use a ConfigMap or a Secret with the environment variables. To do so, use the `extraEnvVarsCM` or the `extraEnvVarsSecret` values.
### Using an external config server
It is possible to not deploy any shards or a config server. For example, it is possible to simply deploy `mongos` instances that point to an external MongoDB sharded database. If that is the case, set the `configsvr.external.host` and `configsvr.external.replicasetName` for the mongos instances to connect. For authentication, set the `configsvr.external.rootPassword` and `configsvr.external.replicasetKey` values.
## Persistence
The [Bitnami MongoDB](https://github.com/bitnami/bitnami-docker-mongodb-sharded) image stores the MongoDB data and configurations at the `/bitnami/mongodb` path of the container.

View File

@@ -71,7 +71,19 @@ Create chart name and version as used by the chart label.
{{- end -}}
{{- define "mongodb-sharded.configServer.primaryHost" -}}
{{- if .Values.configsvr.external.host -}}
{{- .Values.configsvr.external.host }}
{{- else -}}
{{- printf "%s-configsvr-0.%s-headless.%s.svc.%s" (include "mongodb-sharded.fullname" . ) (include "mongodb-sharded.fullname" .) .Release.Namespace .Values.clusterDomain -}}
{{- end -}}
{{- end -}}
{{- define "mongodb-sharded.configServer.rsName" -}}
{{- if .Values.configsvr.external.replicasetName -}}
{{- .Values.configsvr.external.replicasetName }}
{{- else }}
{{- printf "%s-configsvr" ( include "mongodb-sharded.fullname" . ) -}}
{{- end }}
{{- end -}}
{{- define "mongodb-sharded.mongos.configCM" -}}
@@ -235,6 +247,7 @@ Compile all warnings into a single message, and call fail.
{{- define "mongodb-sharded.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.mongodbCustomDatabase" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.externalCfgServer" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.replicas" .) -}}
{{- $messages := append $messages (include "mongodb-sharded.validateValues.config" .) -}}
{{- $messages := without $messages "" -}}
@@ -258,25 +271,44 @@ mongodb: mongodbUsername, mongodbDatabase
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB - If using an external config server, then both the host and the replicaset name should be set.
*/}}
{{- define "mongodb-sharded.validateValues.externalCfgServer" -}}
{{- if and .Values.configsvr.external.replicasetName (not .Values.configsvr.external.host) -}}
mongodb: invalidExternalConfigServer
You specified a replica set name for the external config server but not a host. Set both configsvr.external.replicasetName and configsvr.external.host
{{- end -}}
{{- if and (not .Values.configsvr.external.replicasetName) .Values.configsvr.external.host -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the replica set name. Set both configsvr.external.replicasetName and configsvr.external.host
{{- end -}}
{{- if and .Values.configsvr.external.host (not .Values.configsvr.external.rootPassword) -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the root password. Set the configsvr.external.rootPassword value.
{{- end -}}
{{- if and .Values.configsvr.external.host (not .Values.configsvr.external.replicasetKey) -}}
mongodb: invalidExternalConfigServer
You specified a host for the external config server but not the replica set key. Set the configsvr.external.replicasetKey value.
{{- end -}}
{{- end -}}
{{/*
Validate values of MongoDB - The number of shards must be positive, as well as the data node replicas
*/}}
{{- define "mongodb-sharded.validateValues.replicas" -}}
{{- if le (int .Values.shards) 0 }}
mongodb: invalidShardNumber
You specified an invalid number of shards. Please set shards with a positive number
{{- end -}}
{{- if le (int .Values.shardsvr.dataNode.replicas) 0 }}
{{- if and (le (int .Values.shardsvr.dataNode.replicas) 0) (ge (int .Values.shards) 1) }}
mongodb: invalidShardSvrReplicas
You specified an invalid number of replicas per shard. Please set shardsvr.dataNode.replicas with a positive number
You specified an invalid number of replicas per shard. Please set shardsvr.dataNode.replicas with a positive number or set the number of shards to 0.
{{- end -}}
{{- if lt (int .Values.shardsvr.arbiter.replicas) 0 }}
mongodb: invalidShardSvrArbiters
You specified an invalid number of arbiters per shard. Please set shardsvr.arbiter.replicas with a number greater or equal than 0
{{- end -}}
{{- if le (int .Values.configsvr.replicas) 0 }}
{{- if and (le (int .Values.configsvr.replicas) 0) (not .Values.configsvr.external.host) }}
mongodb: invalidConfigSvrReplicas
You specified an invalid number of replicas per shard. Please set configsvr.replicas with a positive number
You specified an invalid number of replicas per shard. Please set configsvr.replicas with a positive number or set the configsvr.external.host value to use
an external config server replicaset
{{- end -}}
{{- end -}}

View File

@@ -1,4 +1,4 @@
{{- if .Values.configsvr.config }}
{{- if and (not .Values.configsvr.external.host) .Values.configsvr.config }}
apiVersion: v1
kind: ConfigMap
metadata:

View File

@@ -1,4 +1,4 @@
{{- if .Values.configsvr.pdb.enabled -}}
{{- if and (not .Values.configsvr.external.host) .Values.configsvr.pdb.enabled -}}
kind: PodDisruptionBudget
apiVersion: policy/v1beta1
metadata:

View File

@@ -1,3 +1,4 @@
{{- if not .Values.configsvr.external.host }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
@@ -330,3 +331,4 @@ spec:
- name: datadir
emptyDir: {}
{{- end }}
{{- end }}

View File

@@ -87,7 +87,7 @@ spec:
- name: MONGODB_CFG_PRIMARY_HOST
value: {{ include "mongodb-sharded.configServer.primaryHost" . }}
- name: MONGODB_CFG_REPLICA_SET_NAME
value: {{ printf "%s-configsvr" ( include "mongodb-sharded.fullname" . ) }}
value: {{ include "mongodb-sharded.configServer.rsName" . }}
- name: MONGODB_SYSTEM_LOG_VERBOSITY
value: {{ .Values.common.mongodbSystemLogVerbosity | quote }}
- name: MONGODB_DISABLE_SYSTEM_LOG

View File

@@ -5,7 +5,9 @@ metadata:
labels: {{- include "mongodb-sharded.labels" $ | nindent 4 }}
type: Opaque
data:
{{- if .Values.mongodbRootPassword }}
{{- if .Values.configsvr.external.rootPassword }}
mongodb-root-password: {{ .Values.configsvr.external.rootPassword | b64enc | quote }}
{{- else if .Values.mongodbRootPassword }}
mongodb-root-password: {{ .Values.mongodbRootPassword | b64enc | quote }}
{{- else }}
mongodb-root-password: {{ randAlphaNum 10 | b64enc | quote }}
@@ -17,7 +19,9 @@ data:
mongodb-password: {{ randAlphaNum 10 | b64enc | quote }}
{{- end }}
{{- end }}
{{- if .Values.replicaSetKey }}
{{- if .Values.configsvr.external.replicasetKey }}
mongodb-replica-set-key: {{ .Values.configsvr.external.replicasetKey | b64enc | quote }}
{{- else if .Values.replicaSetKey }}
mongodb-replica-set-key: {{ .Values.replicaSetKey | b64enc | quote }}
{{- else }}
mongodb-replica-set-key: {{ randAlphaNum 10 | b64enc | quote }}

View File

@@ -1,4 +1,4 @@
{{- if .Values.shardsvr.arbiter.config }}
{{- if and .Values.shards .Values.shardsvr.arbiter.replicas .Values.shardsvr.arbiter.config }}
apiVersion: v1
kind: ConfigMap
metadata:

View File

@@ -1,4 +1,4 @@
{{- if $.Values.shardsvr.arbiter.replicas }}
{{- if and $.Values.shards $.Values.shardsvr.arbiter.replicas }}
{{- $replicas := $.Values.shards | int }}
{{- range $i, $e := until $replicas }}
apiVersion: apps/v1

View File

@@ -1,4 +1,4 @@
{{- if .Values.shardsvr.dataNode.config }}
{{- if and .Values.shards .Values.shardsvr.dataNode.config }}
apiVersion: v1
kind: ConfigMap
metadata:

View File

@@ -1,4 +1,4 @@
{{- if .Values.shardsvr.dataNode.pdb.enabled -}}
{{- if and .Values.shards .Values.shardsvr.dataNode.pdb.enabled -}}
{{- $replicas := .Values.shards | int -}}
{{- range $i, $e := until $replicas -}}
kind: PodDisruptionBudget

View File

@@ -1,3 +1,4 @@
{{- if .Values.shards }}
{{- $replicas := .Values.shards | int }}
{{- range $i, $e := until $replicas }}
apiVersion: apps/v1
@@ -314,3 +315,4 @@ spec:
---
{{- end }}
{{- end }}
{{- end }}

View File

@@ -14,7 +14,7 @@ global: {}
image:
registry: docker.io
repository: bitnami/mongodb-sharded
tag: 4.2.8-debian-10-r4
tag: 4.2.8-debian-10-r13
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
@@ -48,18 +48,21 @@ fullnameOverride:
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##
## mongodbRootPassword: password
##
mongodbRootPassword:
## Create a non-root MongoDB user
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##
## mongodbUsername: user
##
mongodbUsername:
## non-root MongoDB user password
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##
## mongodbPassword: password
##
mongodbPassword:
## Create database on first run
@@ -72,12 +75,14 @@ mongodbDatabase:
## ref:
##
## replicaSetKey: testkey123
##
replicaSetKey:
## Name of a secret containing all the credentials above
## ref:
##
## existingSecret: name-of-existing-secret
##
existingSecret:
## Mount credentials as files instead of using environment variables
@@ -162,6 +167,7 @@ shardsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars:
## Add init containers to the pod
## For example:
@@ -270,6 +276,7 @@ shardsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars:
## Add init containers to the pod
## For example:
@@ -400,6 +407,7 @@ configsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars:
## Add init containers to the pod
## For example:
@@ -470,6 +478,22 @@ configsvr:
##
annotations: {}
## Use a external config server instead of deploying one
##
external:
## Host name of the config server primary node
##
host:
## Root password of the config server primary node
##
rootPassword:
## Name of the replica set
##
replicasetName:
## Replica set key
##
replicasetKey:
## Mongos properties
## ref: https://docs.mongodb.com/manual/reference/program/mongos/#bin.mongos
##
@@ -540,6 +564,7 @@ mongos:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars:
## Add init containers to the pod
## For example:
@@ -631,6 +656,7 @@ common:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars:
## Add init containers to the pod
## For example:
@@ -720,6 +746,7 @@ service:
## Specify the externalIP value ClusterIP service type.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
##
externalIPs: []
## Specify the loadBalancerIP value for LoadBalancer service types.
@@ -767,7 +794,7 @@ metrics:
image:
registry: docker.io
repository: bitnami/mongodb-exporter
tag: 0.11.0-debian-10-r55
tag: 0.11.0-debian-10-r63
pullPolicy: Always
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
@@ -778,6 +805,7 @@ metrics:
## String with extra arguments to the metrics exporter
## ref: https://github.com/dcu/mongodb_exporter/blob/master/mongodb_exporter.go
##
extraArgs: ""
## Metrics exporter resource requests and limits
@@ -787,6 +815,7 @@ metrics:
## Metrics exporter liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
##
livenessProbe:
enabled: false
initialDelaySeconds: 15
@@ -803,6 +832,7 @@ metrics:
successThreshold: 1
## Metrics exporter pod Annotation
##
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9216"
@@ -816,5 +846,6 @@ metrics:
## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#tldr)
## [Prometheus Selector Label](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#prometheus-operator-1)
## [Kube Prometheus Selector Label](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#exporters)
##
selector:
prometheus: kube-prometheus

View File

@@ -14,7 +14,7 @@ global: {}
image:
registry: docker.io
repository: bitnami/mongodb-sharded
tag: 4.2.8-debian-10-r4
tag: 4.2.8-debian-10-r13
## Specify a imagePullPolicy
## Defaults to 'Always' if image tag is 'latest', else set to 'IfNotPresent'
## ref: http://kubernetes.io/docs/user-guide/images/#pre-pulling-images
@@ -48,18 +48,21 @@ fullnameOverride:
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#setting-the-root-password-on-first-run
##
## mongodbRootPassword: password
##
mongodbRootPassword:
## Replica Set key (shared for shards and config servers)
## ref:
##
## replicaSetKey: testkey123
##
replicaSetKey:
## Name of a secret containing all the credentials above
## ref:
##
## existingSecret: name-of-existing-secret
##
existingSecret:
## Mount credentials as files instead of using environment variables
@@ -144,6 +147,7 @@ shardsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars: []
## Add init containers to the pod
## For example:
@@ -252,6 +256,7 @@ shardsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars: []
## Add init containers to the pod
## For example:
@@ -382,6 +387,7 @@ configsvr:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars: []
## Add init containers to the pod
## For example:
@@ -452,6 +458,22 @@ configsvr:
##
annotations: {}
## Use a external config server instead of deploying one
##
external:
## Host name of the config server primary node
##
host:
## Root password of the config server primary node
##
rootPassword:
## Name of the replica set
##
replicasetName:
## Replica set key
##
replicasetKey:
## Mongos properties
## ref: https://docs.mongodb.com/manual/reference/program/mongos/#bin.mongos
##
@@ -522,6 +544,7 @@ mongos:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars: []
## Add init containers to the pod
## For example:
@@ -560,7 +583,6 @@ mongos:
##
maxUnavailable: 1
## Properties for all of the pods in the cluster (shards, config servers and mongos)
##
common:
@@ -608,6 +630,7 @@ common:
## ports:
## - name: portname
## containerPort: 1234
##
sidecars: []
## Add init containers to the pod
## For example:
@@ -704,6 +727,7 @@ service:
## Specify the externalIP value ClusterIP service type.
## ref: https://kubernetes.io/docs/concepts/services-networking/service/#external-ips
##
externalIPs: []
## Specify the loadBalancerIP value for LoadBalancer service types.
@@ -751,7 +775,7 @@ metrics:
image:
registry: docker.io
repository: bitnami/mongodb-exporter
tag: 0.11.0-debian-10-r55
tag: 0.11.0-debian-10-r63
pullPolicy: Always
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
@@ -762,6 +786,7 @@ metrics:
## String with extra arguments to the metrics exporter
## ref: https://github.com/dcu/mongodb_exporter/blob/master/mongodb_exporter.go
##
extraArgs: ""
## Metrics exporter resource requests and limits
@@ -771,6 +796,7 @@ metrics:
## Metrics exporter liveness and readiness probes
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/configure-liveness-readiness-probes/#configure-probes)
##
livenessProbe:
enabled: false
initialDelaySeconds: 15
@@ -787,6 +813,7 @@ metrics:
successThreshold: 1
## Metrics exporter pod Annotation
##
podAnnotations:
prometheus.io/scrape: "true"
prometheus.io/port: "9216"
@@ -800,5 +827,6 @@ metrics:
## Defaults to what's used if you follow CoreOS [Prometheus Install Instructions](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#tldr)
## [Prometheus Selector Label](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#prometheus-operator-1)
## [Kube Prometheus Selector Label](https://github.com/bitnami/charts/tree/master/bitnami/prometheus-operator#exporters)
##
selector:
prometheus: kube-prometheus