vscode-remote-release icon indicating copy to clipboard operation
vscode-remote-release copied to clipboard

Kubernetes with Remote-SSH

Open chrmarti opened this issue 3 years ago • 11 comments

@chrmarti Haha good point, of course, it is installed. In fact, what you are looking at is not my local vscode at all, it is a remote instance SSH running on a VPS. My local computer is not used for running code or connecting to the cluster at any point.

Originally posted by @markomitranic in https://github.com/microsoft/vscode-remote-release/issues/12#issuecomment-992599767

chrmarti avatar Dec 14 '21 08:12 chrmarti

This needs https://github.com/microsoft/vscode-remote-release/issues/4405 for passing the selection from the Kubernetes extension and changes in Remote-Containers to pass the SSH connection string along.

chrmarti avatar Dec 14 '21 08:12 chrmarti

Can you please explain more about the feature?

gaocegege avatar Dec 14 '21 08:12 gaocegege

I can't explain more about the feature, I'm not very proficient in VSCode extension development. However here is a rundown of my setups and the steps I've taken.

Replication steps:

  1. Local runs VSCode
  2. Using Remote-SSH extension I attach to a VPS
  3. The VPS has (or has access to) a k8s cluster
  4. In the Kubernetes Explorer i right click on a running pod
  5. The context menu appears, but there is no Attach Visual Studio Code item.
145788212-f728e101-dbd8-4dfd-86cf-5d14cf8f9f66

Expected behaviour:

As seen in the docs, that show it under Pods: https://code.visualstudio.com/docs/remote/attach-container#_attach-to-a-container-in-a-kubernetes-cluster

markomitranic avatar Dec 14 '21 10:12 markomitranic

Thanks!

gaocegege avatar Dec 14 '21 10:12 gaocegege

I have the same issue, my original report is here https://github.com/vscode-kubernetes-tools/vscode-kubernetes-tools/issues/1021 but the author says that the problem seems lay in Remote SSH extension.

MurzNN avatar Aug 25 '22 06:08 MurzNN

Same issue.

inliquid avatar May 12 '23 21:05 inliquid

same issue.

thanhtam98 avatar Jan 10 '24 07:01 thanhtam98

Looks like this is an issue with shelling out to kubectl without passing the correct kubeconfig or cluster to use. The error message I get is:

Error running command remote-containers.attachToK8sContainerFromViewlet:
Command failed: kubectl get pod my-pod-dmxnf -o json --namespace default.
This is likely caused by the extension that contributes remote-containers.attachToK8sContainerFromViewlet.

I was able to solve this by replacing ∼/.kube/config (the default config kubectl uses when not specifying uses I guess) with the kubeconfig of cluster containing the pod I wanted to attach to.

iceychris avatar Feb 02 '24 09:02 iceychris

@iceychris you are able to solve the problem @MurzNN is having?

On my machine, I have the same issue as both @MurzNN @markomitranic . We can communicate with the cluster (via remote-ssh instance) , this (may) involve setting the config like below, but the option "attach visual studio code" is unavailable.

if I understand, your solution is to add the path of the kubeconfig file (from your remote server) to the settings.json like below. This just allows VSCode to the access the right configs

  "vs-kubernetes.kubeconfig": "/path_to_/.kube/config",
       "vs-kubernetes.knownKubeconfigs": [
           "/path_to_/.kube/config"
       ],

gitreset-hard avatar Feb 08 '24 23:02 gitreset-hard

@iceychris you are able to solve the problem @MurzNN is having?

On my machine, I have the same issue as both @MurzNN @markomitranic . We can communicate with the cluster (via remote-ssh instance) , this (may) involve setting the config like below, but the option "attach visual studio code" is unavailable.

if I understand, your solution is to add the path of the kubeconfig file (from your remote server) to the settings.json like below. This just allows VSCode to the access the right configs

  "vs-kubernetes.kubeconfig": "/path_to_/.kube/config",
       "vs-kubernetes.knownKubeconfigs": [
           "/path_to_/.kube/config"
       ],

doesn't seem to fix anything by adding that to the settings.json

ottoyiu avatar Jun 26 '24 23:06 ottoyiu