How to connect from local kubectl to a remote kubernetes cluster?

1/2/2016

I have provisioned kubernetes cluster in Azure Cloud(using CoreOS) using the guide http://kubernetes.io/v1.1/docs/getting-started-guides/coreos/azure/README.html

Its working fine, now I want to run kubectl commands from my local machine(I use Mac). for that I installed kubernetes-cli with brew, but I am not able to connect to the remote kubernetes cluster. When I run "kubectl version",

user$  kubectl version 
Client Version: version.Info{Major:"1", Minor:"1",GitVersion:"v1.1.2+3085895",GitCommit:"3085895b8a70a3d985e9320a098e74f545546171",GitTreeState:"not a git tree"} 
error: couldn't read version from server: Get http://localhost:8080/api: dial tcp [::1]:8080: getsockopt: connection refused

how to connect to the kubernetes cluster via SSH or so?

Note: manually I am able to ssh to the kubernetes nodes and run kubectl commands there.

-- Ameen Rashad
coreos
kubernetes

1 Answer

1/2/2016

The mechanism for copying the configuration file necessary to get remote access to your cluster is described in Sharing Cluster Access. You may need to manually tweak ~/.kube/config after copying if it contains an endpoint that isn't remotely reachable (a non-routable IP) and/or open up firewall access to your apiserver running in Azure. Otherwise, once you get the local config file in place you should be all set.

-- Robert Bailey
Source: StackOverflow