k8s through docker windows
That is almost certainly the cause of your trouble, as Windows and its filesystems are not in the same mental model as the traditionally Linux-y docker world. Thus, it is extremely unlikely that those directories are owned by the correct Linux user-id, and even less likely that they are the correct "permission bits" (rwx) for whatever mongodb is expecting.
There are a couple of ways of testing this theory:
- If your docker-for-windows is actually running in a Linux virtual machine (as would be the case for docker-machine backed by VirtualBox, VMware, etc), then you can change the
volume: for the Pod to be emptyDir: {} or hostPath: since those directories will actually reside on the Linux virtual machine. I think that may be true for a Hyper-V backed docker-machine VM, too, but I don't have as much experience with them
- If you are using an actual
dockerd built as a Win32/Win64 application (unlikely, but I guess possible), then you can try switching to NFS (assuming mongodb doesn't whine) since AFAIK one has more influence over the UID and permission-bit mapping when mounting NFS folders
If you experience that with emptyDir: or hostPath: the application boots up, then you now have the challenge of finding some storage mechanism that uses a Linux-friendly filesystem and using it on Windows. Again, in the circumstance where you have a virtual machine, there's a pretty good chance you can attach virtual disks to the machine, format them with a Linux filesystem, and be back in business. The same is mostly true for network-backed filesystems, modulo one would want to be cautious about network-backed filesystems and database-y things like mongodb -- especially mongodb.
If I might offer an opinion, separate from what I hope is some constructive debugging tips: you are just asking for a world of pain trying to do that stuff on Windows. It hasn't had nearly the amount of hours spent exercising those circumstances, and nor does it have nearly the ecosystem for finding solutions. Merely for your consideration.