nkigen
nkigen

Reputation: 450

istio internal GRPC services communication

I am having trouble having two in-cluster GRPC services (written in netcore3.0) I get Grpc.Core.RpcException: Status(StatusCode=Unavailable, Detail="Connection reset by peer") (with uri = <service>.default.svc.cluster.local) or Grpc.Core.RpcException: Status(StatusCode=Unimplemented, Detail="") with uri = user.default.svc.cluster.local:80. The weird part is all the services work fine if they are communicating from different clusters. I'm I using the right urls. The configuration of one of the services in attached here.

apiVersion: v1
kind: Service
metadata:
  name: user
  labels:
    app: user
    service: user
spec:
  ports:
  - port: 80
    name: grpc-port
    protocol: TCP
  selector:
    app: user
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  name: user-v1
  labels:
    app: user
    version: v1
spec:
  replicas: 1
  template:
    metadata:
      labels:
        app: user
        version: v1
    spec:
      containers:
      - name: user
        image: ***
        imagePullPolicy: IfNotPresent
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: "***"
        ports:
        - containerPort: 80
---
apiVersion: networking.istio.io/v1alpha3
kind: VirtualService
metadata:
  name: user
spec:
  hosts:
  - user.default.svc.cluster.local
  http:
  - route:
    - destination:
        port:
          number: 80
        host: user.default.svc.cluster.local
        subset: v1
---
apiVersion: networking.istio.io/v1alpha3
kind: DestinationRule
metadata:
  name: user
spec:
  host: user.default.svc.cluster.local
  subsets:
  - name: v1
    labels:
      version: v1
---

FIXED: I managed to the it to work by using gRPC's .NETCORE3 client factory integration as described here

Upvotes: 0

Views: 728

Answers (1)

nkigen
nkigen

Reputation: 450

Instead of creating a channel and client manually as one would usually do. i.e

var endpoint = "test"; //or http://test
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
Channel channel = new Channel(endpoint, ChannelCredentials.Insecure);
client = new TestService.TestServiceClient(channel);

I used GRPC client factory integration (in ConfigureServices (startup.cs) like this (after adding Grpc.Net.ClientFactory package version 0.1.22-pre1:

services.AddGrpcClient<TestService.TestServiceClient>(o =>
        {
            AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
            o.BaseAddress = new Uri("http://test");
        });

Thereafter you can access the client by using Dependency Injection. I'm not sure why the second approach works but the first one doesn't.

Upvotes: 1

Related Questions