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

Shell into Windows containers #735

Open
dz-pyps opened this issue May 27, 2020 · 2 comments
Open

Shell into Windows containers #735

dz-pyps opened this issue May 27, 2020 · 2 comments
Labels
enhancement New feature or request

Comments

@dz-pyps
Copy link

dz-pyps commented May 27, 2020




Is your feature request related to a problem? Please describe.
At the moment, one can only shell into Linux containers using k9s. Since mixed Kubernetes clusters have gained some traction recently, I think it is a good idea to provide a shell into Windows containers as well.

Describe the solution you'd like
The easiest way would be to utilize kubectl exec which provides this functionality out of the box and doesn't require PowerShell installation locally.

Additional context
I do understand that even though it sounds simple, there are a lot of caveats we should consider.

@derailed derailed added bug Something isn't working enhancement New feature or request and removed bug Something isn't working labels May 28, 2020
@mikesmithgh
Copy link
Contributor

I ended up creating a workaround. If you add the following to ~/.k9s/plugin.yml then you can press w to shell into a windows container.

plugin:
  windows-shell:        
    shortCut: w
    description: "Shell (Windows)"
    scopes:
      - containers
    command: sh
    background: false
    confirm: false
    args:
      - -c
      - "kubectl exec -it -n $NAMESPACE $POD -- cmd.exe"

Only tested on WSL Ubuntu.

@jrobertson-insite
Copy link

jrobertson-insite commented Nov 19, 2020

I went down the plugin route as well but ran in to some weirdness with the plugin as posted by @mjsmith1028. I needed something like this that didn't use "sh", specified the context, and by default goes to powershell since that is in all of our Windows images. This is tested in Terminal in Windows (not in WSL) but would probably work there as well since it only relies on kubectl.

plugin:
  windows-powershell-pod:
    shortCut: w
    description: "Powershell (Windows)"
    scopes:
    - pods
    command: kubectl
    background: false
    confirm: false
    args:
    - exec
    - -it
    - --context
    - $CONTEXT
    - -n
    - $NAMESPACE
    - $NAME
    - --
    - powershell
  windows-powershell-container:
    shortCut: w
    description: "Powershell (Windows)"
    scopes:
    - containers
    command: kubectl
    background: false
    confirm: false
    args:
    - exec
    - -it
    - --context
    - $CONTEXT
    - -n
    - $NAMESPACE
    - $POD
    - --container
    - $NAME
    - --
    - powershell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants