Bhanu Prakash
Bhanu Prakash

Reputation: 1

How to Properly Run a gRPC Service in AKS? Getting HTTP/1.x Request Sent to HTTP/2 Only Endpoint Error

Can someone help me? How can I run a gRPC service in AKS? I am currently facing an issue with my gRPC service.

Below are the configuration details I am using:

dockerfile

# Use base image for running the application
FROM mcr.microsoft.com/dotnet/aspnet:8.0 AS base
WORKDIR /app
EXPOSE 80
EXPOSE 3042

# Use SDK image for building the application

FROM mcr.microsoft.com/dotnet/sdk:8.0 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src

# Copy the entire solution to the build context (important for 
dependencies)

COPY . .

# Restore dependencies

WORKDIR /src/src/Account/CC.Account.Queries.API
RUN dotnet restore "CC.Account.Queries.API.csproj"

# Build the application

RUN dotnet build "CC.Account.Queries.API.csproj" -c 
$BUILD_CONFIGURATION -o /app/build

# Publish the application

FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "CC.Account.Queries.API.csproj" -c 
$BUILD_CONFIGURATION -o /app/publish /p:UseAppHost=false

# Final image for running the application

FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .

# Start the application

ENTRYPOINT ["dotnet", "CC.Account.Queries.API.dll"\]

Deployment.yaml

apiVersion: apps/v1
kind: Deployment
metadata:
  name: accountqueries-api
  namespace: admin-backend
spec:
  replicas: 1
  selector:
    matchLabels:
       app: accountqueries-api
  template:
     metadata:
     labels:
        app: accountqueries-api
     spec:  
       containers:
        - name: accountqueries-api
          image: 824/accountqueriesapi:8 # Replace with your 
          actual image
           ports:
             - containerPort: 3042
             - containerPort: 80
           env:
             - name: ASPNETCORE_ENVIRONMENT
               value: "Development"
             - name: ASPNETCORE_URLS
               value: "http://+"

Service.yaml

apiVersion: v1
kind: Service
metadata:
  name: accountqueries-api
  namespace: admin-backend
spec:
  selector:
     app: accountqueries-api
  ports:
    - name: grpc
      protocol: TCP
      port: 3042
      targetPort: 3042
    - name: http
      protocol: TCP
      port: 80
      targetPort: 80
  type: ClusterIP  

Issue

When I forward the pod to localhost using kubectl port-forward, I see this response:

An HTTP/1.x request was sent to an HTTP/2 only endpoint.

This indicates that the request is being sent to the gRPC service using HTTP/1.1, whereas gRPC expects HTTP/2.

Additionally, when testing using Postman with the provided .proto file and authentication, I am not receiving any response.

What am I missing in my configuration? How can I properly expose and test my gRPC service in AKS?

Upvotes: 0

Views: 29

Answers (0)

Related Questions