<p>I have been reading about the ways in which I can push the database on kubernetes. Initially, I attached the data to the docker image and deployed the <code>service</code> and <code>deployment</code> files. But the issue was that when the container/pod restarts the data gets lost.
I, then, came across the concept of persistent volume claim. I found (<a href="https://www.magalix.com/blog/kubernetes-and-database" rel="nofollow noreferrer">https://www.magalix.com/blog/kubernetes-and-database</a>) and (<a href="https://kubernetes.io/docs/tutorials/stateful-application/cassandra/" rel="nofollow noreferrer">https://kubernetes.io/docs/tutorials/stateful-application/cassandra/</a>) very useful. I have few questions regarding them though:</p>
<p>PVC:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: mysql-pv-claim
spec:
  storageClassName: manual
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 20Gi
</code></pre>
<p>PV:</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: mysql-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 20Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
</code></pre>
<ol>
<li>How does the PVC get the storage from PV in the cluster? If I am running my service using Amazon cloud, what are the steps for the same, if any.</li>
</ol>

<p>PVCs will consume the PV resources you've provisioned. There a more detailed explanation in the Kubernetes docs on <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">Persistent Volumes</a> including the lifecycle of volumes and PV claims.</p>
<p>As a side note in case you weren't already aware, there are several Cassandra operators readily available which makes it easier for you to deploy a cluster on Kubernetes including <a href="https://github.com/instaclustr/cassandra-operator" rel="nofollow noreferrer">Instaclustr's</a>, <a href="https://github.com/Orange-OpenSource/casskop" rel="nofollow noreferrer">Orange's CassKop</a> and DataStax's <strong><a href="https://github.com/datastax/cass-operator" rel="nofollow noreferrer">cass-operator</a></strong>.</p>
<p>The DataStax cass-operator allows you to deploy either a DSE cluster or an Apache Cassandra cluster. You can find out more at the <a href="https://docs.datastax.com/en/cass-operator/doc/cass-operator/cassOperatorTOC.html" rel="nofollow noreferrer">official docs site here</a>. You can also reach out directly to the authors of the cass-operator at <a href="https://community.datastax.com" rel="nofollow noreferrer">https://community.datastax.com</a> if you have any questions. Cheers!</p>
