Skip to content
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
46 changes: 46 additions & 0 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,49 @@ Define the name of the secret to use
{{- template "plausible-analytics.fullname" . -}}
{{- end -}}
{{- end -}}

{{/*
Generate the PostgreSQL service name
*/}}
{{- define "plausible-analytics.postgresql.serviceName" -}}
{{- if .Values.postgresql.enabled -}}
{{- printf "%s-postgresql" (include "plausible-analytics.fullname" .) -}}
{{- else -}}
{{- required "A PostgreSQL service name is required when postgresql.enabled is false" .Values.postgresql.externalServiceName -}}
{{- end -}}
{{- end -}}

{{/*
Generate the ClickHouse service name
*/}}
{{- define "plausible-analytics.clickhouse.serviceName" -}}
{{- if .Values.clickhouse.enabled -}}
{{- printf "%s-clickhouse" (include "plausible-analytics.fullname" .) -}}
{{- else -}}
{{- required "A ClickHouse service name is required when clickhouse.enabled is false" .Values.clickhouse.externalServiceName -}}
{{- end -}}
{{- end -}}

{{/*
Generate the default PostgreSQL database URL
*/}}
{{- define "plausible-analytics.postgresql.defaultURL" -}}
{{- $serviceName := include "plausible-analytics.postgresql.serviceName" . -}}
{{- $username := .Values.postgresql.auth.username | default "postgres" -}}
{{- $password := .Values.postgresql.auth.password | default "postgres" -}}
{{- $database := .Values.postgresql.auth.database | default "plausible_db" -}}
{{- $port := .Values.postgresql.port | default 5432 -}}
{{- printf "postgres://%s:%s@%s:%v/%s" $username $password $serviceName $port $database -}}
{{- end -}}

{{/*
Generate the default ClickHouse database URL
*/}}
{{- define "plausible-analytics.clickhouse.defaultURL" -}}
{{- $serviceName := include "plausible-analytics.clickhouse.serviceName" . -}}
{{- $username := .Values.clickhouse.auth.username | default "clickhouse" -}}
{{- $password := .Values.clickhouse.auth.password | default "password" -}}
{{- $database := .Values.clickhouse.auth.database | default "plausible_events_db" -}}
{{- $port := 8123 -}}
{{- printf "http://%s:%s@%s:%v/%s" $username $password $serviceName $port $database -}}
{{- end -}}
4 changes: 4 additions & 0 deletions templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@ data:
TOTP_VAULT_KEY: {{ .Values.totpVaultKey | toString | b64enc }}
{{- if .Values.databaseURL }}
DATABASE_URL: {{ .Values.databaseURL | toString | b64enc }}
{{- else }}
DATABASE_URL: {{ include "plausible-analytics.postgresql.defaultURL" . | toString | b64enc }}
{{- end }}
{{- if .Values.clickhouseDatabaseURL }}
CLICKHOUSE_DATABASE_URL: {{ .Values.clickhouseDatabaseURL | toString | b64enc }}
{{- else }}
CLICKHOUSE_DATABASE_URL: {{ include "plausible-analytics.clickhouse.defaultURL" . | toString | b64enc }}
{{- end }}
{{- if .Values.mailer.enabled }}
{{- if eq .Values.mailer.adapter "Bamboo.Mua" }}
Expand Down
10 changes: 8 additions & 2 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ logFailedLoginAttempts: false # Controls whether to log warnings about failed l
## Plausible require a Postgres and Clickhouse database

### The URL to the Postgres Database Connection String see -> https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING
databaseURL: "postgres://postgres:postgres@plausible-analytics-postgresql:5432/plausible_db"
### If left empty, it will be automatically generated using the chart's PostgreSQL configuration
databaseURL: ""
### CA certificate for the database connection in PEM format. If not provided, the database connection will not use SSL.
databaseCA: null

### The URL Connection String to clickhouse DB see -> https://clickhouse.tech/docs/en/interfaces/http/
clickhouseDatabaseURL: "http://clickhouse:password@plausible-analytics-clickhouse:8123/plausible_events_db"
### If left empty, it will be automatically generated using the chart's ClickHouse configuration
clickhouseDatabaseURL: ""
clickhouseFlushIntervalMS: ""
clickhouseMaxBufferSize: ""

Expand Down Expand Up @@ -103,6 +105,8 @@ postgresql:
## If true, install the Postgresql chart
## ref: https://github.com/bitnami/charts/tree/main/bitnami/postgresql
enabled: true
## External PostgreSQL service name (used when postgresql.enabled is false)
# externalServiceName: "my-external-postgresql"
global:
security:
allowInsecureImages: true
Expand Down Expand Up @@ -135,6 +139,8 @@ clickhouse:
## If true, install the Clickhouse chart
## ref: https://github.com/bitnami/charts/tree/main/bitnami/clickhouse
enabled: true
## External ClickHouse service name (used when clickhouse.enabled is false)
# externalServiceName: "my-external-clickhouse"
global:
security:
allowInsecureImages: true
Expand Down