[bitnami/node] Allow using Node application that do not require any database (#4068)

This commit is contained in:
Juan Ariza Toledano
2020-10-21 15:20:58 +02:00
committed by GitHub
parent 64051f7ce4
commit c2d91ecc1f
7 changed files with 50 additions and 15 deletions

View File

@@ -1,6 +1,6 @@
apiVersion: v1
name: node
version: 13.0.5
version: 13.1.0
appVersion: 10.22.1
description: Event-driven I/O server-side JavaScript environment based on V8
keywords:

View File

@@ -108,6 +108,7 @@ The following table lists the configurable parameters of the Node chart and thei
| `ingress.secrets[0].certificate` | TLS Secret Certificate | `nil` |
| `ingress.secrets[0].key` | TLS Secret Key | `nil` |
| `mongodb.install` | Wheter to install or not the MongoDB chart | `true` |
| `externaldb.enabled` | Enables or disables external database (ignored if `mongodb.install=true`) | `false` |
| `externaldb.secretName` | Secret containing existing database credentials | `nil` |
| `externaldb.type` | Type of database that defines the database secret mapping | `osba` |
| `externaldb.broker.serviceInstanceName` | The existing ServiceInstance to be used | `nil` |
@@ -188,6 +189,7 @@ ingress:
```console
mongodb.install=false
externaldb.enabled=true
externaldb.secretName=my-database-secret
```
@@ -230,6 +232,7 @@ ingress:
```command
mongodb.install=false
externaldb.enabled=true
externaldb.broker.serviceInstanceName=azure-mongodb-instance
externaldb.ssl=true
```

View File

@@ -22,4 +22,5 @@
{{- end }}
{{ include "node.checkRollingTags" . }}
{{- include "node.checkRollingTags" . }}
{{- include "node.validateValues" . }}

View File

@@ -248,3 +248,28 @@ Usage:
{{- tpl (.value | toYaml) .context }}
{{- end }}
{{- end -}}
{{/*
Compile all warnings into a single message, and call fail.
*/}}
{{- define "node.validateValues" -}}
{{- $messages := list -}}
{{- $messages := append $messages (include "node.validateValues.database" .) -}}
{{- $messages := without $messages "" -}}
{{- $message := join "\n" $messages -}}
{{- if $message -}}
{{- printf "\nVALUES VALIDATION:\n%s" $message | fail -}}
{{- end -}}
{{- end -}}
{{/* Validate values of Node - Database */}}
{{- define "node.validateValues.database" -}}
{{- if and .Values.mongodb.install .Values.externaldb.enabled -}}
node: Database
You can only use one database.
Please choose installing a MongoDB chart (--set mongodb.install=true) or
using an external database (--set externaldb.enabled=true)
{{- end -}}
{{- end -}}

View File

@@ -94,22 +94,21 @@ spec:
value: {{ .Values.mongodb.auth.database | quote }}
- name: DATABASE_CONNECTION_OPTIONS
value: ""
{{- else }}
{{- else if .Values.externaldb.enabled }}
- name: DATABASE_HOST
valueFrom:
secretKeyRef:
name: {{ template "node.secretName" . }}
key: host
{{- if not .Values.externaldb.broker.serviceInstanceName }}
- name: DATABASE_NAME
{{- if not .Values.externaldb.broker.serviceInstanceName }}
valueFrom:
secretKeyRef:
name: {{ template "node.secretName" . }}
key: database
{{- else }}
- name: DATABASE_NAME
{{- else }}
value: ""
{{- end }}
{{- end }}
- name: DATABASE_PORT
valueFrom:
secretKeyRef:
@@ -125,13 +124,12 @@ spec:
secretKeyRef:
name: {{ template "node.secretName" . }}
key: password
{{- if .Values.externaldb.ssl }}
- name: DATABASE_CONNECTION_OPTIONS
{{- if .Values.externaldb.ssl }}
value: "ssl=true"
{{- else }}
- name: DATABASE_CONNECTION_OPTIONS
{{- else }}
value: ""
{{- end }}
{{- end }}
{{- end }}
- name: DATA_FOLDER
value: "/app"

View File

@@ -1,4 +1,4 @@
{{- if .Values.externaldb.broker.serviceInstanceName }}
{{- if and .Values.externaldb.enabled .Values.externaldb.broker.serviceInstanceName }}
apiVersion: servicecatalog.k8s.io/v1beta1
kind: ServiceBinding
metadata:

View File

@@ -229,12 +229,14 @@ ingress:
# key:
# certificate:
##
## MongoDB chart configuration
## ref: https://github.com/bitnami/charts/blob/master/bitnami/mongodb/values.yaml
##
mongodb:
## Whether to deploy a mongodb server to satisfy the applications database requirements.
## Whether to deploy a MongoDB server to satisfy the applications database requirements.
## To use an external database set this to false and configure the externaldb parameters
##
install: true
## MongoDB custom user and database
## ref: https://github.com/bitnami/bitnami-docker-mongodb/blob/master/README.md#creating-a-user-and-database-on-first-run
@@ -244,12 +246,18 @@ mongodb:
database: test_db
password: secret_password
## Provision an external database (Only if mongodb.install is false)
## You can:
##
## External Database Configuration
##
## Provision an external database
## You have two alternatives:
## 1) Pass an already existing Secret with your database credentials
## 2) Pass an already existing ServiceInstance name and specify the service catalog broker to automatically create a ServiceBinding for your application.
##
externaldb:
## Enables or disables external database
##
enabled: false
## Set to true if your external database has ssl enabled
##
ssl: false