Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[mattermost-team-edition] add existingSecret for externalDB #467

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/mattermost-team-edition/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
description: Mattermost Team Edition server.
type: application
name: mattermost-team-edition
version: 6.6.60
version: 6.6.61
appVersion: 9.10.1
keywords:
- mattermost
Expand Down
16 changes: 16 additions & 0 deletions charts/mattermost-team-edition/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ Parameter | Description
`mysql.mysqlPassword` | User Password for Mysql (Required) | ""
`mysql.mysqlDatabase` | Database name (Required) | "mattermost"
`externalDB.enabled` | Enables use of an preconfigured external database server | `false`
`externalDB.existingSecret` | Uses an externally configured secret instead of externalDriverType + externalConnectionString | ""
`externalDB.existingSecretKey` | The key in the existingSecret containing the necessary Connection String | ""
`externalDB.externalDriverType` | `"postgres"` or `"mysql"` | ""
`externalDB.externalConnectionString` | See the section about [external databases](#External-Databases). | ""
`extraPodAnnotations` | Extra pod annotations to be used in the deployments | `[]`
Expand Down Expand Up @@ -220,6 +222,20 @@ externalDB:
externalConnectionString: "<USERNAME>:<PASSWORD>@tcp(<HOST>:3306)/<DATABASE_NAME>?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s"
```

#### External Secret
To use an externally configured secret, You need to set Mattermost **externalDB** config and the **existingSecret**

**IMPORTANT:** Make sure the DB is already created before deploying Mattermost services

Example when using **Percona Operator for PostgreSQL**:

```yaml
externalDB:
enabled: true
existingSecret: "mattermost-pguser-mattermost"
existingSecretKey: "uri"
```

#### Expose extra ports
To use plugins that require extra ports to be exposed, you can use the following config

Expand Down
8 changes: 8 additions & 0 deletions charts/mattermost-team-edition/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,16 @@ spec:
- name: MM_CONFIG
valueFrom:
secretKeyRef:
{{- if .Values.externalDB.existingSecret }}
name: {{ .Values.externalDB.existingSecret }}
{{- else }}
name: {{ include "mattermost-team-edition.fullname" . }}-mattermost-dbsecret
{{- end }}
{{- if .Values.externalDB.existingSecretKey }}
key: {{ .Values.externalDB.existingSecretKey }}
{{- else }}
key: mattermost.dbsecret
{{- end }}
{{- if .Values.extraEnvVars }}
{{- .Values.extraEnvVars | toYaml | nindent 8 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{{- if not .Values.externalDB.existingSecret }}
apiVersion: v1
kind: Secret
metadata:
Expand All @@ -9,8 +10,9 @@ metadata:
helm.sh/chart: {{ include "mattermost-team-edition.chart" . }}
type: Opaque
data:
{{- if .Values.mysql.enabled }}
{{- if .Values.mysql.enabled }}
mattermost.dbsecret: {{ tpl "mysql://{{ .Values.mysql.mysqlUser }}:{{ .Values.mysql.mysqlPassword }}@tcp({{ .Release.Name }}-mysql:3306)/{{ .Values.mysql.mysqlDatabase }}?charset=utf8mb4,utf8&readTimeout=30s&writeTimeout=30s" . | b64enc }}
{{- else }}
{{- else }}
mattermost.dbsecret: {{ tpl "{{ .Values.externalDB.externalDriverType }}://{{ .Values.externalDB.externalConnectionString }}" . | b64enc }}
{{- end }}
{{- end }}
4 changes: 4 additions & 0 deletions charts/mattermost-team-edition/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ route:
externalDB:
enabled: false

## when externally configured
# existingSecret: secretname
# existingSecretKey: keywithfulluri

## postgres or mysql
externalDriverType: ""

Expand Down