From 2d87a3230cddbfba03334ab5f9cc753132ad80ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lu=C3=ADs=20Simas?= Date: Sun, 23 Jun 2024 11:11:27 -0300 Subject: [PATCH] docs: add docker compose and kubernetes examples --- .../Zettelkasten-InfluxDB.json | 12 ++-- examples/compose/docker-compose.yaml | 55 ++++++++++++++++ examples/compose/sample/dir1/dir2/four.md | 3 + examples/compose/sample/dir1/three.md | 7 ++ examples/compose/sample/one.md | 5 ++ examples/compose/sample/two.md | 3 + examples/kubernetes/manifest.yaml | 66 +++++++++++++++++++ 7 files changed, 145 insertions(+), 6 deletions(-) rename {examples => dashboards}/Zettelkasten-InfluxDB.json (98%) create mode 100644 examples/compose/docker-compose.yaml create mode 100644 examples/compose/sample/dir1/dir2/four.md create mode 100644 examples/compose/sample/dir1/three.md create mode 100644 examples/compose/sample/one.md create mode 100644 examples/compose/sample/two.md create mode 100644 examples/kubernetes/manifest.yaml diff --git a/examples/Zettelkasten-InfluxDB.json b/dashboards/Zettelkasten-InfluxDB.json similarity index 98% rename from examples/Zettelkasten-InfluxDB.json rename to dashboards/Zettelkasten-InfluxDB.json index 7836c4f..859a935 100644 --- a/examples/Zettelkasten-InfluxDB.json +++ b/dashboards/Zettelkasten-InfluxDB.json @@ -18,7 +18,7 @@ "editable": true, "fiscalYearStartMonth": 0, "graphTooltip": 0, - "id": 3, + "id": 1, "links": [], "panels": [ { @@ -213,7 +213,7 @@ "type": "influxdb", "uid": "edogaymh9y96of" }, - "query": "from(bucket: v.defaultBucket)\n|> range(start: -1d)\n|> last()\n|> group()", + "query": "from(bucket: v.defaultBucket)\n|> range(start: v.timeRangeStart, stop: v.timeRangeStop)\n|> last()\n|> group()", "refId": "A" } ], @@ -428,7 +428,7 @@ "type": "timeseries" } ], - "refresh": "1m", + "refresh": "10s", "schemaVersion": 39, "tags": [], "templating": { @@ -437,7 +437,7 @@ "current": { "selected": false, "text": "influxdb", - "value": "edogaymh9y96of" + "value": "bdp8tekqeihogd" }, "hide": 0, "includeAll": false, @@ -454,7 +454,7 @@ ] }, "time": { - "from": "now-5y", + "from": "now-1h", "to": "now" }, "timeRangeUpdatedDuringEditOrView": false, @@ -462,6 +462,6 @@ "timezone": "browser", "title": "Zettelkasten", "uid": "fdoghlpqzr5kwe", - "version": 8, + "version": 2, "weekStart": "" } \ No newline at end of file diff --git a/examples/compose/docker-compose.yaml b/examples/compose/docker-compose.yaml new file mode 100644 index 0000000..69b651f --- /dev/null +++ b/examples/compose/docker-compose.yaml @@ -0,0 +1,55 @@ +# This is a sample compose file for deploying the zettelkasten-exporter +# using an InfluxDB storage. +version: '3.8' + +volumes: + influxdb-data: {} + influxdb-config: {} + grafana-data: {} + +services: + grafana: + image: grafana/grafana + depends_on: + - influxdb + restart: unless-stopped + volumes: + - grafana-data:/var/lib/grafan + ports: + - 3000:3000 + + influxdb: + image: influxdb:2 + environment: + # We opt for an automated setup of InfluxDB for simplicity. It's + # strongly recommended to change those credentials or doing a + # manual InfluxDB setup + DOCKER_INFLUXDB_INIT_MODE: setup + DOCKER_INFLUXDB_INIT_USERNAME: admin + DOCKER_INFLUXDB_INIT_PASSWORD: password + DOCKER_INFLUXDB_INIT_ORG: default + DOCKER_INFLUXDB_INIT_BUCKET: zettelkasten + DOCKER_INFLUXDB_INIT_RETENTION: 1w + DOCKER_INFLUXDB_INIT_ADMIN_TOKEN: demo-auth-token + volumes: + - influxdb-data:/var/lib/influxdb2 + - influxdb-config:/etc/influxdb2 + ports: + - 8086:8086 + + zettelkasten-exporter: + image: ghcr.io/luissimas/zettelkasten-exporter:latest + depends_on: + - influxdb + environment: + LOG_LEVEL: INFO + # Here we use a local directory for simplicity, but check out the + # README to see how to configure different sources such as git repositories. + ZETTELKASTEN_DIRECTORY: /sample + COLLECTION_INTERVAL: 10s + INFLUXDB_TOKEN: demo-auth-token + INFLUXDB_URL: http://influxdb:8086 + INFLUXDB_ORG: default + INFLUXDB_BUCKET: zettelkasten + volumes: + - ./sample:/sample diff --git a/examples/compose/sample/dir1/dir2/four.md b/examples/compose/sample/dir1/dir2/four.md new file mode 100644 index 0000000..d3eb6ab --- /dev/null +++ b/examples/compose/sample/dir1/dir2/four.md @@ -0,0 +1,3 @@ +# Four + +Relative link to [[../three.md]]. And another link to [[one]]. diff --git a/examples/compose/sample/dir1/three.md b/examples/compose/sample/dir1/three.md new file mode 100644 index 0000000..e045c32 --- /dev/null +++ b/examples/compose/sample/dir1/three.md @@ -0,0 +1,7 @@ +# Three + +Multiple links in this one. + +[[one]] +[[two.md]] +[[four]] diff --git a/examples/compose/sample/one.md b/examples/compose/sample/one.md new file mode 100644 index 0000000..3a6b3e7 --- /dev/null +++ b/examples/compose/sample/one.md @@ -0,0 +1,5 @@ +# One + +This is a markdown note. + +This is a [[link to a second|two.md]] note. diff --git a/examples/compose/sample/two.md b/examples/compose/sample/two.md new file mode 100644 index 0000000..c7f9383 --- /dev/null +++ b/examples/compose/sample/two.md @@ -0,0 +1,3 @@ +# Two + +This note links to the [[three.md]] note. diff --git a/examples/kubernetes/manifest.yaml b/examples/kubernetes/manifest.yaml new file mode 100644 index 0000000..0aeac98 --- /dev/null +++ b/examples/kubernetes/manifest.yaml @@ -0,0 +1,66 @@ +# This is a sample manifest for deploying the zettelkasten-exporter using an InfluxDB +# storage. +# To deploy InfluxDB, see: https://github.com/influxdata/helm-charts/tree/master/charts/influxdb2 +--- +apiVersion: v1 +kind: Namespace +metadata: + name: monitoring +--- +apiVersion: v1 +kind: Secret +metadata: + name: zettelkasten-exporter-env + namespace: monitoring +type: Opaque +data: + # These are placeholder values. Replace them with the + # appropriate values for your setup. + github-token: YW55LXRva2Vu + influxdb-token: YW55LXRva2Vu +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: zettelkasten-exporter + namespace: monitoring + labels: + app.kubernetes.io/name: zettelkasten-exporter +spec: + selector: + matchLabels: + app.kubernetes.io/name: zettelkasten-exporter + replicas: 1 + template: + metadata: + labels: + app.kubernetes.io/name: zettelkasten-exporter + spec: + containers: + - name: zettelkasten-exporter + image: "ghcr.io/luissimas/zettelkasten-exporter:latest" + env: + - name: LOG_LEVEL + value: INFO + - name: COLLECTION_INTERVAL + value: 5m + - name: ZETTELKASTEN_GIT_URL + value: + - name: ZETTELKASTEN_GIT_BRANCH + value: master + - name: ZETTELKASTEN_GIT_TOKEN + valueFrom: + secretKeyRef: + name: zettelkasten-exporter-env + key: github-token + - name: INFLUXDB_URL + value: http://influxdb-influxdb2 + - name: INFLUXDB_ORG + value: homelab + - name: INFLUXDB_BUCKET + value: zettelkasten + - name: INFLUXDB_TOKEN + valueFrom: + secretKeyRef: + name: zettelkasten-exporter-env + key: influxdb-token