I'm learning Kubernetes and trying to follow the following tutorial to create a Mysql database:
Until now, I've been using Docker and Docker-compose to do all of my development and production work.
Using Docker Desktop's (On Mac) Kubernetes single master node cluster, I was able to get the example working and interact with Mysql creating a table and filling some data. After deleting the resources and retrying, the data persisted and I was able to access the data immediately upon reinstalling the Deployment, service, PV and PVC. A successful pre-requisite for connecting an application.
However I cannot for the life of me find out WHERE the data is actually being stored on my laptop's local file system . There are only 2 file paths listed in these examples. One in the deployment (which I assume to be the container's internal filesystem , Similar to Docker's container internal path):
volumeMounts:
- name: mysql-persistent-storage
mountPath: /var/lib/mysql
And the persistent volume path (Which I assume to be docker's Host system equivalent file path):
hostPath:
path: "/mnt/data"
My problem is : Nowhere on my laptop can I find either of these paths. /mnt/data does not exist from my laptop's root directly (where I would have expected it to be) , despite the PV still being active, and I see nowhere where the kubernetes cluster, node, or pod is mounted on my file system. WHERE on my laptop is this data being stored?? This isn't necessarily a practically useful thing to know, but it's critical to know in order to have a good grasp of understanding kubernetes and how it works, and I'm unwilling and unable to continue learning kubernetes until I can figure out where physically the data is stored on the host filesystem.
I've seen another question saying to "SSH into the Node that's running the PV Resource" , But I feel like that's referencing a distributed cloud system where the node exists on a separate server, and as stated I cannot find the mount path to my one master node running locally. Everything else seems to point to the not-useful official docs on PV and PVCs.
Can anyone explain to me where this mysql data should be?
Docker Desktop on a Mac runs a virtual machine to run docker inside. You're correct when you look at the hostPath.path
- that's where it's stored. But because docker/Kubernetes is inside the VM, that's where the path is relative to.
To see this yourself is a little tricky, Docker Desktop doesn't provide a guide on getting inside the VM. The community has some options though. An easy way would be docker run -it --rm --privileged --pid=host justincormack/nsenter1
. That command runs a container inside docker that gets you a shell on the VM containing the docker daemon.
As to where this is on your laptop, you can follow the docs about the disk image for the VM. Preferences > Resources > Advanced will show you where the disk image file is physically located on your laptop.