Adding Persistent Volume Claim to the existing file in Container Adding Persistent Volume Claim to the existing file in Container kubernetes kubernetes

Adding Persistent Volume Claim to the existing file in Container


check if you have storage class defined in your cluster.kubectl get storageclass If your are using default storage class as host-path(in case of minikube) then you do not need to include storage class into your template.

volumeClaimTemplates:- metadata: name: data spec: accessModes: [ "ReadWriteOnce" ] resources: requests: storage: 5Giby specifying no storage class k8s will go ahead and schedule the persistent volume with the default storage class which would be host-path in case of minikube also make sure /opt/myapp/etc exist on the node where pod is going to be scheduled.


Kubernetes will not allow the mounting 2 volumes to a same directory. second mount will overwrite the files created by the first.In my case docker image had some files in etc directory, which were removed after mounting the volume. Solved the problem using subpath.