I have a client and a service with gRPC. Locally they work well. I tried to start the server in openshift (minishift):
kind: DeploymentConfig
apiVersion: v1
metadata:
name: app-grpc
spec:
replicas: 1
selector:
app: app-grpc
template:
metadata:
labels:
app: app-grpc
spec:
containers:
- name: app-grpc
ports:
- containerPort: 9005
protocol: TCP
imagePullPolicy: Always
restartPolicy: Always
dnsPolicy: ClusterFirst
---
kind: Service
apiVersion: "v1"
metadata:
name: "app-grpc-service"
spec:
ports:
- port: 9005
targetPort: 9005
selector:
app: "app-grpc"
---
kind: Route
apiVersion: route.openshift.io/v1
metadata:
name: "app-grpc-route"
spec:
to:
kind: Service
name: app-grpc-service
But the call from the client does not reach the server. I am not sure if I have configured Service and Route correctly
The client looks like this:
ManagedChannel channel = NettyChannelBuilder
.forAddress("app-grpc-route-myproject.111.111.111.111.nip.io/app-grpc", 9005)
.usePlaintext()
.build();
try {
HelloServiceGrpc.HelloServiceBlockingStub client = HelloServiceGrpc.newBlockingStub(channel);
System.out.println(client.hello(HelloRequest.newBuilder()
.setFirstName("firstName")
.setLastName("lastName")
.build())
.getGreeting());
} catch (InterruptedException e) {
e.printStackTrace();
} finally {
channel.shutdown();
}
I'm not sure if I'm specifying host correctly. I copied it from route.
When trying to call
forAddress("app-grpc-route-myproject.111.111.111.111.nip.io", 9005)
I have Caused by: io.netty.channel.AbstractChannel$AnnotatedConnectException: Connection refused: no further information
If I use .forAddress("app-grpc-route-myproject.111.111.111.111.nip.io/app-grpc", 9005)
I have Caused by: io.netty.handler.codec.http2.Http2Exception: First received frame was not SETTINGS. Hex dump for first 5 bytes: 485454502f
To be able to serve gRPC connections, you need your ingress controller to handle HTTP2 connections.
This is not the case by default.
So, your answer might be to enter the following command: