<p>I need to make use of PVC to specify the specs of the PV and I also need to make sure it uses a custom local storage path in the PV.</p>
<p><em>I am unable to figure out how to mention the hostpath in a PVC</em>?</p>
<p>This is the PVC config:</p>
<pre class="lang-yaml prettyprint-override"><code>apiVersion: v1 
kind: PersistentVolumeClaim
metadata: 
  name: mongo-pvc 
spec: 
  accessModes: 
    - ReadWriteOnce
  resources: 
    requests: 
      storage: 1Gi
</code></pre>
<p>And this is the mongodb deployment:</p>
<pre class="lang-yaml prettyprint-override"><code>spec:
    replicas: 1
    selector:
        matchLabels:
            app: mongo
    template:
        metadata:
            labels: 
                app: mongo
        spec:
            volumes: 
                - name: mongo-volume 
                  persistentVolumeClaim: 
                    claimName: mongo-pvc 
            containers:
                - name: mongo
                  image: mongo
                  ports:
                    - containerPort: 27017
                  volumeMounts: 
                    - name: mongo-volume 
                      mountPath: /data/db 
</code></pre>
<p><strong>How</strong> and <strong>where</strong> do I mention the <strong><a href="https://kubernetes.io/docs/concepts/storage/volumes/#hostpath" rel="noreferrer">hostPath</a></strong> to be mounted in here?</p>

<p>Doc says that you set <code>hostPath</code> when creating a PV (the step before creating PVC).</p>
<pre><code>apiVersion: v1
kind: PersistentVolume
metadata:
  name: task-pv-volume
  labels:
    type: local
spec:
  storageClassName: manual
  capacity:
    storage: 10Gi
  accessModes:
    - ReadWriteOnce
  hostPath:
    path: &quot;/mnt/data&quot;
</code></pre>
<p>After you create the PersistentVolumeClaim, the Kubernetes control plane looks for a PersistentVolume that satisfies the claim's requirements. If the control plane finds a suitable PersistentVolume with the same StorageClass, it binds the claim to the volume.</p>
<p>Please see <a href="https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/" rel="noreferrer">https://kubernetes.io/docs/tasks/configure-pod-container/configure-persistent-volume-storage/</a></p>
