Skip to content
This repository has been archived by the owner on Feb 22, 2022. It is now read-only.

Commit

Permalink
[stable/redmine] Add support to external databases (#12346)
Browse files Browse the repository at this point in the history
Signed-off-by: juan131 <juan@bitnami.com>
  • Loading branch information
juan131 authored and k8s-ci-robot committed Mar 20, 2019
1 parent 985fcf7 commit 0f6bdf6
Show file tree
Hide file tree
Showing 9 changed files with 125 additions and 37 deletions.
2 changes: 1 addition & 1 deletion stable/redmine/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: redmine
version: 9.1.0
version: 9.2.0
appVersion: 4.0.2
description: A flexible project management web application.
keywords:
Expand Down
22 changes: 14 additions & 8 deletions stable/redmine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,22 @@ The following table lists the configurable parameters of the Redmine chart and t
| `smtpUser` | SMTP user | `nil` |
| `smtpPassword` | SMTP password | `nil` |
| `smtpTls` | Use TLS encryption with SMTP | `nil` |
| `databaseType.postgresql` | Select postgresql database | `false` |
| `databaseType.mariadb` | Select mariadb database | `true` |
| `databaseType.postgresql` | Select PostgreSQL as database | `false` |
| `databaseType.mariadb` | Select MariaDB as database | `true` |
| `mariadb.enabled` | Whether to deploy a MariaDB server to satisfy the applications database requirements | `true` |
| `mariadb.rootUser.password` | MariaDB admin password | `nil` |
| `postgresql.enabled` | Whether to deploy a PostgreSQL server to satisfy the applications database requirements | `false` |
| `postgresql.postgresqlPassword` | PostgreSQL admin password | `nil` |
| `service.type` | Kubernetes Service type | `LoadBalancer` |
| `service.port` | Service HTTP port | `80` |
| `service.nodePorts.http` | Kubernetes http node port | `""` |
| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` |
| `service.loadBalancerIP` | LoadBalancer service IP address | `""` |
| `service.loadBalancerSourceRanges` | An array of load balancer sources | `0.0.0.0/0` |
| `externalDatabase.host` | Host of the external database | `localhost` |
| `externalDatabase.user` | External db admin user | `root` |
| `externalDatabase.password` | Password for the admin user | `""` |
| `externalDatabase.port` | Database port number | `3306` |
| `service.type` | Kubernetes Service type | `LoadBalancer` |
| `service.port` | Service HTTP port | `80` |
| `service.nodePorts.http` | Kubernetes http node port | `""` |
| `service.externalTrafficPolicy` | Enable client source IP preservation | `Cluster` |
| `service.loadBalancerIP` | LoadBalancer service IP address | `""` |
| `service.loadBalancerSourceRanges` | An array of load balancer sources | `0.0.0.0/0` |
| `ingress.enabled` | Enable or disable the ingress | `false` |
| `ingress.hosts[0].name` | Hostname to your Redmine installation | `redmine.local ` |
| `ingress.hosts[0].path` | Path within the url structure | `/` |
Expand Down
8 changes: 4 additions & 4 deletions stable/redmine/requirements.lock
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
dependencies:
- name: mariadb
repository: https://kubernetes-charts.storage.googleapis.com/
version: 5.5.3
version: 5.11.0
- name: postgresql
repository: https://kubernetes-charts.storage.googleapis.com/
version: 3.11.6
digest: sha256:19ad4a1dfc87350474e1cff5293e0e613ebe7378ee9e530423a04fb8be5bf186
generated: 2019-02-26T16:39:44.746904219Z
version: 3.14.2
digest: sha256:e4434ee4dc502ae6d45dc5d224aaabef9b80673a29e694a124b0717bbeca5f0a
generated: 2019-03-18T16:08:08.079713587+01:00
4 changes: 2 additions & 2 deletions stable/redmine/requirements.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ dependencies:
- name: mariadb
version: 5.x.x
repository: https://kubernetes-charts.storage.googleapis.com/
condition: databaseType.mariadb
condition: mariadb.enabled
- name: postgresql
version: 3.x.x
repository: https://kubernetes-charts.storage.googleapis.com/
condition: databaseType.postgresql
condition: postgresql.enabled
16 changes: 16 additions & 0 deletions stable/redmine/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
{{- if and (not .Values.databaseType.mariadb) (not .Values.databaseType.postgresql) }}
################################################################################
### ERROR: You did not indicate MariaDB nor PostgreSQL as the database ###
### server to use. ###
################################################################################

You have 4 alternatives:

a) Use MariaDB as database creating a new MariaDB server: set `databaseType.mariadb=true` and `mariadb.enabled=true`
b) Use MariaDB as database using a external MariaDB server: set `databaseType.mariadb=true` and `mariadb.enabled=false`
c) Use PostgreSQL as database creating a new PostgreSQL server: set `databaseType.postgresql=true` and `postgresql.enabled=true`
d) Use PostgreSQL as database using a external PostgreSQL server: `databaseType.postgresql=true` and `postgresql.enabled=false`

{{- else }}

1. Get the Redmine URL:

{{- if contains "NodePort" .Values.service.type }}
Expand Down Expand Up @@ -34,3 +49,4 @@

echo Username: {{ .Values.redmineUsername }}
echo Password: $(kubectl get secret --namespace {{ .Release.Namespace }} {{ template "redmine.fullname" . }} -o jsonpath="{.data.redmine-password}" | base64 --decode)
{{- end }}
15 changes: 7 additions & 8 deletions stable/redmine/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,13 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this
{{- printf "%s-%s" .Release.Name "postgresql" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "redmine.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}

{{/*
Return the proper Redmine image name
*/}}
Expand All @@ -54,14 +61,6 @@ Also, we can't use a single if because lazy evaluation is not an option
{{- end -}}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "redmine.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}


{{/*
Return the proper Docker Image Registry Secret Names
*/}}
Expand Down
58 changes: 46 additions & 12 deletions stable/redmine/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if or .Values.databaseType.mariadb .Values.databaseType.postgresql }}
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
Expand Down Expand Up @@ -31,22 +32,44 @@ spec:
{{- if .Values.extraVars }}
{{ toYaml .Values.extraVars | indent 8 }}
{{- end }}
{{- if .Values.databaseType.postgresql }}
{{- if .Values.databaseType.mariadb }}
- name: REDMINE_DB_MYSQL
{{- if .Values.mariadb.enabled }}
value: {{ template "redmine.mariadb.fullname" . }}
- name: REDMINE_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "redmine.mariadb.fullname" . }}
key: mariadb-root-password
{{- else }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
{{- else if .Values.databaseType.postgresql }}
- name: REDMINE_DB_POSTGRES
{{- if .Values.postgresql.enabled }}
value: {{ template "redmine.postgresql.fullname" . }}
- name: REDMINE_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "redmine.postgresql.fullname" . }}
key: postgresql-password
{{- else }}
- name: REDMINE_DB_MYSQL
value: {{ template "redmine.mariadb.fullname" . }}
value: {{ .Values.externalDatabase.host | quote }}
{{- end }}
{{- end }}
{{- if or (and .Values.databaseType.mariadb (not .Values.mariadb.enabled)) (and .Values.databaseType.postgresql (not .Values.postgresql.enabled)) }}
- name: REDMINE_DB_USERNAME
valueFrom:
secretKeyRef:
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
key: db-admin-user
- name: REDMINE_DB_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "redmine.mariadb.fullname" . }}
key: mariadb-root-password
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
key: db-password
- name: REDMINE_DB_PORT_NUMBER
value: {{ .Values.externalDatabase.port | quote }}
{{- end }}
- name: REDMINE_USERNAME
value: {{ default "" .Values.redmineUsername | quote }}
Expand All @@ -56,22 +79,32 @@ spec:
name: {{ template "redmine.fullname" . }}
key: redmine-password
- name: REDMINE_EMAIL
value: {{ default "" .Values.redmineEmail | quote }}
value: {{ .Values.redmineEmail | quote }}
- name: REDMINE_LANG
value: {{ default "" .Values.redmineLanguage | quote }}
value: {{ .Values.redmineLanguage | quote }}
{{- if .Values.smtpHost }}
- name: SMTP_HOST
value: {{ default "" .Values.smtpHost | quote }}
value: {{ .Values.smtpHost | quote }}
{{- end }}
{{- if .Values.smtpPort }}
- name: SMTP_PORT
value: {{ default "" .Values.smtpPort | quote }}
value: {{ .Values.smtpPort | quote }}
{{- end }}
{{- if .Values.smtpUser }}
- name: SMTP_USER
value: {{ default "" .Values.smtpUser | quote }}
value: {{ .Values.smtpUser | quote }}
{{- end }}
{{- if .Values.smtpPassword }}
- name: SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ template "redmine.fullname" . }}
key: smtp-password
{{- end }}
{{- if .Values.smtpTls }}
- name: SMTP_TLS
value: {{ default "" .Values.smtpTls | quote }}
value: {{ .Values.smtpTls | quote }}
{{- end }}
ports:
- name: http
containerPort: 3000
Expand All @@ -97,4 +130,5 @@ spec:
claimName: {{ .Values.persistence.existingClaim | default (include "redmine.fullname" .) }}
{{- else }}
emptyDir: {}
{{- end -}}
{{- end }}
{{- end }}
15 changes: 15 additions & 0 deletions stable/redmine/templates/externaldb-secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{{- if or (and .Values.databaseType.mariadb (not .Values.mariadb.enabled)) (and .Values.databaseType.postgresql (not .Values.postgresql.enabled)) }}
apiVersion: v1
kind: Secret
metadata:
name: {{ printf "%s-%s" .Release.Name "externaldb" }}
labels:
app: {{ printf "%s-%s" .Release.Name "externaldb" }}
chart: "{{ template "redmine.chart" . }}"
release: {{ .Release.Name | quote }}
heritage: {{ .Release.Service | quote }}
type: Opaque
data:
db-admin-user: {{ .Values.externalDatabase.user | b64enc | quote }}
db-password: {{ .Values.externalDatabase.password | b64enc | quote }}
{{- end }}
22 changes: 20 additions & 2 deletions stable/redmine/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ redmineUsername: user

## Application password
## Defaults to a random 10-character alphanumeric string if not set
## ref: https://github.com/bitnami/bitnami-docker-wordpress#environment-variables
## ref: https://github.com/bitnami/bitnami-docker-redmine#environment-variables
##
# redminePassword:

Expand Down Expand Up @@ -120,6 +120,8 @@ mariadb:
## https://github.com/helm/charts/blob/master/stable/postgresql/values.yaml
##
postgresql:
## Whether to deploy a PostgreSQL server to satisfy the applications database requirements. To use an external database set this to false and configure the externalDatabase parameters
enabled: false
## PostgreSQL admin password
## ref: https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md#setting-the-root-password-on-first-run
##
Expand All @@ -146,6 +148,22 @@ postgresql:
accessMode: ReadWriteOnce
size: 8Gi

## All of these values are only used when:
## a) mariadb.enabled is set to false and databaseType.mariadb is set to true
## b) postgresql.enabled is set to false and databaseType.postgresql is set to true
externalDatabase:
## Database host
host: localhost

## Database Admin User
user: root

## Database Admin Password
password: ""

## Database port number (use 5432 when using PostgreSQL)
port: 3306

## Kubernetes configuration
## minikube: NodePort
## ingress: ClusterIP
Expand Down Expand Up @@ -183,7 +201,7 @@ ingress:
- name: redmine.local

## Set this to true in order to enable TLS on the ingress record
## A side effect of this will be that the backend wordpress service will be connected at port 443
## A side effect of this will be that the backend redmine service will be connected at port 443
tls: false

## Set this to true in order to add the corresponding annotations for cert-manager
Expand Down

0 comments on commit 0f6bdf6

Please sign in to comment.