Unable to connect to the server: dial tcp i/o time out

前端 未结 10 1427
死守一世寂寞
死守一世寂寞 2021-02-06 21:52

When i run the kubectl version command , I get the following error message.

kubectl version
Client Version: version.Info{Major:\"1\", Minor:\"9\", GitVersion:\"v         


        
相关标签:
10条回答
  • 2021-02-06 22:24

    I got similar problem when I run

    $ kubectl version
    Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.11", GitCommit:"637c7e288581ee40ab4ca210618a89a555b6e7e9", GitTreeState:"clean", BuildDate:"2018-11-26T14:38:32Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"darwin/amd64"}
    Unable to connect to the server: dial tcp 192.168.99.100:8443: i/o timeout
    

    And here's how I tried and finally worked.

    I installed Docker Desktop on Mac (Version 2.0.0.3) firstly. Then I installed the kubectl with command

    $ brew install kubectl
    .....
    ==> Pouring kubernetes-cli-1.16.0.high_sierra.bottle.tar.gz
    Error: The `brew link` step did not complete successfully
    The formula built, but is not symlinked into /usr/local
    Could not symlink bin/kubectl
    Target /usr/local/bin/kubectl
    already exists. You may want to remove it:
      rm '/usr/local/bin/kubectl'
    
    To force the link and overwrite all conflicting files:
      brew link --overwrite kubernetes-cli
    
    To list all files that would be deleted:
      brew link --overwrite --dry-run kubernetes-cli
    
    Possible conflicting files are:
    /usr/local/bin/kubectl -> /Applications/Docker.app/Contents/Resources/bin/kubectl
    .....
    

    That doesn't matter, we have already got the kubectl. Then I install minikube with command

    $ brew cask install minikube
    ...
    ==> Linking Binary 'minikube-darwin-amd64' to '/usr/local/bin/minikube'.
                                                                        
    0 讨论(0)
  • 2021-02-06 22:25

    You can get relevant information about the client-server status by using the following command.

    kubectl config view 
    

    Now you can update or set k8s context accordingly with the following command.

    kubectl config use-context kubernetes
    

    you can do further action on kubeconfig file. the following command will provide you with all necessary information.

    kubectl config --help
    
    0 讨论(0)
  • 2021-02-06 22:27

    I was facing the same issue on Ubuntu 18.04.1 LTS.

    The solution provided here worked for me.

    Just putting the same data here:

    1. Get current cluster name and Zone:

      gcloud container clusters list

    2. Configure Kubernetes to use your current cluster:

      gcloud container clusters get-credentials [cluster name] --zone [zone]

    Hope it helps.

    0 讨论(0)
  • 2021-02-06 22:31

    I had the same issue when I tried use kubrnetes installed with Docker. It turned out that it was not enbled by default.

    First I enabled kubrnetes in Docker options and then I changed context for docker-for-desktop

    kubectl config get-contexts
    kubectl config use-context docker-for-desktop
    

    It solved the issue.

    0 讨论(0)
提交回复
热议问题