I'm new to Kubernetes and wondering about the possibility of using persistent storage for containers. In my experience with Podman, the data inside the container remains persistent across stops and restarts until the container is deleted. I'm currently building a small application that allows users to create packages, similar to what Gitpod offers. I believe Kubernetes is the right tool for achieving high availability and distribution across worker machines, but I can't find a way to maintain a user's environment persistently.
Here's my current workflow using Podman: 1. Users log into the container via SSH. 2. They install dependencies through a package manager. 3. They build their projects and extract binaries.
Is there a way to replicate this persistent storage capability in Kubernetes, especially for the second step where the dependencies are installed? Could it be an anti-pattern to try and achieve this persistence within Kubernetes?
5 Answers
Yes, you can definitely achieve persistent storage in Kubernetes! It's not an anti-pattern—many tools like Loki and Prometheus use it for their operations. However, your current method sounds like a manual build process. Instead of SSHing into a container, consider using Argo Workflows to automate your builds. This will allow you to trigger builds more efficiently through the command line or UI without needing to log in manually.
You could look at using StatefulSets in conjunction with Persistent Volume Claims (PVCs). This setup ensures that your data is retained as the same disk gets remounted by default. Still, it's worth noting that in a transient compute environment, this can be seen as an anti-pattern. Ideally, the whole build process should be automated so that containers can run autonomously and clean up afterward.
In Kubernetes, the concept of persistent storage exists but requires you to approach it differently. You need to mount persistent volumes instead of relying on traditional container storage, which is ephemeral. Use PVCs to request the storage you need, and this will help maintain user data through pod restarts. However, I've seen instances where managing PVCs leads to bottlenecks, so have a plan for cleanup and automation.
If what you're looking for is straightforward, mounting a hostPath volume might be the easiest solution if you're just running on a single node. This way, you can directly utilize a directory on the host for storage without the complexity of PVCs. But remember, this method lacks the portability that Kubernetes is known for.
Absolutely, persistent volumes are your answer. They give you long-term storage that outlives pods. Just be cautious with the lifecycle management as Kubernetes can recycle everything if not configured carefully. Stick to using databases or external storage solutions for dependencies—it's generally less hassle in the Kubernetes world.

Related Questions
Can't Load PhpMyadmin On After Server Update
Redirect www to non-www in Apache Conf
How To Check If Your SSL Cert Is SHA 1
Windows TrackPad Gestures