2

I am using MobaXterm_21.2 installed version. When I run kubectl version, it's working as expected:

 kubectl version
Client Version: version.Info{Major:"1", Minor:"14", GitVersion:"v1.14.3", GitCommit:"5e53fd6bc17c0dec8434817e69b04a25d8ae0ff0", GitTreeState:"clean", BuildDate:"2019-06-06T01:44:30Z", G
oVersion:"go1.12.5", Compiler:"gc", Platform:"windows/amd64"}
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.  

But it is not able to read the .kube/config file or able to pickup the config file given through ENV variable KUBECONFIG or --kubeconfig. See the response below:

  export KUBECONFIG=/drives/path/to/config/file.config
                                                                                                                                                                                        ✔

  kubectl config view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

                                                                                                                                                                                    

Not working either:

 kubectl config --kubeconfig=/drives/path/to/config/file.config  view
apiVersion: v1
clusters: []
contexts: []
current-context: ""
kind: Config
preferences: {}
users: []

This is a kind of blocking issues for me. Can anyone guide me on how to make kubectl work in mobaxterm? Any help will be highly appreciated.

Edit - like @mikolaj-s pointed. From powershel/cmd/gitbash, I am able to access the k8s cluster with out any problem. I have been accessing the cluster using powershell for several months now and it reads the .kube/config file or KUBECONFIG env var as expected.
I want to shift to mobaxterm for it's multi-tab feature. If there is another tool that provides multi-tab feature I might be ok with it too.

In Mobaxterm -

 kubectl cluster-info dump 
Unable to connect to the server: dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.

 kubectl config get-contexts --kubeconfig /path/to/config/file
CURRENT   NAME   CLUSTER   AUTHINFO   NAMESPACE

The kubeconfig files i am using are tested and have no issues for sure(100%) as they are working from powershell.

Edit 2 - Many thanks for @mikolaj-s.
With lot of hope I tried using powershell in mobaxterm as suggest by mikolaj - mobaxterm-windows-command-prompt and it worked.

Wytrzymały Wiktor
  • 11,492
  • 5
  • 29
  • 37
samshers
  • 1
  • 6
  • 37
  • 84
  • Try giving the path in double quotes. – confused genius Nov 15 '21 at 17:06
  • @confusedgenius, i tried it . But you might me saying any thing bit different. Can you put the code here . – samshers Nov 16 '21 at 07:03
  • @confusedgenius - further, in the first case it should pick the .kube/config file.. but its failing to do even that. – samshers Nov 16 '21 at 07:04
  • How did you install Kubernetes? Did you try running these commands in PowerShell? Could you check solutions from similar issues - [this](https://stackoverflow.com/questions/50490808/unable-to-connect-to-the-server-dial-tcp-18080-connectex-no-connection-c) and from [this](https://stackoverflow.com/questions/59860987/kubectl-config-view-gives-empty-results)? – Mikolaj S. Nov 16 '21 at 10:46
  • @MikolajS. - am using powershell and it work will. Please see my edit. – samshers Nov 16 '21 at 12:05
  • You can use any Windows shell in the Mobaxterm (Cmd, Powershell etc.) - check [this](https://codetryout.com/mobaxterm-windows-command-prompt/) and [this](https://superuser.com/questions/1418606/how-to-get-an-elevated-powershell-in-mobaxterm). Is it OK for you? – Mikolaj S. Nov 16 '21 at 12:25
  • 1
    @MikolajS. - please see edit-2. Would you mind posting it as answer so i can accept. – samshers Nov 16 '21 at 18:41

1 Answers1

2

The solution is to use PowerShell directly in the MobaXterm - steps how to configure that can be found here (instead of CMD choose Powershell):

MobaXterm comes with various client tools such as SSH, telnet, WSL, CMD, and so on. It can well handle a Windows command line as well, here is how,

How to open Windows command prompt using MobaXterm?

  • Open your MobaXterm
  • From the top menu, click on Sessions
  • From the Session settings window, click on the Shell button
  • Under the Basic Shell settings tab, select Terminal shell CMD
  • Also select a startup directory of your choice, which the CMD prompt will start it as you startup folder.
  • Now, Click the OK button to open a windows command window!

With this, you should be able to use multiple Windows command lines in a tabbed view, or along with your other sessions.

Mikolaj S.
  • 2,850
  • 1
  • 5
  • 17