Deploy a Go gRPC server and gateway on Koyeb
Learn more about Koyeb
·
Explore the documentation
·
Discover our tutorials
Koyeb is a developer-friendly serverless platform to deploy apps globally. No-ops, servers, or infrastructure management. This repository contains two companion applications: A gRPC API application and a gateway that can be used to accept and translate HTTP requests.
This example application is designed to show how you can create a gRPC API and make it accessible to web clients by deploying it on Koyeb. You can find out more about these two applications in the associated tutorial.
Follow the steps below to deploy and run the gRCP API server (orders-service
) and the HTTP gateway (gateway-service
) applications on your Koyeb account.
You need a Koyeb account to successfully deploy and run this application. If you don't already have an account, you can sign-up for free here.
The fastest way to deploy the two applications is to click the Deploy to Koyeb buttons below.
First, deploy the gRPC API service with the following button:
Afterwards, deploy the HTTP gateway service with this button:
The required environment variable for the HTTP gateway application is:
ORDER_SERVICE_ADDRESS
: The internal service address where theorders-service
application is deployed. If using the deploy button above, this will be:https://orders-service.orders-service.koyeb:50051
. Be sure to modify it if you deployed with a different app or service name.
Clicking on these buttons brings you to the Koyeb App creation page with everything pre-set to launch the applications. Fill out the required information in the environment variables and then click Apply to launch the applications.
To modify this application example, you will need to fork this repository. Check out the fork and deploy instructions.
If you want to customize and enhance this application, you need to fork this repository.
If you used the Deploy to Koyeb button, you can simply link your service to your forked repository to be able to push changes. Alternatively, you can manually create the application as described below.
On the Koyeb Control Panel, on the Overview tab, click the Create Web Service button to begin.
For the orders-service
application:
- Select GitHub as the deployment method.
- Select your project from the GitHub repository list and choose the appropriate branch.
- In the Builder section, select Dockerfile. Click the override toggle associated with the Target option and enter
orders-service
in the field. - Expand the Exposed ports sections and set the port to 50051. De-select the Public option to mark the service as internal.
- Set the App and Service name to
orders-service
and click Deploy.
Next, deploy the gateway-service
application with the following steps:
- Select GitHub as the deployment method.
- Select your project from the GitHub repository list and choose the appropriate branch.
- In the Builder section, select Dockerfile. Click the override toggle associated with the Target option and enter
gateway-service
in the field. Click the override toggle associated with the Args option and set the value to["ORDER_SERVICE_ADDRESS"]
. - Expand Environment variable section and add a new environment variable called
ORDER_SERVICE_ADDRESS
with the private address where your order service can be reached. It should follow this format:<SERVICE_NAME>.<APP_NAME>.koyeb:50051
. If you followed the above steps, this should be:orders-service.orders-service.koyeb:50051
. - Expand the Exposed ports section and set the port to 8080.
- Set the App name to
gateway-service
. This determines where the application will be deployed to. For example,https://gateway-service-<YOUR_USERNAME>.koyeb.app
. - Click Deploy to begin the deployment process.
By visiting the URL for the HTTP gateway you should be able to access the API.
If you have any questions, ideas or suggestions regarding this application sample, feel free to open an issue or fork this repository and open a pull request.