Skip to content

Conversation

cooper-grc
Copy link
Contributor

@cooper-grc cooper-grc commented Aug 20, 2025

Summary by cubic

Expose Pod, Image, and Gateway gRPC services over HTTP using grpc-gateway, mounted at /api/v1/grpc-gateway. This lets clients call JSON endpoints without a gRPC client.

  • New Features

    • Added grpc-gateway mux and server wiring (initGrpcGateway) and mounted at /api/v1/grpc-gateway/*.
    • Registered PodService, ImageService, and GatewayService handlers against the gRPC port.
    • Authorization header is forwarded to gRPC metadata; gRPC interceptors handle auth.
    • Updated gen_proto.sh to generate grpc-gateway code for pod/image/gateway with generate_unbound_methods=true.
    • Added generated reverse-proxy files: proto/pod.pb.gw.go, proto/image.pb.gw.go, proto/gateway.pb.gw.go.
  • Dependencies

    • Added protoc-gen-grpc-gateway@v2.27.1 to bin/setup.sh.
    • Promoted github.com/grpc-ecosystem/grpc-gateway/v2 v2.25.0 to a direct dependency.

@cooper-grc cooper-grc changed the title Cg/grpc gateway GRPC -> Http Aug 21, 2025
@cooper-grc cooper-grc changed the title GRPC -> Http Expose Pod, Image, and Gateway over HTTP using GRPC-Gateway Aug 25, 2025
@cooper-grc cooper-grc marked this pull request as ready for review August 25, 2025 19:38
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

6 issues found across 17 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@cooper-grc
Copy link
Contributor Author

@cubic-dev-ai re-run

Copy link
Contributor

cubic-dev-ai bot commented Aug 25, 2025

@cubic-dev-ai re-run

@cooper-grc I've started the AI code review. It'll take a few minutes to complete.

Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 17 files

React with 👍 or 👎 to teach cubic. You can also tag @cubic-dev-ai to give feedback, ask questions, or re-run the review.

@@ -503,6 +529,11 @@ func (g *Gateway) Start() error {
log.Fatal().Err(err).Msg("failed to initialize http server")
}

err = g.initGrpcGateway(fmt.Sprintf(":%d", g.Config.GatewayService.GRPC.Port))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Endpoint passed to initGrpcGateway lacks a host; use "localhost:%d" (or configured host) instead of just ":%d" to avoid dial errors.

Prompt for AI agents
Address the following comment on pkg/gateway/gateway.go at line 532:

<comment>Endpoint passed to initGrpcGateway lacks a host; use &quot;localhost:%d&quot; (or configured host) instead of just &quot;:%d&quot; to avoid dial errors.</comment>

<file context>
@@ -503,6 +529,11 @@ func (g *Gateway) Start() error {
 		log.Fatal().Err(err).Msg(&quot;failed to initialize http server&quot;)
 	}
 
+	err = g.initGrpcGateway(fmt.Sprintf(&quot;:%d&quot;, g.Config.GatewayService.GRPC.Port))
+	if err != nil {
+		log.Fatal().Err(err).Msg(&quot;failed to initialize grpc gateway&quot;)
</file context>
Suggested change
err = g.initGrpcGateway(fmt.Sprintf(":%d", g.Config.GatewayService.GRPC.Port))
err = g.initGrpcGateway(fmt.Sprintf("localhost:%d", g.Config.GatewayService.GRPC.Port))

@cooper-grc cooper-grc requested a review from jsun-m August 27, 2025 17:09
// No need to add auth middleware: grpc-gateway maps the 'Authorization' header
// to gRPC metadata, and the destination gRPC server's interceptor will handle
// authorization for every request.
g.baseRouteGroup.Any("/grpc-gateway/*", echo.WrapHandler(http.StripPrefix(apiv1.HttpServerBaseRoute+"/grpc-gateway", mux)))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure if I like the naming. This is more like an /api/v2 path instead of calling it /api/v1/grpc-gateway. People using this endpoint shouldn't need to associated it with an http gateway in front of GRPC. @luke-beamcloud

Also is this some form of behavior that will allow us to add additional endpoints to the grpc->http generated route groups?
If so, then we can actually call this /api/v2 and either build out all functionality to grpc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants