I'm building a project(frontend+backend+DB), containerize it, & deploy it on minikube(single node cluster). Due to absence of PV, I lost the data after pod update. Trying to figure out how I can create a PV for hostpath & keep that database on that storage for data persistance.
I tried out to link deployment.yml with pvc.yml & pvc.yml with pv.yml. While executing pv.yml file giving node affinity error & host path error. can't find how to resolve the error.
apiVersion: v1
kind: PersistentVolume
metadata:
name: mlh-pv
spec:
capacity:
storage: 500Mi
accessModes:
- ReadWriteOnce
hostPath:
path: /home/parth/storage-mlh
type: DirectoryOrCreate
- pvc.yml
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mlh-pvc
spec:
volumeName: mlh-pv
storageClassName: manual
resources:
requests:
storage: 500Mi
volumeMode: Filesystem
accessModes:
- ReadWriteOnce
- deployment.yml (spec section)
spec:
selector:
matchLabels:
app: mlh-with-hostpath
template:
metadata:
labels:
app: mlh-with-hostpath
spec:
containers:
- name: mlh-with-hostpath
image: parth721/django-mlh:4.2
volumeMounts:
- name: www-hostpath-storage
mountPath: /app/db.sqlite3
resources:
limits:
memory: "300Mi"
cpu: "500m"
ports:
- containerPort: 8000
volumes:
- name: www-hostpath-storage
hostPath:
path: /home/parth/storage-mlh
type: DirectoryOrCreate