<p>I wouldd to create a persistent volume on my kubernetes (gcp) cluster and use it in my django app as , for example, media folder.
On my kubernetes side i do:</p>
<p>First create a volumes claim:</p>
<pre><code>apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc-zeus
  namespace: ctest
spec:
  accessModes:
    - ReadWriteOnce
  resources:
    requests:
      storage: 5Gi
</code></pre>
<p>, then in my deployments.yaml i create a volume and associate to the pod:</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: django
  namespace: ctest
  labels:
    app: django
spec:
  replicas: 3
  selector:
    matchLabels:
      app: django
  template:
    metadata:
      labels:
        app: django
    spec:
      volumes:
        - name: cc-volume
          persistentVolumeClaim:
           claimName: pvc-zeus 
      containers:
        - name: django
          image: gcr.io/direct-variety-3066123/cc-mirror
          volumeMounts:
           - mountPath: &quot;/app/test-files&quot;
             name: cc-volume
      ...
</code></pre>
<p>then in my django settings:</p>
<pre><code>MEDIA_URL = '/test-files/'
</code></pre>
<p>Here my Dockerfile:</p>
<pre><code>FROM python:3.8-slim

ENV PROJECT_ROOT /app
WORKDIR $PROJECT_ROOT

COPY requirements.txt requirements.txt
RUN pip install -r requirements.txt
COPY . .

RUN chmod +x run.sh

CMD python manage.py runserver --settings=settings.kube 0.0.0.0:8000
</code></pre>
<p>when i apply volume claim on my cluster all was done (volume claim was created) but whe apply deployment.yaml no volume was created for the pods (also if i connect in bash to my pods, no folder test-files exist).</p>
<p>How can i create a volume on my deployments pods and use it in my django app?</p>
<p>So many thanks in advance</p>

Manuel Santi
<p>You need to have one of two Kubernetes objects in place in order to make a PVC: a <a href="https://kubernetes.io/docs/concepts/storage/persistent-volumes/" rel="nofollow noreferrer">PersistentVolume</a>(PV) or a <a href="https://kubernetes.io/docs/concepts/storage/storage-classes/" rel="nofollow noreferrer">StorageClass</a>(SC).</p>
<p>As you showed, your PVC <strong>does not indicate a PV or a SC</strong> from which to create a volume.</p>
<p>Usually, when you don't specify a PV or a SC in a PVC, a default SC will be used and you are not supposed to indicate the .resources in the PVC but in the default SC.</p>
<p>Maybe, if you just want to work with default SC, you would want to check if your specific cluster has it active or whether you need to create/activate it.</p>
