From b9b2feda53bd40d3dcf77a196d856601a6d67003 Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Mon, 17 May 2021 16:22:06 +0200 Subject: [PATCH 1/6] Metabase chart --- charts/metabase/Chart.yaml | 19 ++++ charts/metabase/README.md.gotmpl | 23 +++++ charts/metabase/templates/NOTES.txt | 2 + charts/metabase/templates/_helpers.tpl | 11 +++ charts/metabase/templates/ingress.yaml | 21 ++++ .../metabase/templates/metabase-deploy.yaml | 99 +++++++++++++++++++ charts/metabase/templates/metabase-svc.yaml | 13 +++ charts/metabase/templates/secrets.yaml | 7 ++ charts/metabase/templates/tests/test.yaml | 20 ++++ charts/metabase/values.yaml | 39 ++++++++ 10 files changed, 254 insertions(+) create mode 100644 charts/metabase/Chart.yaml create mode 100644 charts/metabase/README.md.gotmpl create mode 100644 charts/metabase/templates/NOTES.txt create mode 100644 charts/metabase/templates/_helpers.tpl create mode 100644 charts/metabase/templates/ingress.yaml create mode 100644 charts/metabase/templates/metabase-deploy.yaml create mode 100644 charts/metabase/templates/metabase-svc.yaml create mode 100644 charts/metabase/templates/secrets.yaml create mode 100644 charts/metabase/templates/tests/test.yaml create mode 100644 charts/metabase/values.yaml diff --git a/charts/metabase/Chart.yaml b/charts/metabase/Chart.yaml new file mode 100644 index 0000000..d8f7dc1 --- /dev/null +++ b/charts/metabase/Chart.yaml @@ -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 diff --git a/charts/metabase/README.md.gotmpl b/charts/metabase/README.md.gotmpl new file mode 100644 index 0000000..9af29c0 --- /dev/null +++ b/charts/metabase/README.md.gotmpl @@ -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" . }} \ No newline at end of file diff --git a/charts/metabase/templates/NOTES.txt b/charts/metabase/templates/NOTES.txt new file mode 100644 index 0000000..baf8fd6 --- /dev/null +++ b/charts/metabase/templates/NOTES.txt @@ -0,0 +1,2 @@ +Thank you for installing Metabase as {{ .Release.Name }} in namespace {{ .Release.Namespace }}! + diff --git a/charts/metabase/templates/_helpers.tpl b/charts/metabase/templates/_helpers.tpl new file mode 100644 index 0000000..7504438 --- /dev/null +++ b/charts/metabase/templates/_helpers.tpl @@ -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 -}} diff --git a/charts/metabase/templates/ingress.yaml b/charts/metabase/templates/ingress.yaml new file mode 100644 index 0000000..3fea564 --- /dev/null +++ b/charts/metabase/templates/ingress.yaml @@ -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 -}} diff --git a/charts/metabase/templates/metabase-deploy.yaml b/charts/metabase/templates/metabase-deploy.yaml new file mode 100644 index 0000000..537fc11 --- /dev/null +++ b/charts/metabase/templates/metabase-deploy.yaml @@ -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: / + port: 3000 + initialDelaySeconds: 10 + periodSeconds: 5 + failureThreshold: 15 + livenessProbe: + httpGet: + path: / + port: 3000 + initialDelaySeconds: 60 + periodSeconds: 5 + failureThreshold: 5 + + volumes: + # Temp folder to host downloaded plugins + - name: plugin-volume + emptyDir: {} diff --git a/charts/metabase/templates/metabase-svc.yaml b/charts/metabase/templates/metabase-svc.yaml new file mode 100644 index 0000000..4ea604e --- /dev/null +++ b/charts/metabase/templates/metabase-svc.yaml @@ -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 }} diff --git a/charts/metabase/templates/secrets.yaml b/charts/metabase/templates/secrets.yaml new file mode 100644 index 0000000..aa2611d --- /dev/null +++ b/charts/metabase/templates/secrets.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ .Release.Name }}-metabase + namespace: {{ .Release.Namespace }} +data: + {{- include "secrets" . | nindent 2 }} diff --git a/charts/metabase/templates/tests/test.yaml b/charts/metabase/templates/tests/test.yaml new file mode 100644 index 0000000..837fbb0 --- /dev/null +++ b/charts/metabase/templates/tests/test.yaml @@ -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 + image: curlimages/curl + imagePullPolicy: IfNotPresent + # Test published services - change this to reflect your endpoints + command: + - sh + - -ce + - | + curl -sSfv http://{{ .Release.Name }}-metabase.{{ .Release.Namespace }}.svc:3000/ diff --git a/charts/metabase/values.yaml b/charts/metabase/values.yaml new file mode 100644 index 0000000..42e0c79 --- /dev/null +++ b/charts/metabase/values.yaml @@ -0,0 +1,39 @@ +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 From 22f124214e56055bc25e33309f99cfc0bc8db4f1 Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Mon, 17 May 2021 16:22:26 +0200 Subject: [PATCH 2/6] README --- charts/metabase/README.md | 49 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 charts/metabase/README.md diff --git a/charts/metabase/README.md b/charts/metabase/README.md new file mode 100644 index 0000000..93a1d55 --- /dev/null +++ b/charts/metabase/README.md @@ -0,0 +1,49 @@ +# 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:** + +## Maintainers + +| Name | Email | Url | +| ---- | ------ | --- | +| Yann-J | yann.jouanique@gmail.com | | + +## Source Code + +* + +## 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) | +| 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 | \ No newline at end of file From f5269cdc4ee592c6c302665ce1152851d8d545b3 Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Mon, 17 May 2021 16:34:50 +0200 Subject: [PATCH 3/6] Fix ingress lint --- charts/metabase/README.md | 3 +++ charts/metabase/values.yaml | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/charts/metabase/README.md b/charts/metabase/README.md index 93a1d55..b01d020 100644 --- a/charts/metabase/README.md +++ b/charts/metabase/README.md @@ -35,6 +35,9 @@ $ helm install my-release one-acre-fund/metabase |-----|------|---------|-------------| | 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 | diff --git a/charts/metabase/values.yaml b/charts/metabase/values.yaml index 42e0c79..854afe8 100644 --- a/charts/metabase/values.yaml +++ b/charts/metabase/values.yaml @@ -37,3 +37,11 @@ postgresql: service: # -- Postgres port port: 5432 + +ingress: + # -- Install ingress? + enabled: false + # -- Dictionary of ingress annotations + annotations: {} + # -- Ingress TLS settings, passed directly to ingress definition + tls: {} From 0ca4ed2adfda88464608048821f046eb0018a8f6 Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Tue, 18 May 2021 06:54:51 +0200 Subject: [PATCH 4/6] Bump build --- charts/metabase/templates/metabase-deploy.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/charts/metabase/templates/metabase-deploy.yaml b/charts/metabase/templates/metabase-deploy.yaml index 537fc11..aa5a92c 100644 --- a/charts/metabase/templates/metabase-deploy.yaml +++ b/charts/metabase/templates/metabase-deploy.yaml @@ -39,7 +39,7 @@ spec: volumeMounts: - name: plugin-volume mountPath: /plugins - {{- end}} + {{- end }} # Wait for db - name: wait-db From 0cac47ee0b4b04817df612833efdde8444af55a9 Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Tue, 18 May 2021 10:28:41 +0200 Subject: [PATCH 5/6] Better helm test --- charts/metabase/templates/tests/test.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/charts/metabase/templates/tests/test.yaml b/charts/metabase/templates/tests/test.yaml index 837fbb0..733b281 100644 --- a/charts/metabase/templates/tests/test.yaml +++ b/charts/metabase/templates/tests/test.yaml @@ -10,11 +10,11 @@ spec: restartPolicy: Never containers: - name: {{ .Release.Name }}-test-http - image: curlimages/curl - imagePullPolicy: IfNotPresent # Test published services - change this to reflect your endpoints + image: blacktop/httpie + imagePullPolicy: IfNotPresent command: - sh - -ce - | - curl -sSfv http://{{ .Release.Name }}-metabase.{{ .Release.Namespace }}.svc:3000/ + http --ignore-stdin --check-status --print hb "http://{{ .Release.Name }}-metabase.{{ .Release.Namespace }}.svc:3000/api/health" From addd4d2c8e4a38a0c5e7ef9f527191f6bd4e78ac Mon Sep 17 00:00:00 2001 From: Yann Jouanique Date: Tue, 18 May 2021 10:29:18 +0200 Subject: [PATCH 6/6] Better probes --- charts/metabase/templates/metabase-deploy.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/charts/metabase/templates/metabase-deploy.yaml b/charts/metabase/templates/metabase-deploy.yaml index aa5a92c..a939b08 100644 --- a/charts/metabase/templates/metabase-deploy.yaml +++ b/charts/metabase/templates/metabase-deploy.yaml @@ -80,14 +80,14 @@ spec: readinessProbe: httpGet: - path: / + path: /api/health port: 3000 initialDelaySeconds: 10 periodSeconds: 5 failureThreshold: 15 livenessProbe: httpGet: - path: / + path: /api/health port: 3000 initialDelaySeconds: 60 periodSeconds: 5