<p>H2 is an open-source lightweight Java database.
Basically I am trying to build a DevOps pipeline but for the Kubernetes part I need to hook up the h2 database locally to the pod and not using  aws rds for anything like that.  Any ideas on how to configure this?</p>

<p>It’s a little unclear when you say you need to hook up H2 locally in each pod whether you mean 1 H2 overall or 1 per pod.  I’m assuming you need a server H2 and not an embedded one.</p>

<p>If your requirement is to have all your pods talking to the same H2 instance, you can create a container that runs H2 in server mode and run it in a Deployment.  You <em>would</em> also need a Service to expose the database port within the cluster.  See <a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/#accessing-the-service</a> for some details.  </p>

<p>You’d probably also want to run H2 with a file backing the database, unless you can recreate the contents of the database by some other magic when its pod restarts.  For that file to be persistent across H2 restarts, you would need to provision a persistent volume and persistent volume binding.  Details for PVs are Kubernetes platform specific.  <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/storage/persistent-volumes/</a></p>

<p>If you don’t need a single H2, but rather one in each pod, you could run an H2 container in each pod beside your other other container(s). Or you could fork an H2 server in a Deployment’s main container command, if you don’t want to use H2 in a container. (Ugly, though and not really the Kubernetes way.) You <em>would not</em> need a Service in this case, as you’d connect to H2 locally in the Pod.  But you’d have a real nightmare I’d think managing persistent volumes to hold the database for each Pod’s H2, assuming you need persistent storage.  </p>

<p>Ultimately, you may decide that RDS is easier...</p>
