From b73bf57fc2db0212f4d720f7b27b4de6682613f1 Mon Sep 17 00:00:00 2001 From: Will Giddens Date: Thu, 24 Jan 2019 10:17:04 -0500 Subject: [PATCH] Add support for an external Postgres DB to the sentry chart. (#7449) The majority of this was done by jalberto here: https://github.com/helm/charts/pull/3376 Signed-off-by: Will Giddens --- stable/sentry/Chart.yaml | 2 +- stable/sentry/README.md | 14 ++++++-- stable/sentry/requirements.lock | 4 +-- stable/sentry/requirements.yaml | 1 + stable/sentry/templates/_helpers.tpl | 33 +++++++++++++++++++ stable/sentry/templates/cron-deployment.yaml | 10 +++--- .../sentry/templates/hooks/db-init.job.yaml | 10 +++--- .../templates/hooks/user-create.job.yaml | 10 +++--- stable/sentry/templates/secrets.yaml | 3 ++ stable/sentry/templates/service.yaml | 4 +++ stable/sentry/templates/web-deployment.yaml | 10 +++--- .../sentry/templates/workers-deployment.yaml | 10 +++--- stable/sentry/values.yaml | 7 +++- 13 files changed, 86 insertions(+), 32 deletions(-) diff --git a/stable/sentry/Chart.yaml b/stable/sentry/Chart.yaml index f16e7daa41..17db590f4a 100644 --- a/stable/sentry/Chart.yaml +++ b/stable/sentry/Chart.yaml @@ -1,7 +1,7 @@ apiVersion: v1 description: Sentry is a cross-platform crash reporting and aggregation platform. name: sentry -version: 1.1.0 +version: 1.2.0 appVersion: 9.0 keywords: - debugging diff --git a/stable/sentry/README.md b/stable/sentry/README.md index 2c0435b4af..5679beeb70 100644 --- a/stable/sentry/README.md +++ b/stable/sentry/README.md @@ -12,9 +12,7 @@ $ helm install --wait stable/sentry This chart bootstraps a [Sentry](https://sentry.io/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager. -It also packages the [PostgreSQL](https://github.com/kubernetes/charts/tree/master/stable/postgresql) and [Redis](https://github.com/kubernetes/charts/tree/master/stable/redis) which are required for Sentry. - -> **Warning**: This chart does not yet allow for you to specify your own database host or redis host. +It also optionally packages the [PostgreSQL](https://github.com/kubernetes/charts/tree/master/stable/postgresql) and [Redis](https://github.com/kubernetes/charts/tree/master/stable/redis) which are required for Sentry. ## Prerequisites @@ -104,6 +102,12 @@ The following table lists the configurable parameters of the Sentry chart and th | `ingress.annotations` | Ingress annotations | `{}` | | `ingress.hostname` | URL to address your Sentry installation | `sentry.local` | | `ingress.tls` | Ingress TLS configuration | `[]` | +| `postgresql.enabled` | Deploy postgres server (see below) | `true` | +| `postgresql.postgresDatabase` | Postgres database name | `sentry` | +| `postgresql.postgresUser` | Postgres username | `sentry` | +| `postgresql.postgresHost` | External postgres host | `nil` | +| `postgresql.postgresPassword` | External postgres password | `nil` | +| `postgresql.postgresPort` | External postgres port | `5432` | | `persistence.enabled` | Enable persistence using PVC | `true` | | `persistence.existingClaim` | Provide an existing `PersistentVolumeClaim` | `nil` | | `persistence.storageClass` | PVC Storage Class | `nil` (uses alpha storage class annotation) | @@ -130,6 +134,10 @@ $ helm install --name my-release -f values.yaml stable/sentry > **Tip**: You can use the default [values.yaml](values.yaml) +## PostgresSQL + +By default, PostgreSQL is installed as part of the chart. To use an external PostgreSQL server set `postgresql.enabled` to `false` and then set `postgresql.postgresHost` and `postgresql.postgresPassword`. The other options (`postgresql.postgresDatabase`, `postgresql.postgresUser` and `postgresql.postgresPort`) may also want changing from their default values. + ## Persistence The [Sentry](https://github.com/getsentry/docker-sentry) image stores the Sentry data at the `/var/lib/sentry/files` path of the container. diff --git a/stable/sentry/requirements.lock b/stable/sentry/requirements.lock index 4344402547..d630d73ded 100644 --- a/stable/sentry/requirements.lock +++ b/stable/sentry/requirements.lock @@ -5,5 +5,5 @@ dependencies: - name: redis repository: https://kubernetes-charts.storage.googleapis.com/ version: 3.8.1 -digest: sha256:bb223efbf7741e16ea4090893c70d8f6a600b53e43ecb91c37c02d7c9205702c -generated: 2018-09-05T20:53:38.493142607-07:00 +digest: sha256:48cdc656a1a3a2951266a108ddd3b0a4b4d3ce2af2e8ea54d81d2f88641bc6a1 +generated: 2018-09-11T18:06:41.639986538-04:00 diff --git a/stable/sentry/requirements.yaml b/stable/sentry/requirements.yaml index 24aa7e086e..f9fab760b6 100644 --- a/stable/sentry/requirements.yaml +++ b/stable/sentry/requirements.yaml @@ -2,6 +2,7 @@ dependencies: - name: postgresql version: 0.18.0 repository: https://kubernetes-charts.storage.googleapis.com/ + condition: postgresql.enabled - name: redis version: 3.8.1 repository: https://kubernetes-charts.storage.googleapis.com/ diff --git a/stable/sentry/templates/_helpers.tpl b/stable/sentry/templates/_helpers.tpl index 0283cb26dc..1a26d6c652 100644 --- a/stable/sentry/templates/_helpers.tpl +++ b/stable/sentry/templates/_helpers.tpl @@ -37,3 +37,36 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this {{- define "smtp.fullname" -}} {{- printf "%s-%s" .Release.Name "smtp" | trunc 63 | trimSuffix "-" -}} {{- end -}} + +{{/* +Set postgres host +*/}} +{{- define "postgresql.host" -}} +{{- if .Values.postgresql.enabled -}} +{{- template "postgresql.fullname" . -}} +{{- else -}} +{{- .Values.postgresql.postgresHost | quote -}} +{{- end -}} +{{- end -}} + +{{/* +Set postgres secret +*/}} +{{- define "postgresql.secret" -}} +{{- if .Values.postgresql.enabled -}} +{{- template "postgresql.fullname" . -}} +{{- else -}} +{{- template "fullname" . -}} +{{- end -}} +{{- end -}} + +{{/* +Set postgres port +*/}} +{{- define "postgresql.port" -}} +{{- if .Values.postgresql.enabled -}} + "5432" +{{- else -}} +{{- default "5432" .Values.postgresql.postgresPort | quote -}} +{{- end -}} +{{- end -}} diff --git a/stable/sentry/templates/cron-deployment.yaml b/stable/sentry/templates/cron-deployment.yaml index 833856b78c..7ba1fdc6d4 100644 --- a/stable/sentry/templates/cron-deployment.yaml +++ b/stable/sentry/templates/cron-deployment.yaml @@ -53,22 +53,22 @@ spec: name: {{ template "fullname" . }} key: sentry-secret - name: SENTRY_DB_USER - value: {{ default "sentry" .Values.postgresUser | quote }} + value: {{ default "sentry" .Values.postgresql.postgresUser | quote }} - name: SENTRY_DB_NAME - value: {{ default "sentry" .Values.postgresDatabase | quote }} + value: {{ default "sentry" .Values.postgresql.postgresDatabase | quote }} - name: SENTRY_DB_PASSWORD valueFrom: secretKeyRef: {{- if .Values.postgresql.existingSecret }} name: {{ .Values.postgresql.existingSecret }} {{- else }} - name: {{ template "postgresql.fullname" . }} + name: {{ template "postgresql.secret" . }} {{- end }} key: postgres-password - name: SENTRY_POSTGRES_HOST - value: {{ template "postgresql.fullname" . }} + value: {{ template "postgresql.host" . }} - name: SENTRY_POSTGRES_PORT - value: "5432" + value: {{ template "postgresql.port" . }} - name: SENTRY_REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/stable/sentry/templates/hooks/db-init.job.yaml b/stable/sentry/templates/hooks/db-init.job.yaml index 31492e3e42..83023f7018 100644 --- a/stable/sentry/templates/hooks/db-init.job.yaml +++ b/stable/sentry/templates/hooks/db-init.job.yaml @@ -37,22 +37,22 @@ spec: name: {{ template "fullname" . }} key: sentry-secret - name: SENTRY_DB_USER - value: {{ default "sentry" .Values.postgresUser | quote }} + value: {{ default "sentry" .Values.postgresql.postgresUser | quote }} - name: SENTRY_DB_NAME - value: {{ default "sentry" .Values.postgresDatabase | quote }} + value: {{ default "sentry" .Values.postgresql.postgresDatabase | quote }} - name: SENTRY_DB_PASSWORD valueFrom: secretKeyRef: {{- if .Values.postgresql.existingSecret }} name: {{ .Values.postgresql.existingSecret }} {{- else }} - name: {{ template "postgresql.fullname" . }} + name: {{ template "postgresql.secret" . }} {{- end }} key: postgres-password - name: SENTRY_POSTGRES_HOST - value: {{ template "postgresql.fullname" . }} + value: {{ template "postgresql.host" . }} - name: SENTRY_POSTGRES_PORT - value: "5432" + value: {{ template "postgresql.port" . }} - name: SENTRY_REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/stable/sentry/templates/hooks/user-create.job.yaml b/stable/sentry/templates/hooks/user-create.job.yaml index 582d052a2b..bf725f4bd3 100644 --- a/stable/sentry/templates/hooks/user-create.job.yaml +++ b/stable/sentry/templates/hooks/user-create.job.yaml @@ -37,22 +37,22 @@ spec: name: {{ template "fullname" . }} key: sentry-secret - name: SENTRY_DB_USER - value: {{ default "sentry" .Values.postgresUser | quote }} + value: {{ default "sentry" .Values.postgresql.postgresUser | quote }} - name: SENTRY_DB_NAME - value: {{ default "sentry" .Values.postgresDatabase | quote }} + value: {{ default "sentry" .Values.postgresql.postgresDatabase | quote }} - name: SENTRY_DB_PASSWORD valueFrom: secretKeyRef: {{- if .Values.postgresql.existingSecret }} name: {{ .Values.postgresql.existingSecret }} {{- else }} - name: {{ template "postgresql.fullname" . }} + name: {{ template "postgresql.secret" . }} {{- end }} key: postgres-password - name: SENTRY_POSTGRES_HOST - value: {{ template "postgresql.fullname" . }} + value: {{ template "postgresql.host" . }} - name: SENTRY_POSTGRES_PORT - value: "5432" + value: {{ template "postgresql.port" . }} - name: SENTRY_REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/stable/sentry/templates/secrets.yaml b/stable/sentry/templates/secrets.yaml index cfa8ffe276..0a985b5a46 100644 --- a/stable/sentry/templates/secrets.yaml +++ b/stable/sentry/templates/secrets.yaml @@ -22,3 +22,6 @@ data: {{ else }} user-password: {{ randAlphaNum 16 | b64enc | quote }} {{ end }} + {{ if not .Values.postgresql.enabled }} + postgres-password: {{ .Values.postgresql.postgresPassword | default "" | b64enc | quote }} + {{ end }} diff --git a/stable/sentry/templates/service.yaml b/stable/sentry/templates/service.yaml index 856cbb94b8..d240de7015 100644 --- a/stable/sentry/templates/service.yaml +++ b/stable/sentry/templates/service.yaml @@ -11,6 +11,10 @@ metadata: chart: "{{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}" release: "{{ .Release.Name }}" heritage: "{{ .Release.Service }}" +{{- if .Values.service.annotations }} + annotations: +{{ toYaml .Values.service.annotations | indent 4 }} +{{- end }} spec: type: {{ .Values.service.type }} ports: diff --git a/stable/sentry/templates/web-deployment.yaml b/stable/sentry/templates/web-deployment.yaml index a58409ed5f..8cb87b6ff2 100644 --- a/stable/sentry/templates/web-deployment.yaml +++ b/stable/sentry/templates/web-deployment.yaml @@ -52,22 +52,22 @@ spec: name: {{ template "fullname" . }} key: sentry-secret - name: SENTRY_DB_USER - value: {{ default "sentry" .Values.postgresUser | quote }} + value: {{ default "sentry" .Values.postgresql.postgresUser | quote }} - name: SENTRY_DB_NAME - value: {{ default "sentry" .Values.postgresDatabase | quote }} + value: {{ default "sentry" .Values.postgresql.postgresDatabase | quote }} - name: SENTRY_DB_PASSWORD valueFrom: secretKeyRef: {{- if .Values.postgresql.existingSecret }} name: {{ .Values.postgresql.existingSecret }} {{- else }} - name: {{ template "postgresql.fullname" . }} + name: {{ template "postgresql.secret" . }} {{- end }} key: postgres-password - name: SENTRY_POSTGRES_HOST - value: {{ template "postgresql.fullname" . }} + value: {{ template "postgresql.host" . }} - name: SENTRY_POSTGRES_PORT - value: "5432" + value: {{ template "postgresql.port" . }} - name: SENTRY_REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/stable/sentry/templates/workers-deployment.yaml b/stable/sentry/templates/workers-deployment.yaml index b4453e5346..6470447841 100644 --- a/stable/sentry/templates/workers-deployment.yaml +++ b/stable/sentry/templates/workers-deployment.yaml @@ -53,22 +53,22 @@ spec: name: {{ template "fullname" . }} key: sentry-secret - name: SENTRY_DB_USER - value: {{ default "sentry" .Values.postgresUser | quote }} + value: {{ default "sentry" .Values.postgresql.postgresUser | quote }} - name: SENTRY_DB_NAME - value: {{ default "sentry" .Values.postgresDatabase | quote }} + value: {{ default "sentry" .Values.postgresql.postgresDatabase | quote }} - name: SENTRY_DB_PASSWORD valueFrom: secretKeyRef: {{- if .Values.postgresql.existingSecret }} name: {{ .Values.postgresql.existingSecret }} {{- else }} - name: {{ template "postgresql.fullname" . }} + name: {{ template "postgresql.secret" . }} {{- end }} key: postgres-password - name: SENTRY_POSTGRES_HOST - value: {{ template "postgresql.fullname" . }} + value: {{ template "postgresql.host" . }} - name: SENTRY_POSTGRES_PORT - value: "5432" + value: {{ template "postgresql.port" . }} - name: SENTRY_REDIS_PASSWORD valueFrom: secretKeyRef: diff --git a/stable/sentry/values.yaml b/stable/sentry/values.yaml index b864cb26fc..8c63c01aca 100644 --- a/stable/sentry/values.yaml +++ b/stable/sentry/values.yaml @@ -145,9 +145,14 @@ ingress: # TODO: add support for plugins https://docs.sentry.io/server/plugins/ postgresql: + enabled: true postgresDatabase: sentry postgresUser: sentry - imageTag: "9.5" + # Only used when internal PG is disabled + # postgresHost: postgres + # postgresPassword: postgres + # postgresPort: 5432 + imageTag: "9.6" persistence: enabled: true