Is there need for a database when using grafana HA on k8s with PVC?

Hi all,

I’m looking into deploying grafana on an on-prem k8s cluster using the grafana helm chart.
I’d like to have it run in a HA configuration with several grafana pods replicas and I read that using a database is a must in such a case (Set up Grafana for high availability | Grafana documentation).

However, since the plan is to install grafana on k8s, is it possible to use a pvc instead of a database? If all the grafana pods will share the same pvc, wouldn’t that replace the need for a database? The storage class the pvc will use can handle multiple process access to files (sort of like an NFS).
Has anyone successfully deployed grafana in a HA setup on k8s with only a pvc?

Many thanks.

welcome @ishays

grafana stores almost everything in a db

we don’t want to conflate storage with application backend unless the application uses files in volumes to function (though sqlite is a file :wink: but you know what I mean)

1 Like

:Hi @ishays,

Welcome to the :grafana: community support forums !!

We are excited that you joined our OSS community. Please read about some of the FAQs in the community :slight_smile:

I talked to the Engineering folks and the short answer is that Grafana does need a Database.

Long answer:

Grafana needs a database. SQLite stores its DB on disk and thus can be stored in a PVC.

However, PVCs are per pod, so you can’t (generally) mount a PVC onto two instances. Then, there’s the fact that an SQLite database isn’t designed for concurrent writes, so even if you did, you’d get yourself into trouble.

3 Likes

Thank you both :slightly_smiling_face:

I’ll look into what DB to use.
If I point Grafana to use for example a postgres StatefulSet cluster as its DB (which will have its own pvc for saving DB data over pod restarts), does this mean I can disable persistence in Grafana’s values.yaml?
Or is persistence still required if I want to save dashboards and alerts across Grafana pod restarts for a HA setup, assuming I enable persistence with pvc instead of using the sidecar+configMaps option?

Hi @ishays

Not tested but Yes, if you are using an external DB you shouldn’t need persistence enabled in the chart.

While I am assuming disabling persistence still lets you use ENV VARS to point at the database.

@usman.ahmad wouldn’t persistence be needed for plugins?