<p>I have 2 pods: a server pod and a client pod (basically the client hits port 8090 to interact with the server). I have created a service (which in turn creates an endpoint) but the client pod cannot reach that endpoint and therefore it crashes:</p>

<blockquote>
  <p>Error :Error in client :rpc error: code = Unavailable desc = all SubConns are in TransientFailure, latest connection error: connection error: desc = "transport: Error while dialing dial tcp :8090: connect: connection refused")</p>
</blockquote>

<p>The client pod tries to access port 8090 in its host network. What I am hoping to do is that whenever the client hits 8090 through the service it connects to the server.</p>

<p>I just cannot understand how I would connect these 2 pods and therefore require help.</p>

<p>server pod:</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: server-pod
  labels:
    app: grpc-app
spec:
  containers:
  - name: server-pod
    image: image
    ports:
      - containerPort: 8090
</code></pre>

<p>client pod :</p>

<pre><code>apiVersion: v1
kind: Pod
metadata:
  name: client-pod
  labels:
    app: grpc-app
spec:
  hostNetwork: true
  containers:
  - name: client-pod
    image: image
</code></pre>

<p>Service:</p>

<pre><code>apiVersion: v1
kind: Service
metadata:
  name: server
  labels:
    app: grpc-app
spec:
  type: ClusterIP
  ports:
  - port: 8090
    targetPort: 8090
    protocol: TCP
  selector:
    app: grpc-app
</code></pre>

<p>Your service is selecting both the client and the server. You should change the labels so that the server should have something like app: grpc-server and the client should have app: grpc-client. The service selector should be app: grpc-server to expose the server pod. Then in your client app, connect to server:8090. You should remove hostNetwork: true.</p>
