How to edit a file in a running pod?
Venryx opened this issue · comments
I am able to view the file-tree of running pods, and view the file contents, but how can I edit those files?
Nevermind, I figured it out:
- Right-click the remote file you want to edit, press "kubectl copy from", and save it somewhere on your local computer. (alternatively, you can right-click and press "View file", then copy-paste it into a local file)
- Edit that local copy of the file.
- Right click the folder parent of the original remote file, press "kubectl copy to from file", and select your edited local copy of the file.
However, there were three snags I hit with the above:
- The "kubectl copy from" command did not work for me at first, because the terminal I had open was already running a task; there should be a warning message that for the "kubectl" commands to work, the currently open terminal tab must be non-busy/accepting-commands.
- The "kubectl copy from" command failed even after opening a fresh terminal tab; this is because the
cd \D [...]
command it uses only works for CMD, not Powershell (the default, for me at least). In Powershell, the\D
argument apparently needs to be removed. - The "kubectl" commands failed for me even after the above, because the path it was copying to had spaces in it; when I manually reran the command with quotes added around the path, it succeeded.
Would you be open to pull-requests to fix these issues?
This feature would be a very useful addition to this extension.
I've made a PR for exactly your requirements, hope it may gets merged :-)
Unfortunately the PR was rejected without a reason, so I decided to fork it and created an own extension with editing functionality. It now also includes favorite files for quicker access (in beta):
https://marketplace.visualstudio.com/items?itemName=tsimones.kubernetes-file-system-explorer-editor