mirror of
https://github.com/bitnami/charts.git
synced 2026-03-15 06:47:24 +08:00
[bitnami/mongodb] adding local and global namespace overrides for mongodb (#2351)
* update to allow parent charts to override the namespace in the mongodb chart * correct readme mistake * add global namespace overrides * reuse mongodb.namespace template * add global namespace override to production values.yaml * first of the review updates * minor version bump * remove redundant local namespaceOverride, can just use the global with fewer edge-cases * typo in .values * [bitnami/mongodb] Update components versions Signed-off-by: Bitnami Containers <containers@bitnami.com> Co-authored-by: Ben Wright <benjamin.wright@nielsen.com> Co-authored-by: Bitnami Containers <containers@bitnami.com> Co-authored-by: Miguel Ángel Cabrera Miñagorri <macabrera@bitnami.com>
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
apiVersion: v1
|
||||
name: mongodb
|
||||
version: 7.10.13
|
||||
version: 7.11.0
|
||||
appVersion: 4.2.6
|
||||
description: NoSQL document-oriented database that stores JSON-like documents with dynamic schemas, simplifying the integration of data in content-driven applications.
|
||||
keywords:
|
||||
|
||||
@@ -53,6 +53,7 @@ The following table lists the configurable parameters of the MongoDB chart and t
|
||||
| `global.imageRegistry` | Global Docker image registry | `nil` |
|
||||
| `global.imagePullSecrets` | Global Docker registry secret names as an array | `[]` (does not add image pull secrets to deployed pods) |
|
||||
| `global.storageClass` | Global storage class for dynamic provisioning | `nil` |
|
||||
| `global.namespaceOverride` | String to override the release namespace. | `nil` |
|
||||
| `image.registry` | MongoDB image registry | `docker.io` |
|
||||
| `image.repository` | MongoDB Image name | `bitnami/mongodb` |
|
||||
| `image.tag` | MongoDB Image tag | `{TAG_NAME}` |
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
|
||||
MongoDB can be accessed via port {{ .Values.service.port }} on the following DNS name from within your cluster:
|
||||
|
||||
{{ template "mongodb.serviceName" . }}.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}
|
||||
{{ template "mongodb.serviceName" . }}.{{ template "mongodb.namespace" . }}.svc.{{ .Values.clusterDomain }}
|
||||
|
||||
{{ if .Values.usePassword -}}
|
||||
|
||||
To get the root password run:
|
||||
|
||||
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mongodb.fullname" . }} -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
|
||||
export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace {{ template "mongodb.namespace" . }} {{ template "mongodb.fullname" . }} -o jsonpath="{.data.mongodb-root-password}" | base64 --decode)
|
||||
|
||||
{{- end }}
|
||||
{{- if and .Values.mongodbUsername .Values.mongodbDatabase }}
|
||||
@@ -33,34 +33,34 @@ To get the root password run:
|
||||
|
||||
To get the password for "{{ .Values.mongodbUsername }}" run:
|
||||
|
||||
export MONGODB_PASSWORD=$(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "mongodb.fullname" . }} -o jsonpath="{.data.mongodb-password}" | base64 --decode)
|
||||
export MONGODB_PASSWORD=$(kubectl get secret --namespace {{ template "mongodb.namespace" . }} {{ template "mongodb.fullname" . }} -o jsonpath="{.data.mongodb-password}" | base64 --decode)
|
||||
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
To connect to your database run the following command:
|
||||
|
||||
kubectl run --namespace {{ .Release.Namespace }} {{ template "mongodb.fullname" . }}-client --rm --tty -i --restart='Never' --image {{ template "mongodb.image" . }} --command -- mongo admin --host {{ template "mongodb.serviceName" . }} {{- if .Values.usePassword }} --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD{{- end }}
|
||||
kubectl run --namespace {{ template "mongodb.namespace" . }} {{ template "mongodb.fullname" . }}-client --rm --tty -i --restart='Never' --image {{ template "mongodb.image" . }} --command -- mongo admin --host {{ template "mongodb.serviceName" . }} {{- if .Values.usePassword }} --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD{{- end }}
|
||||
|
||||
To connect to your database from outside the cluster execute the following commands:
|
||||
|
||||
{{- if contains "NodePort" .Values.service.type }}
|
||||
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "mongodb.serviceName" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ template "mongodb.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
export NODE_PORT=$(kubectl get --namespace {{ template "mongodb.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ template "mongodb.serviceName" . }})
|
||||
mongo --host $NODE_IP --port $NODE_PORT {{- if .Values.usePassword }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD{{- end }}
|
||||
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
Watch the status with: 'kubectl get svc --namespace {{ .Release.Namespace }} -w {{ template "mongodb.serviceName" . }}'
|
||||
Watch the status with: 'kubectl get svc --namespace {{ template "mongodb.namespace" . }} -w {{ template "mongodb.serviceName" . }}'
|
||||
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ template "mongodb.serviceName" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ template "mongodb.namespace" . }} {{ template "mongodb.serviceName" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
mongo --host $SERVICE_IP --port {{ .Values.service.port }} {{- if .Values.usePassword }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD{{- end }}
|
||||
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
|
||||
kubectl port-forward --namespace {{ .Release.Namespace }} svc/{{ template "mongodb.serviceName" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &
|
||||
kubectl port-forward --namespace {{ template "mongodb.namespace" . }} svc/{{ template "mongodb.serviceName" . }} {{ .Values.service.port }}:{{ .Values.service.port }} &
|
||||
mongo --host 127.0.0.1 {{- if .Values.usePassword }} --authenticationDatabase admin -p $MONGODB_ROOT_PASSWORD{{- end }}
|
||||
|
||||
{{- end }}
|
||||
|
||||
@@ -6,6 +6,29 @@ Expand the name of the chart.
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Allow the release namespace to be overridden for multi-namespace deployments in combined charts.
|
||||
*/}}
|
||||
{{- define "mongodb.namespace" -}}
|
||||
{{- if .Values.global -}}
|
||||
{{- if .Values.global.namespaceOverride }}
|
||||
{{- .Values.global.namespaceOverride -}}
|
||||
{{- else -}}
|
||||
{{- .Release.Namespace -}}
|
||||
{{- end -}}
|
||||
{{- else -}}
|
||||
{{- .Release.Namespace -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{- define "mongodb.serviceMonitor.namespace" -}}
|
||||
{{- if .Values.metrics.serviceMonitor.namespace -}}
|
||||
{{- .Values.metrics.serviceMonitor.namespace -}}
|
||||
{{- else -}}
|
||||
{{- template "mongodb.namespace" . -}}
|
||||
{{- end }}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Renders a value that contains template.
|
||||
Usage:
|
||||
|
||||
@@ -8,6 +8,7 @@ metadata:
|
||||
heritage: {{ .Release.Service }}
|
||||
release: {{ .Release.Name }}
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
data:
|
||||
mongodb.conf: |-
|
||||
{{ toYaml .Values.configmap | indent 4 }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: apps/v1
|
||||
kind: {{ if .Values.useStatefulSet }}{{ "StatefulSet" }}{{- else }}{{ "Deployment" }}{{- end }}
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: extensions/v1beta1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}-init-scripts
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -8,6 +8,7 @@ metadata:
|
||||
heritage: {{ .Release.Service }}
|
||||
release: {{ .Release.Name }}
|
||||
name: {{ template "mongodb.fullname" . }}-arbiter
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
spec:
|
||||
{{- if .Values.replicaSet.pdb.minAvailable }}
|
||||
{{- if .Values.replicaSet.pdb.minAvailable.arbiter }}
|
||||
|
||||
@@ -8,6 +8,7 @@ metadata:
|
||||
heritage: {{ .Release.Service }}
|
||||
release: {{ .Release.Name }}
|
||||
name: {{ template "mongodb.fullname" . }}-secondary
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
spec:
|
||||
{{- if .Values.replicaSet.pdb.minAvailable }}
|
||||
{{- if .Values.replicaSet.pdb.minAvailable.secondary }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,9 +3,7 @@ apiVersion: monitoring.coreos.com/v1
|
||||
kind: ServiceMonitor
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
{{- if .Values.metrics.serviceMonitor.namespace }}
|
||||
namespace: {{ .Values.metrics.serviceMonitor.namespace }}
|
||||
{{- end }}
|
||||
namespace: {{ template "mongodb.serviceMonitor.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
@@ -25,11 +23,11 @@ spec:
|
||||
jobLabel: {{ template "mongodb.fullname" . }}
|
||||
namespaceSelector:
|
||||
matchNames:
|
||||
- "{{ $.Release.Namespace }}"
|
||||
- "{{ template "mongodb.namespace" . }}"
|
||||
selector:
|
||||
matchLabels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
release: "{{ .Release.Name }}"
|
||||
heritage: "{{ .Release.Service }}"
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
@@ -8,6 +8,7 @@ metadata:
|
||||
heritage: {{ .Release.Service }}
|
||||
release: {{ .Release.Name }}
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
spec:
|
||||
accessModes:
|
||||
{{- range .Values.persistence.accessModes }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: Secret
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ template "mongodb.serviceAccountName" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}-arbiter
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
@@ -108,7 +109,7 @@ spec:
|
||||
value: {{ .Values.replicaSet.name | quote }}
|
||||
{{- if .Values.replicaSet.useHostnames }}
|
||||
- name: MONGODB_ADVERTISED_HOSTNAME
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ template "mongodb.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||
{{- end }}
|
||||
{{- if .Values.usePassword }}
|
||||
- name: MONGODB_PRIMARY_ROOT_PASSWORD
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}-primary
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
@@ -123,7 +124,7 @@ spec:
|
||||
value: {{ .Values.replicaSet.name | quote }}
|
||||
{{- if .Values.replicaSet.useHostnames }}
|
||||
- name: MONGODB_ADVERTISED_HOSTNAME
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ template "mongodb.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||
{{- end }}
|
||||
{{- if .Values.mongodbUsername }}
|
||||
- name: MONGODB_USERNAME
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: apps/v1
|
||||
kind: StatefulSet
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}-secondary
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
@@ -126,7 +127,7 @@ spec:
|
||||
value: {{ .Values.replicaSet.name | quote }}
|
||||
{{- if .Values.replicaSet.useHostnames }}
|
||||
- name: MONGODB_ADVERTISED_HOSTNAME
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}"
|
||||
value: "$(MONGODB_POD_NAME).{{ template "mongodb.fullname" . }}-headless.{{ template "mongodb.namespace" . }}.svc.{{ .Values.clusterDomain }}"
|
||||
{{- end }}
|
||||
{{- if .Values.usePassword }}
|
||||
- name: MONGODB_PRIMARY_ROOT_PASSWORD
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "mongodb.fullname" . }}-headless
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "mongodb.serviceName" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -3,6 +3,7 @@ apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ template "mongodb.serviceName" . }}
|
||||
namespace: {{ template "mongodb.namespace" . }}
|
||||
labels:
|
||||
app: {{ template "mongodb.name" . }}
|
||||
chart: {{ template "mongodb.chart" . }}
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
# imagePullSecrets:
|
||||
# - myRegistryKeySecretName
|
||||
# storageClass: myStorageClass
|
||||
## Override the namespace for resource deployed by the chart, but can itself be overridden by the local namespaceOverride
|
||||
# namespaceOverride: my-global-namespace
|
||||
|
||||
image:
|
||||
## Bitnami MongoDB registry
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
# imagePullSecrets:
|
||||
# - myRegistryKeySecretName
|
||||
# storageClass: myStorageClass
|
||||
## Override the namespace for resource deployed by the chart, but can itself be overridden by the local namespaceOverride
|
||||
# namespaceOverride: my-global-namespace
|
||||
|
||||
image:
|
||||
## Bitnami MongoDB registry
|
||||
|
||||
Reference in New Issue
Block a user