From 8a5cc0df3279b97bb36aa7617dfaf908f0ffdbe6 Mon Sep 17 00:00:00 2001 From: Koren Lev Date: Thu, 3 Jun 2021 12:56:15 +0300 Subject: [PATCH] =?UTF-8?q?[bitnami/mongodb]=20support=20https://github.co?= =?UTF-8?q?m/combor/k8s-mongo-labeler-sidecar=20-=20a=20very=20=E2=80=A6?= =?UTF-8?q?=20(#6435)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bitnami/mongodb/Chart.yaml | 2 +- bitnami/mongodb/README.md | 34 +++++++++++++++++++++++++ bitnami/mongodb/values.yaml | 50 +++++++++++++++++++++++++++++++++++-- 3 files changed, 83 insertions(+), 3 deletions(-) diff --git a/bitnami/mongodb/Chart.yaml b/bitnami/mongodb/Chart.yaml index e691d23e8..cec6c1a68 100644 --- a/bitnami/mongodb/Chart.yaml +++ b/bitnami/mongodb/Chart.yaml @@ -26,4 +26,4 @@ name: mongodb sources: - https://github.com/bitnami/bitnami-docker-mongodb - https://mongodb.org -version: 10.18.0 +version: 10.19.0 diff --git a/bitnami/mongodb/README.md b/bitnami/mongodb/README.md index 9246b9605..a835b7fea 100644 --- a/bitnami/mongodb/README.md +++ b/bitnami/mongodb/README.md @@ -531,3 +531,37 @@ Use the workaround below to upgrade from versions previous to 5.0.0. The followi ```console $ kubectl delete statefulset my-release-mongodb-arbiter my-release-mongodb-primary my-release-mongodb-secondary --cascade=false ``` + +### Add extra deployment options + +To add extra deployments (useful for advanced features like sidecars), use the `extraDeploy` property. + +In the example below, you can find how to use a example here for a [MongoDB replica set pod labeler sidecar](https://github.com/combor/k8s-mongo-labeler-sidecar) to identify the primary pod and dynamically label it as the primary node: + +```yaml +extraDeploy: + - apiVersion: v1 + kind: Service + metadata: + name: mongodb-primary + namespace: default + labels: + app.kubernetes.io/component: mongodb + app.kubernetes.io/instance: mongodb + app.kubernetes.io/managed-by: Helm + app.kubernetes.io/name: mongodb + spec: + type: NodePort + externalTrafficPolicy: Cluster + ports: + - name: mongodb-primary + port: 30001 + nodePort: 30001 + protocol: TCP + targetPort: mongodb + selector: + app.kubernetes.io/component: mongodb + app.kubernetes.io/instance: mongodb + app.kubernetes.io/name: mongodb + primary: "true" +``` diff --git a/bitnami/mongodb/values.yaml b/bitnami/mongodb/values.yaml index 721fe0926..95ed90a96 100644 --- a/bitnami/mongodb/values.yaml +++ b/bitnami/mongodb/values.yaml @@ -49,6 +49,33 @@ image: clusterDomain: cluster.local ## Extra objects to deploy (value evaluated as a template) +## This needs to be uncommented and added to 'extraDeploy' in order to use the replicaset 'mongo-labeler' sidecar +## for dynamically discovering the mongodb primary pod +## suggestion is to use a hard-coded and predictable TCP port for the primary mongodb pod (here is 30001, choose your own) +## - apiVersion: v1 +## kind: Service +## metadata: +## name: mongodb-primary +## namespace: the-mongodb-namespace +## labels: +## app.kubernetes.io/component: mongodb +## app.kubernetes.io/instance: mongodb +## app.kubernetes.io/managed-by: Helm +## app.kubernetes.io/name: mongodb +## spec: +## type: NodePort +## externalTrafficPolicy: Cluster +## ports: +## - name: mongodb +## port: 30001 +## nodePort: 30001 +## protocol: TCP +## targetPort: mongodb +## selector: +## app.kubernetes.io/component: mongodb +## app.kubernetes.io/instance: mongodb +## app.kubernetes.io/name: mongodb +## primary: "true" ## extraDeploy: [] @@ -440,6 +467,22 @@ initContainers: {} ## ports: ## - name: portname ## containerPort: 1234 +## This is an optional 'mongo-labeler' sidecar container that tracks replica-set for the primary mongodb pod +## and labels it dynamically with ' primary: "true" ' in order for an extra-deployed service to always expose +## and attach to the primary pod, this needs to be uncommented along with the suggested 'extraDeploy' example +## and the suggested rbac example for the pod to be allowed adding labels to mongo replica pods +## search 'mongo-labeler' through this file to find the sections that needs to be uncommented to make it work +## +## - name: mongo-labeler +## image: korenlev/k8s-mongo-labeler-sidecar +## imagePullPolicy: Always +## env: +## - name: LABEL_SELECTOR +## value: "app.kubernetes.io/component=mongodb,app.kubernetes.io/instance=mongodb,app.kubernetes.io/name=mongodb" +## - name: NAMESPACE +## value: "the-mongodb-namespace" +## - name: DEBUG +## value: "true" ## sidecars: {} @@ -955,17 +998,20 @@ rbac: ## Specifies whether RBAC rules should be created ## binding MongoDB(R) ServiceAccount to a role ## that allows MongoDB(R) pods querying the K8s API - ## + ## this needs to be set to 'true' to enable the mongo-labeler sidecar primary mongodb discovery create: false role: ## Custom rules to create following the role specification - ## e.g. + ## The example below needs to be uncommented to use the 'mongo-labeler' sidecar for dynamic discovery of the primary mongodb pod: ## rules: ## - apiGroups: ## - "" ## resources: ## - pods ## verbs: + ## - get + ## - list + ## - watch ## - update ## rules: []