Following my previous question, I've set my Asp Net Core 3.1 app to only use HTTP2 protocol. Actually it solved my issue, at least locally.
But when I deploy the server app on Kubernetes, my client app (a net core 3.1 demo console app), throws an exception:
upstream connect error or disconnect/reset before headers. reset reason: connection termination
I did some research online and it seems to be related to the Kubernetes configuration. Since this is the first time I use Kubernetes, I don't exactly which part is wrong and why.
My deployment script is:
apiVersion: apps/v1
kind: Deployment
metadata:
name: ***-service-beta
namespace: ***-staging
spec:
selector:
matchLabels:
app: ***-beta
template:
metadata:
labels:
app: ***-service-beta
spec:
containers:
- name: ***-service-beta
image: __image_name__
imagePullPolicy: Always
ports:
- containerPort: 16050
resources:
limits:
cpu: 500m
memory: 2Gi
env:
- name: ***
value: ***
- name: ***
value: ***
---
apiVersion: v1
kind: Service
metadata:
namespace: ***-staging
name: ***-service-beta
spec:
selector:
app: ***-service-beta
ports:
- protocol: TCP
port: 16050
targetPort: 16050
---
apiVersion: networking.k8s.io/v1beta1
kind: Ingress
metadata:
namespace: ***-staging
name: ***-service-beta
annotations:
kubernetes.io/ingress.class: istio
spec:
rules:
- host: ***-service-beta.***.k8s.***.***
http:
paths:
- backend:
serviceName: ***-service-beta
servicePort: 16050
My client code. Not sure if I need to set the port?
static async Task Main(string[] args)
{
AppContext.SetSwitch("System.Net.Http.SocketsHttpHandler.Http2UnencryptedSupport", true);
using var channel = GrpcChannel.ForAddress("http://***-service-beta.***.k8s.***.***");
var client = new EventService.EventServiceClient(channel);
var reply1 = await client.GetTrackEventAsync(new GetTrackEventRequest { Name = "01Austra14" });
}
The server provides both REST and gRPC APIs on the same port. RESTful APIs are working.
I would be glad if anyone can help me