This example demonstrates the deployment of a gRPC service on Scaleway Serverless Containers.
For this example, we will use the CLI to deploy the container, but you can use other methods. You can also use the CLI directly from Scaleway console without having to use your credentials.
Here are the different steps we are going to proceed:
- Quick set-up of Container Registry to host our gRPC container
- Deploy the Serverless Container
- Run gRPC test command ot ensure everything is ok
To complete the actions presented below, you must have:
- installed and configured the Scaleway CLI
- installed Docker to build the image
- installed the common gRPC stack) to test locally (optional)
-
Run the following command in a terminal to create Container Registry namespace to store the image:
scw registry namespace create name=hello-grpc
The registry namespace information displays.
-
Copy the namespace endpoint (in this case,
rg.fr-par.scw.cloud/hello-grpc
). -
Log into the Container Registry namespace you created using Docker:
docker login rg.fr-par.scw.cloud/hello-grpc -u nologin --password-stdin <<< "$SCW_SECRET_KEY"
At this point, you have correctly set up Docker to be able to push your image online.
-
In a terminal, access this directory (containing the Dockerfile), and run the following command to build the image:
docker build -t grpc:latest .
-
Tag and push the image to the registry namespace:
docker tag grpc:latest rg.fr-par.scw.cloud/hello-grpc/grpc:latest docker push rg.fr-par.scw.cloud/hello-grpc/grpc:latest
In a terminal, run the following command to create a Serverless Containers namespace:
```bash
scw container namespace create name=grpc-test
```
The namespace information displays.
-
Copy the namespace ID.
-
Run the following command to create and deploy the container (make sure to use the
h2c
protocol to connect via HTTP2):scw container container create namespace-id=<PREVIOUS_NAMESPACE_ID> protocol=h2c name=grpc-test registry-image=rg.fr-par.scw.cloud/hello-grpc/grpc:latest
The container information displays.
-
Copy the DomainName (endpoint) to test your container.
Make sure your container is in a ready
status before testing it.
-
In the
client/client.go
file, replace the constantcontainerEndpoint
with theDomainName
copied previously. -
Make sure to keep the
:80
port at the end even if you container port is set to 8080, as these are two different settings. -
Run the command below to check if your container responds:
`go run client/client.go'