Typically, if I have a remote server, I could access it using ssh, and VS Code gives a beautiful extension for editing and debugging codes for the remote server. But when I create pods in Kuberneters, I can't really ssh into the container and so I cannot edit the code inside the pod or machine. And the kuberneters plugin in VSCode does not really help because the plugin is used to deploy the code. So, I was wondering whether there is a way edit codes inside a pod using VSCode.
P.S. Alternatively if there is a way to ssh into a pod in a kuberneters, that will do too.
There are two ways to edit a file in an existing pod: either by using kubectl exec and console commands to edit the file in place, or kubectl cp to copy an already edited file into the pod.
Edit a PODRun the kubectl edit pod <pod name> command. This will open the pod specification in an editor (vi editor). Then edit the required properties. When you try to save it, you will be denied.
Create and config a Kubernetes cluster You can create a Kubernetes cluster running on Azure using the Kubernetes extension in VS Code. Once you have installed the Kubernetes extension, you will see KUBERNETES in the Explorer. Click on More and choose Create Cluster.
If your requirement is "kubectl edit xxx" to use VSCode.
The solution is:
For Linux: export EDITOR='code --wait'
For Windows: set EDITOR=code --wait
For macOS: export EDITOR='open -a "Visual Studio Code" --wait'
Kubernetes + Remote Development extensions now allow:
must have:
required vscode extentions:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With