Home > database >  mobaxterm is not able to read kube config setting when using with kubectl?
mobaxterm is not able to read kube config setting when using with kubectl?

Time:11-18

I am using MobaXterm_21.2 installed version. When i run - kubectl version, its woking 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 reade the .kube/config file or able to pickup the config file given through ENV variable KUBECONFIG or --kubeconfig. See bellow response

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

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

                                                                                                                                                                                    

And neither is below working -

 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.

CodePudding user response:

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.

  • Related