The basic volume (part of pod deployment) is destroyed along with POD.
-
Create a new POD using file pod-volume.yaml.
$ kubectl apply -f pod-volume1.yaml
-
Save the file using name
pod-volume1.yaml
and deploy usingkubectl
$ kubectl apply -f pod-volume1.yaml $ kubectl get po pod-volume1
-
Execute
bash
on running pod (Enter inside pod container to verify volume)$ kubectl exec -it pod-volume1 -- sh $ cd /data $ echo "Testing the filesystem" > file1 $ exit
-
Try deleting and re-creating the pod and then test the
/data
directory to check if volume was deleted along with pod.$ kubectl delete -f pod-volume1.yaml # wait for 1 minutes and then $ kubectl apply -f pod-volume1.yaml # Execute bash on container $ kubectl exec -it pod-volume1 -- sh $ cd /data # Try display content of file1 $ cat file1 # EXPECTED: File contents # Now quit the bash and delete pod $ exit $ kubectl delete -f pod-volume1.yaml