In my current project, I’m developing directly within Kubernetes in an effort to stay as close as possible to the production environment. Of course the similarity has its limits. For instance, the front-end application is based on Angular and is built using the NG CLI. When the app runs in production mode, then only the production build output remains, hosted inside of an NGINX pod. During development though, the Angular CLI is used (i.e., ng serve) so that the app can be rebuilt each time any part of the project changes. As I iterate on the code base within
VS Code, I need it to be synchronized within the pod so that the NG CLI process in the pod can detect the changes and rebuild the app. I use
Minikube to run the Kubernetes cluster. One solution to synchronize files from the local host machine towards the K8S cluster is to use a
hostPath volume, but I’ve experience huge performance issues when doing that. Also, I had to enable polling with the Angular CLI for it to detect the file changes, leading to really high CPU usage. Currently, my alternative is to use the “sync” functionality of the
DevSpace CLI client:
https://devspace.cloud/docs/cli/development/configuration/file-synchronization Using a simple YAML template, I could define multiple synchronization jobs targeting specific pods (selected using labels, as always with K8S). DevSpace sync works like a charm and is really efficient (it uses an rsync-like approach) You can learn more about it through its official docs and also this nice blog article:
https://medium.com/@lukas.gentele/devspace-sync-kubectl-cp-on-steroids-51207bdf5a3e Last but not least, the developers behind the DevSpace CLI are really reactive and helpful. I’ve reported two issues, which were both fixed within days and released, so congrats and thanks to them! :)
Comments ()