How to connect to the kubernetes pod from the remote machine?

7/11/2020

I have Kubernetes cluster in DigitalOcean and there is a pod with gRPC server inside. I have gGRP client on my local machine. My client is written in go.

The goal is to connect gRPC client from my local machine to gRPC server inside DO k8s cluster.

I read this guide: https://kubernetes.io/docs/tasks/administer-cluster/access-cluster-services/ and tried to connect with this type of uri: http://kubernetes_master_address/api/v1/namespaces/namespace_name/services/[https:]service_name[:port_name]/proxy

Here is a part of my client code:

conn, err := grpc.Dial(addr, grpc.WithInsecure())
if err != nil {
	glog.Fatalln("grpc.Dial()", err.Error())
}

But I got always get an error like this: transport: Error while dialing dial tcp: address ...

-- Klimbo
go
grpc
kubernetes

1 Answer

7/11/2020

It’s probably better to first test if the port is reachable from the outside, e.g. by doing telnet <uri> <port>. When you can connect to the host and port you can look further at whether you can connect via the grpc client.

-- ggerritsen
Source: StackOverflow