I have an API running in a Kubernetes container that writes data to a file. The file path is set to "/home/dataset.arff" inside the container the file gets created successfully but it get deleted when the container is deleted. I need to make this file permanat because I have another API using . Is there a way to achieve this ? (Im using docker desktop to enable k8s)
Asked
Active
Viewed 23 times
-1
-
Trying to share data in files can be troublesome, especially in a cluster environment like Kubernetes. Can you provide the data via some other path, like an HTTP API? – David Maze Jul 10 '23 at 00:37
2 Answers
0
You have to use Persistent Volumes (PVs) and Persistent Volume Claims (PVCs) Maybe search on web how to setup this.

MAvim
- 55
- 5
0
You should look into persistent volumes, which seems to be what you are looking for.
If you cannot implement something like this, kubectl enables copying from a pod to host: https://stackoverflow.com/a/55673655/21164658 This could be somewhat automated using shell scripts.

CloudWatcher
- 181
- 1
- 11
-
I read about PV but what I understand is that the file gonna be permanat in my host machine directory wich is windows in my case am I correct ? if yes does the other API will still be able to use that file ? – trey Jul 09 '23 at 14:12
-
You can konfigure PVs in a way that multiple pods can access it, yes. What you need to do precisely depends on your specific usecase. – CloudWatcher Jul 09 '23 at 14:18