Create image database for grafana

This commit is contained in:
2025-11-25 10:41:24 +01:00
parent 098f7b5025
commit 237761e2ca
6 changed files with 82 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
# RAW
Where all lonely children go to die
Custom manifests we can't be bothered to template or properly structure. Still try to namespace them and stuff though.
```bash
raw
└── tos # site
└── oceanbox # cluster
└── database # whatever
```
+6
View File
@@ -0,0 +1,6 @@
Catch-all db for whatever. Currently just used for media files used in grafana.
Example usage:
- `echo "select * from images" | ./query`
- `cat upload.sql | ./query`
- `./upload-img.sh my-image ~/Picture/pretty.png | ./query`
@@ -0,0 +1,5 @@
CREATE TABLE images (
name text,
image bytea,
UNIQUE(name)
);
@@ -0,0 +1,20 @@
apiVersion: postgresql.cnpg.io/v1
kind: Cluster
metadata:
name: oceanbox
namespace: oceanbox
spec:
instances: 1
storage:
size: 10Gi
---
apiVersion: postgresql.cnpg.io/v1
kind: Database
metadata:
name: grafana-aux
spec:
name: aux
owner: app
cluster:
name: oceanbox
+8
View File
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
# NOTE(simkir): Pipe your queries into this
# E.g.:
# - echo "select * from images" | ./query
# - cat upload.sql | ./query
kubectl --context oceanbox -n oceanbox exec -i svc/oceanbox-rw -c postgres -- psql aux
+30
View File
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
# Simple script for uploading a base64 encoded image into our database. For
# grafana business image panels.
if [ $# -ne 2 ]
then
echo "Usage: $0 <image-name> <file>.png"
exit 1
fi
filename=$1
file=$2
if [ ! -e $file ]
then
echo "file $file does not exist"
exit 1
fi
function create_image() {
local filename=$1
local data=$2
cat << EOF
INSERT INTO images VALUES('$filename', '$data');
EOF
}
data=$(cat $file | base64 -w0)
create_image $filename $data