Exposing services on the application network using YAML¶
Use YAML to create connectors and listeners for services on the application network.
After creating an application network by linking sites, you can expose services from one site using connectors and consume those services on other sites using listeners.
A routing key is a string that matches one or more connectors with one or more listeners.
For example, if you create a connector with the routing key backend, you need to create a listener with the routing key backend to consume that service.
This section assumes you have created and linked at least two sites.
Creating a connector using YAML¶
A connector binds a local workload to listeners in remote sites. Listeners and connectors are matched using routing keys.
For more information about connectors see Connector concept. For configuration details, see Connector resource.
Procedure
-
Create a workload that you want to expose on the network, for example:
-
Create a connector resource YAML file:
This creates a connector in theapiVersion: skupper.io/v2alpha1 kind: Connector metadata: name: backend namespace: east spec: routingKey: backend selector: app=backend port: 8080eastsite and exposes thebackenddeployment on the network on port 8080. You can create a listener on a different site using the matching routing keybackendto address this service.
To create the connector resource:
where <filename> is the name of a YAML file that is saved on your local filesystem.
- Check the connector status:
For example:
NAME STATUS ROUTING-KEY SELECTOR HOST PORT HAS MATCHING LISTENER MESSAGE
backend Pending backend app=backend 8080 false No matching listeners
spec.routingKey to your custom value.
Creating a listener using YAML¶
A listener binds a local connection endpoint to connectors in remote sites. Listeners and connectors are matched using routing keys.
For more information about listeners, see Listener concept. For configuration details, see Listener resource.
Procedure
-
Identify a connector that you want to use. Note the routing key of that connector.
-
Create a listener resource YAML file:
This creates a listener on the local system site and matches it with connectors that use the routing keyapiVersion: skupper.io/v2alpha1 kind: Listener metadata: name: backend namespace: west spec: routingKey: backend host: east-backend port: 8080backend. The listener accepts connections on port 8080 using the configured host value.
To create the listener resource:
where <filename> is the name of a YAML file that is saved on your local filesystem.
- Check the listener status:
For example:
NAME STATUS ROUTING-KEY HOST PORT MATCHING-CONNECTOR MESSAGE
backend Ready backend 0.0.0.0 8080 true OK
📌 NOTE
There must be a MATCHING-CONNECTOR for the service to operate.