Introduction
The networking entrypoint for a greymatter tenant project is called an edge node or application edge node. The greymatter init
command templates out manifests and configurations for the edge node; however, you may need to make changes.
This guide will walk you through connecting a service to an application edge node.
Prerequisites
- A greymatter
1.8.x
instance - A tenant project with at least one service
1. Add the edge
Block
The gsl #Service
definition contains an edge
object that configures the connection between the service and some edge. Embedding this route configuration in the #Service
definition allows for tight coupling of configurations. But, this method only allows for a service to connect with one edge and only using HTTP.
Open the GSL service file for the service you want to connect to an edge.
Add an edge field inside the #Service
definition, like so:
gsl.#Service & {
...
edge: {
}
}
Inside the edge
object, add these two fields:
edge: {
edge_name: "<the edge name found in the GSL edge file>"
routes: "<route path>": {}
}
Optionally, you can add a edge_ingress
field set to the specific edge listener you want to handle this route.
The routes
map should look familiar since it matches the schema of an #HTTPListener
’s routes
field. The map keys are route paths that get matched against incoming requests and the values are configurations to execute upon a successful route match.
Once you defined the route path to match and any extra route configuration, link the route to the service with an upstream:
routes: "<route path>": {
...
upstreams: (name): {
gsl.#Upstream
namespace: context.globals.namespace
}
}
Inside the upstream block, you can configure the connection options between the edge and the service, for instance, to enable SPIRE or special load balancing.
Conclusion
Once you commit and push your changes to your git repository, then you are done. The application edge node will route all requests matching <route path>
to this service.