Skip to content

Commit

Permalink
Merge pull request #7 from one-acre-fund/metabase
Browse files Browse the repository at this point in the history
metabase
  • Loading branch information
Yann-J authored May 18, 2021
2 parents be0a525 + addd4d2 commit 5346af1
Show file tree
Hide file tree
Showing 11 changed files with 314 additions and 0 deletions.
19 changes: 19 additions & 0 deletions charts/metabase/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
apiVersion: v2
name: metabase
version: 0.1.0
description: Metabase with postgres persistence and plugins support
home: https://www.metabase.com/
icon: https://avatars.githubusercontent.com/u/10520629?s=400&v=4
keywords:
- bi
- analytics
maintainers:
- name: Yann-J
email: yann.jouanique@gmail.com
sources:
- https://github.com/one-acre-fund/oaf-public-charts/tree/main/charts/metabase
dependencies:
- name: postgresql
version: ~10.1.2
repository: https://charts.bitnami.com/bitnami
condition: postgresql.enabled
52 changes: 52 additions & 0 deletions charts/metabase/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
# metabase

![Version: 0.1.0](https://img.shields.io/badge/Version-0.1.0-informational?style=flat-square)

Metabase with postgres persistence and plugins support

**Homepage:** <https://www.metabase.com/>

## Maintainers

| Name | Email | Url |
| ---- | ------ | --- |
| Yann-J | yann.jouanique@gmail.com | |

## Source Code

* <https://github.com/one-acre-fund/oaf-public-charts/tree/main/charts/metabase>

## TL;DR;

```console
$ helm repo add one-acre-fund https://one-acre-fund.github.io/oaf-public-charts
$ helm install my-release one-acre-fund/metabase
```

## Requirements

| Repository | Name | Version |
|------------|------|---------|
| https://charts.bitnami.com/bitnami | postgresql | ~10.1.2 |

## Values

| Key | Type | Default | Description |
|-----|------|---------|-------------|
| general.serviceType | string | `"ClusterIP"` | Used for all published services |
| global.storageClass | string | `"standard"` | This will be used on all pods for all PVCs, including dependencies (postgres) |
| ingress.annotations | object | `{}` | Dictionary of ingress annotations |
| ingress.enabled | bool | `false` | Install ingress? |
| ingress.tls | object | `{}` | Ingress TLS settings, passed directly to ingress definition |
| metabase | object | `{"extraPlugins":[],"image":{"name":"metabase/metabase","tag":"latest"},"replicas":1}` | See https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html for more details |
| metabase.extraPlugins | list | `[]` | Array of URLs to download extra plugins from (jar files) |
| metabase.image.name | string | `"metabase/metabase"` | Metabase image name |
| metabase.image.tag | string | `"latest"` | Metabase image tag |
| metabase.replicas | int | `1` | Replica count |
| postgresql | object | `{"enabled":true,"host":"","postgresqlDatabase":"metabase","postgresqlPassword":"ciJ8KfiMUK","postgresqlPostgresPassword":"H55Djpc7Vs","postgresqlUsername":"metabase","service":{"port":5432}}` | Postgres config See https://artifacthub.io/packages/helm/bitnami/postgresql for docs |
| postgresql.enabled | bool | `true` | Install postgres? |
| postgresql.postgresqlDatabase | string | `"metabase"` | Database to create and use |
| postgresql.postgresqlPassword | string | `"ciJ8KfiMUK"` | Application password |
| postgresql.postgresqlPostgresPassword | string | `"H55Djpc7Vs"` | Password for the `postgres` user |
| postgresql.postgresqlUsername | string | `"metabase"` | Application username |
| postgresql.service.port | int | `5432` | Postgres port |
23 changes: 23 additions & 0 deletions charts/metabase/README.md.gotmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
{{ template "chart.header" . }}
{{ template "chart.deprecationWarning" . }}

{{ template "chart.badgesSection" . }}

{{ template "chart.description" . }}

{{ template "chart.homepageLine" . }}

{{ template "chart.maintainersSection" . }}

{{ template "chart.sourcesSection" . }}

## TL;DR;

```console
$ helm repo add one-acre-fund https://one-acre-fund.github.io/oaf-public-charts
$ helm install my-release one-acre-fund/metabase
```

{{ template "chart.requirementsSection" . }}

{{ template "chart.valuesSection" . }}
2 changes: 2 additions & 0 deletions charts/metabase/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Thank you for installing Metabase as {{ .Release.Name }} in namespace {{ .Release.Namespace }}!

11 changes: 11 additions & 0 deletions charts/metabase/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{- define "secrets" -}}
db-password: {{ .Values.postgresql.postgresqlPassword | b64enc }}
{{- end -}}

{{- define "dbHost" -}}
{{ coalesce .Values.postgresql.host ( print .Release.Name "-postgresql." .Release.Namespace ".svc" ) }}
{{- end -}}

{{- define "dbUrl" -}}
{{ printf "postgresql://%s:%s@%s:%s/%s" .Values.postgresql.postgresqlUsername .Values.postgresql.postgresqlPassword (include "dbHost" .) ( toString .Values.postgresql.service.port ) .Values.postgresql.postgresqlDatabase }}
{{- end -}}
21 changes: 21 additions & 0 deletions charts/metabase/templates/ingress.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{{- if .Values.ingress.enabled -}}
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ .Release.Name }}-metabase
namespace: {{ .Release.Namespace }}
annotations:
{{- .Values.ingress.annotations | toYaml | nindent 4 }}
spec:
rules:
- host: {{ .Values.ingress.domain }}
http:
paths:
- backend:
serviceName: {{ .Release.Name }}-metabase
servicePort: 3000
path: /
pathType: Prefix
tls:
{{ .Values.ingress.tls | toYaml | nindent 2 }}
{{- end -}}
99 changes: 99 additions & 0 deletions charts/metabase/templates/metabase-deploy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-metabase
namespace: {{ .Release.Namespace }}
labels:
org.metabase.project: metabase
org.metabase.app: app
org.metabase.instance: {{ .Release.Name }}-metabase
spec:
replicas: {{ .Values.metabase.replicas }}
selector:
matchLabels:
org.metabase.instance: {{ .Release.Name }}-metabase
template:
metadata:
annotations:
checksum/secrets: {{ include "secrets" . | sha256sum }}
labels:
org.metabase.project: metabase
org.metabase.app: app
org.metabase.instance: {{ .Release.Name }}-metabase
spec:
initContainers:
{{- if .Values.metabase.extraPlugins }}
# Install plugins. These will fail silently
- name: install-plugins
image: curlimages/curl
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- |
cd /plugins
{{- range .Values.metabase.extraPlugins }}
echo Installing '{{ . }}'
curl -sSLfO '{{ . }}' && echo Success || echo Failed
{{- end }}
volumeMounts:
- name: plugin-volume
mountPath: /plugins
{{- end }}

# Wait for db
- name: wait-db
image: jwilder/dockerize:0.6.1
args:
- -wait
- tcp://{{ include "dbHost" . }}:{{ .Values.postgresql.service.port }}
- -timeout
- 300s

containers:
- name: app
image: "{{ .Values.metabase.image.name }}:{{.Values.metabase.image.tag }}"
# Mount custom plugin folder
volumeMounts:
- name: plugin-volume
mountPath: /plugins

env:
- name: MB_DB_TYPE
value: postgres
- name: MB_DB_DBNAME
value: {{ .Values.postgresql.postgresqlDatabase | quote }}
- name: MB_DB_PORT
value: {{ .Values.postgresql.service.port | quote }}
- name: MB_DB_USER
value: {{ .Values.postgresql.postgresqlUsername | quote }}
- name: MB_DB_PASS
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-metabase
key: db-password
- name: MB_DB_HOST
value: {{ include "dbHost" . | quote }}

ports:
- containerPort: 3000

readinessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 10
periodSeconds: 5
failureThreshold: 15
livenessProbe:
httpGet:
path: /api/health
port: 3000
initialDelaySeconds: 60
periodSeconds: 5
failureThreshold: 5

volumes:
# Temp folder to host downloaded plugins
- name: plugin-volume
emptyDir: {}
13 changes: 13 additions & 0 deletions charts/metabase/templates/metabase-svc.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
kind: Service
apiVersion: v1
metadata:
name: {{ .Release.Name }}-metabase
namespace: {{ .Release.Namespace }}
spec:
selector:
org.metabase.instance: {{ .Release.Name }}-metabase
ports:
- targetPort: 3000
port: 3000
name: app
type: {{ .Values.general.serviceType }}
7 changes: 7 additions & 0 deletions charts/metabase/templates/secrets.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-metabase
namespace: {{ .Release.Namespace }}
data:
{{- include "secrets" . | nindent 2 }}
20 changes: 20 additions & 0 deletions charts/metabase/templates/tests/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: v1
kind: Pod
metadata:
name: {{ .Release.Name }}-test
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": test-success
# "helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
restartPolicy: Never
containers:
- name: {{ .Release.Name }}-test-http
# Test published services - change this to reflect your endpoints
image: blacktop/httpie
imagePullPolicy: IfNotPresent
command:
- sh
- -ce
- |
http --ignore-stdin --check-status --print hb "http://{{ .Release.Name }}-metabase.{{ .Release.Namespace }}.svc:3000/api/health"
47 changes: 47 additions & 0 deletions charts/metabase/values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
global:
# -- This will be used on all pods for all PVCs, including dependencies (postgres)
storageClass: standard

general:
# -- Used for all published services
serviceType: ClusterIP

# -- See https://www.metabase.com/docs/latest/operations-guide/running-metabase-on-docker.html for more details
metabase:
# -- Replica count
replicas: 1
image:
# -- Metabase image name
name: metabase/metabase
# -- Metabase image tag
tag: latest
# -- Array of URLs to download extra plugins from (jar files)
extraPlugins: []

# -- Postgres config
# See https://artifacthub.io/packages/helm/bitnami/postgresql for docs
postgresql:
# -- Install postgres?
enabled: true
# Specify an external host here if desired - otherwise we will use the subchart dependency
host: ''

# -- Password for the `postgres` user
postgresqlPostgresPassword: H55Djpc7Vs
# -- Database to create and use
postgresqlDatabase: metabase
# -- Application username
postgresqlUsername: metabase
# -- Application password
postgresqlPassword: ciJ8KfiMUK
service:
# -- Postgres port
port: 5432

ingress:
# -- Install ingress?
enabled: false
# -- Dictionary of ingress annotations
annotations: {}
# -- Ingress TLS settings, passed directly to ingress definition
tls: {}

0 comments on commit 5346af1

Please sign in to comment.