Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kubernetes with Remote-SSH #6054

Closed
chrmarti opened this issue Dec 14, 2021 · 17 comments
Closed

Kubernetes with Remote-SSH #6054

chrmarti opened this issue Dec 14, 2021 · 17 comments
Assignees
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2 verification-needed Verification of issue is requested verified Verification succeeded

Comments

@chrmarti
Copy link
Contributor

@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 #12 (comment)

@chrmarti chrmarti self-assigned this Dec 14, 2021
@chrmarti chrmarti added the feature-request Request for new features or functionality label Dec 14, 2021
@chrmarti chrmarti added this to the Backlog milestone Dec 14, 2021
@chrmarti chrmarti added the containers Issue in vscode-remote containers label Dec 14, 2021
@chrmarti
Copy link
Contributor Author

This needs #4405 for passing the selection from the Kubernetes extension and changes in Remote-Containers to pass the SSH connection string along.

@gaocegege
Copy link

Can you please explain more about the feature?

@markomitranic
Copy link

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

@gaocegege
Copy link

Thanks!

@MurzNN
Copy link

MurzNN commented Aug 25, 2022

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

@inliquid
Copy link

Same issue.

@thanhtam98
Copy link

same issue.

@iceychris
Copy link

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.

@gitreset-hard
Copy link

@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"
       ],

@ottoyiu
Copy link

ottoyiu commented Jun 26, 2024

@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

@lupalby
Copy link

lupalby commented Aug 21, 2024

I am also affected by this unfortunately. Happy to test anything if a possible solution comes around.

@chrmarti chrmarti modified the milestones: Backlog, September 2024 Sep 6, 2024
@chrmarti chrmarti closed this as completed Sep 6, 2024
@felipecrs
Copy link

@chrmarti mind explaining the reason why this was closed?

@chrmarti
Copy link
Contributor Author

chrmarti commented Sep 6, 2024

This will be available in the next pre-release version of Dev Containers.

The workaround for the missing selection when invoking the action from the context menu in the Kubernetes view is to show the list of pods in a picker at the top of the window.

@felipecrs
Copy link

This is amazing, thanks a lot.

@chrmarti
Copy link
Contributor Author

Available in Dev Containers 0.386.0-pre-release. The context menu action is also available when connected to a remote host (it will show a picker due to limitations) and there is a new command F1 > Dev Containers: Attach to Kubernetes Container....

@lupalby
Copy link

lupalby commented Sep 13, 2024

I can confirm that it's working, thank you very much for fixing this! And now I don't even need the kubernetes extension anymore, the dev containers extension is enough. Awesome

@lupalby
Copy link

lupalby commented Sep 13, 2024

@chrmarti perhaps the official instructions should be updated here: https://code.visualstudio.com/docs/devcontainers/attach-container#_attach-to-a-container-in-a-kubernetes-cluster

chrmarti added a commit to microsoft/vscode-docs that referenced this issue Sep 17, 2024
@chrmarti chrmarti added verification-needed Verification of issue is requested verified Verification succeeded labels Sep 24, 2024
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Oct 21, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
containers Issue in vscode-remote containers feature-request Request for new features or functionality plan-review PM-highlighted item determined to be P1 or P2 verification-needed Verification of issue is requested verified Verification succeeded
Projects
None yet
Development

No branches or pull requests