How to develop code inside a running pod without redeploying an image?
My problem is, that once I want to try a code change, I always need to build a new image, push it to a registry, patch a Kubernetes Operator CRD, let it redeploy, let it reconcile, wait for the new pod to startup and see if the change worked once traffic is routed to the new instance. That's quite time consuming.
I want something that has mount drive like docker desktop, every .net solution build package or publish artifacts should checked for changed file and push to the target AKS POD namespace hosted website.
Developing code inside a running pod without redeploying the entire image can indeed be time-consuming and cumbersome, especially in restricted environments. Fortunately, there are some tools and techniques that can help streamline this process. Let’s explore a few options:
Skaffold:
Skaffold is a popular tool for local development with Kubernetes. It automates the build, push, and deployment process, allowing you to iterate quickly.
You can set up Skaffold to watch your local code and automatically rebuild and redeploy your application whenever changes are detected.
Skaffold works well with Kubernetes clusters, including OpenShift1.
Telepresence:
Telepresence allows you to “teleport” your development machine into the Kubernetes cluster. It creates a proxy pod that forwards traffic between your local environment and the cluster.
With Telepresence, you can develop locally while interacting with services running inside the cluster. It provides a seamless experience for debugging and testing.
DevSpace:
DevSpace is another tool that simplifies local development with Kubernetes.
It allows you to sync files between your local machine and a running pod. You can edit code locally, and DevSpace will automatically update the pod with your changes.
DevSpace integrates well with Visual Studio Code (VSCode) and other IDEs1.
Code-Server:
If you prefer to use VSCode for development, consider using Code-Server. It’s a web-based version of VSCode that you can run inside a pod.
Code-Server allows you to edit code directly within the pod, eliminating the need for frequent image rebuilds and deployments.
Pair it with tools like Skaffold or DevSpace for an efficient development workflow1.
Remember that each tool has its own trade-offs, and the best choice depends on your specific requirements and constraints. Experiment with a few options to find the one that fits your workflow best. Happy coding! 😊
If you want to know how exactly it happens, please refer to this fragment of the official Kubernetes documentation on postStart handlers.
No comments :
Post a Comment