Kong grpc-gateway: Bad Gateway

78 views Asked by At

I would like to implement GRPC-Gateway to Kong so that I can make HTTP request to Kong whereas my microservices communicate with GRPC.

Expected: I should receive a response from my basic-stream-service microservice when I make an HTTP call to Kong gateway.

curl -i http://basic-stream-service-http.local:30783/

However when I make this request, I don't receive any response as the request hang-out:

HTTP/1.1 502 Bad Gateway
Date: Sun, 15 Oct 2023 12:44:29 GMT
Content-Type: application/json
Connection: keep-alive
Access-Control-Allow-Origin: *
Content-Length: 75
X-Kong-Upstream-Latency: 2
X-Kong-Proxy-Latency: 1
Via: kong/3.4.2

... // infinite "loading"

And my Kong Gateway show me this error:

2023/10/15 13:02:46 [error] 1262#0: *4918 upstream sent no valid HTTP/1.0 header while reading response header from upstream, client: 10.244.0.1, server: kong, request: "GET / HTTP/1.1", upstream: "http://10.244.0.9:3000/", host: "basic-stream-service-http.local:30783"

What I already do/have:

  • I can grpcurl successfully of my basic-stream-service
  • I have my proto files in Kong proxy
  • I deployed Kong with helm chart kong/ingress
  • my microservice listen to 0.0.0.0:3000

I think there is an error in my ingress config file but I have no idea where.

Here is my ingress config:

---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: basic-stream-service-http
  namespace: basic-stream-service
  annotations:
    konghq.com/protocols: http
    konghq.com/plugins: my-grpc-gateway
spec:
  ingressClassName: kong
  rules:
    - host: basic-stream-service-http.local
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: basic-stream-service
                port:
                  number: 80
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: basic-stream-service-grpc
  namespace: basic-stream-service
  annotations:
    konghq.com/protocols: grpc,grpcs
spec:
  ingressClassName: kong
  rules:
    - host: basic-stream-service-grpc.local
      http:
        paths:
          - path: /
            pathType: ImplementationSpecific
            backend:
              service:
                name: basic-stream-service
                port:
                  number: 80
---
apiVersion: configuration.konghq.com/v1
kind: KongPlugin
metadata:
  name: my-grpc-gateway
  namespace: basic-stream-service
plugin: grpc-gateway
config:
  proto: /mnt/protobufs/basicstream/v1/app.proto

Here is my service:

apiVersion: v1
kind: Service
metadata:
  name: basic-stream-service
  namespace: basic-stream-service
  annotations:
    konghq.com/protocol: grpc,grpcs
spec:
  ports:
    - name: grpc
      port: 80
      targetPort: 3000
  selector:
    app.name: basic-stream-service
  type: ClusterIP

I omit the deployment config as it is useless to show it.

EDIT SOLUTION:

I have no idea why but I removed the grpcs annotation in the service:

konghq.com/protocol: grpc
0

There are 0 answers