Skip to content

Commit

Permalink
added k8s example (#193)
Browse files Browse the repository at this point in the history
  • Loading branch information
acjohnson authored Sep 14, 2022
1 parent 74ab060 commit b5dcd82
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,10 @@ Replace variables below to use the Docker version of this tool
* `{YOUR_GRAFANA_URL}`: Your Grafana site `URL`.
* `{YOUR_BACKUP_FOLDER_ON_THE_HOST}`: The `backup folder` on the Grafana host machine.

## Kubernetes
Check out the CronJob in [examples](examples) for a simple example of how grafana-backup-tool
can be ran within a Kubernetes environment

### Backup

If you decide to use a volume (-v) then you'll need to create the volume first with 1337 uid/gid ownership first, example:
Expand Down
49 changes: 49 additions & 0 deletions examples/grafana-backup-k8s-cronjob.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
---
apiVersion: v1
kind: Namespace
metadata:
name: grafana-backup-tool
---
apiVersion: v1
kind: ConfigMap
metadata:
name: grafana-backup-tool
namespace: grafana-backup-tool
data:
GRAFANA_URL: "http://grafana.grafana.svc.cluster.local:80"
GRAFANA_TOKEN: "{YOUR_GRAFANA_TOKEN}"
GRAFANA_ADMIN_ACCOUNT: "backup"
GRAFANA_ADMIN_PASSWORD: "{YOUR_GRAFANA_ADMIN_PASSWORD}"
AWS_ENDPOINT_URL: "http://gitlab-minio-svc.gitlab.svc.cluster.local:9000"
AWS_S3_BUCKET_NAME: "grafana-backup"
AWS_S3_BUCKET_KEY: "daily"
AWS_DEFAULT_REGION: "us-east-1"
AWS_ACCESS_KEY_ID: "{YOUR_AWS_ACCESS_KEY_ID}"
AWS_SECRET_ACCESS_KEY: "{YOUR_AWS_SECRET_ACCESS_KEY}"
---
# Run grafana-backup-tool daily and store backups in an S3
# compatible object storage such as minio
apiVersion: batch/v1
kind: CronJob
metadata:
name: grafana-backup-tool
namespace: grafana-backup-tool
labels:
app: grafana-backup-tool
spec:
schedule: "0 4 * * *"
jobTemplate:
metadata:
labels:
app: grafana-backup-tool
spec:
template:
spec:
restartPolicy: "Never"
containers:
- name: grafana-backup-tool
image: "ysde/docker-grafana-backup-tool:1.2.3"
imagePullPolicy: Always
envFrom:
- configMapRef:
name: grafana-backup-tool

0 comments on commit b5dcd82

Please sign in to comment.