The typical guideline in container management is that containers should remain stateless, only using persistent volumes when persistence is necessary. While this approach works well for production environments, it becomes problematic in a development setting where pods function more like 'pets' than 'cattle.' In this context, developers often face issues such as:
1. **Code & Config:** Mounting a persistent volume to a directory like `/workspace` can save code effectively.
2. **System Dependencies:** However, if a developer installs a library or alters system configurations, those changes are made within the container's temporary filesystem, which disappears once the pod restarts due to eviction or resource management.
3. **Workflow Disruption:** Each time the pod restarts, any installed libraries or changed configurations are lost, necessitating constant reconstruction of the development environment.
Simply telling developers to update their Dockerfile isn't user-friendly—especially when small changes like installing a utility could interrupt their development flow. I'm wondering if Kubernetes inherently struggles with this stateful development pattern, or if there are current practices and tools available that would work around these limitations. I'm particularly curious about solutions that can save the entire state of a container, including filesystem changes. What are your thoughts on this?
3 Answers
GitHub Codespaces tackles this issue by using a system called 'devcontainers.' While it adds another layer to build, it’s specifically tailored for development. Plus, there are plenty of pre-made configurations for popular programming languages. You can run one-off commands that need to be executed after the container is created without the hassle of managing the full image build process. This seems like a solid way to streamline your dev workflow.
I actually don’t see a problem with this approach. If a dependency is required beyond a quick test, it’s best practice to document it in the Dockerfile rather than leaving it as undocumented in your cloud environment. If you’re unsure whether you need a package, you can always test it directly and then make adjustments as necessary. However, I’d be more worried about Kubernetes pod evictions disrupting development than the need for persistence.
Running web-based IDEs on Kubernetes, such as Code Server or VS Code, can work well if you set up persistent volumes for workspace data. It’s advisable to have essential system libraries baked directly into your container images, while keeping project-specific dependencies isolated. If you need to build or run your app from a web IDE, consider delegating the workload to Docker via dind or directly to your Kubernetes setup. Installing packages directly in the IDE can lead to issues, so try to manage your dependencies through a containerized approach, ensuring everything aligns with production environments.
Also, you can configure your IDE container to save any installations to directories backed by PVCs, which can then be included in your $PATH. Still, it’s crucial to shift your mindset about container states in dev environments.

It looks like Kubernetes isn’t actually being employed for scheduling these devcontainers, which might be revealing in terms of its limitations.