1

I downloaded Lens and imported my config file there and everything works great on Lens other than the fact that kubectl commands don't work through the terminal.

I was trying an exec command:

kubectl exec -i -t -n mynamespace mypod -c mycontainer -- sh -c "clear; (bash || ash || sh)"

And I got:

PS C:\Users\<user> kubectl exec -i -t -n mynamespace mypod -c mycontainer -- sh -c "clear; (bash || ash || sh)"
Access denied
line:1 char:1
+ kubectl exec -i -t -n mynamespace mypod -c...
+ ~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OperationStopped: (:) [], UnauthorizedAccessException
    + FullyQualifiedErrorId : System.UnauthorizedAccessException

When I try to run that command through a CMD prompt or PowerShell prompt it works fine.

Anyone's got an idea why am I getting Access denied?

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
teamdever
  • 309
  • 6
  • 21
  • K8s lens is specific Kubernetes IDE. Could you try to `turn off "Download kubectl binaries matching the kubernetes cluster version" and downloaded kubectl.exe manually from k8s website and give the path in PATH TO KUECTL BINARY section` It looks like this is known issue which was already rised on Github - [here](https://github.com/lensapp/lens/issues/3845#issuecomment-929060411). – PjoterS Feb 23 '22 at 08:10
  • Hey, sorry I haven't noticed your comment, I tried that and still got the same result. Thank you though. – teamdever Mar 27 '22 at 08:25

1 Answers1

0

As OP didn't respond to my comment I'm going to post this as Community Wiki for better visibility.

Lens is a special IDE for Kubernetes. Very similar issue was already posted in the Github thread - Error "Access denied" while using kubectl in lens' terminal.

There is no proper solution for this issue, however user sanarena posted a workaround which could help with this issue.

Turn off "Download kubectl binaries matching the kubernetes cluster version" and download kubectl.exe manually from k8s website and give the path in PATH TO KUBECTL BINARY section. it is now working fine

Full comment with more details can be found under this link.

PjoterS
  • 12,841
  • 1
  • 22
  • 54