Search code examples
dockergcloudkubectl

Kubectl can't connect on Windows 10


I have recently installed Docker and the gcloud SDK on a Windows 10 machine.

After running gcloud init and configuring my local setup, I ran gcloud components install kubectl.

Now when I run kubectl get pods I get the response

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

I then ran kubectl config view and got the following

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

I'm not sure how to fix this on Windows as I am normally a Mac user so this is all new to me.

How can my instance of kubectl connect?


Solution

  • Generally if you want to configure your kubectl to use your GKE cluster, you have to run below commands to copy k8s configuration to local.

    1.First list your cluster names (under NAME column) and recognize zone (under Location column)

    $ gcloud container clusters list
    

    2.Then run below command to copy k8s config to local

    $ gcloud container clusters get-credentials <cluster-name> --zone <zone>
    

    3.Then check config

    $ kubectl config view