In my previous article, I demonstrated how you can leverage the upcoming v0.7 release of the VMware Event Broker Appliance (VEBA) to publish and consume custom events to easily extend your event-driven automation to other event sources. As a recap, this is accomplished by constructing and sending a conformant CloudEvent to VEBA, which can then be consumed by your functions.
This is perfect for external event sources that can create a custom HTTP payload that conforms to the CloudEvent specification, however not all solutions have this type of functionality or flexibility. An alternative solution to this is to simply create a VEBA function that can accept a custom payload and then handle the transformation of the data into a valid CloudEvent and then forward that off to broker running within VEBA. This is just one of the many benefits of Knative, the backend for VEBA, where each function deployment includes an endpoint that is automatically served as a subdomain to the VEBA hostname (e.g. https://my-function.NAMESPACE.VEBA-FQDN)
This solution would enable external "Event Producer" to send a non-CloudEvent payload which can then be processed by your function and re-publish as a conformant CloudEvent that can then be consumed by other function and services.
- Event Provider would make HTTP request to the function webhook with a custom payload
- A conformant CloudEvent payload is constructed by the webhook function
- Webhook function will then forward the CloudEvent internally to the VMware Event Broker Appliance
- VEBA functions can now react to these custom CloudEvents
The only requirement to support custom webhook functions is that VEBA must be deployed with a wildcard DNS entry. This is required because each function deployment will translate into service endpoint with the following URL structure: https://[FUNCTION-NAME].[FUNCTION-NAMESPACE].[VEBA-FQDN] and your DNS server must be able to automatically resolve these dynamic endpoints.
You can view a specific function service URL by running the following command:
kubectl -n vmware-functions get ksvc [FUNCTION-NAME]
In my homelab, I am using Photon OS and Unbound for my DNS server.
Here is a typical DNS (forward and reverse record) using Unbound:
local-data: "vcenter.primp-industries.local A 192.168.30.84"
local-data-ptr: "192.168.30.84 vcenter.primp-industries.local"
Here is wildcard DNS record (which includes a forward and reverse entry) using Unbound:
local-zone: "veba.primp-industries.local." redirect
local-data: "veba.primp-industries.local. 3600 IN A 192.168.30.171"
local-data: "veba.primp-industries.local A 192.168.30.171"
local-data-ptr: "192.168.30.171 veba.primp-industries.local"
To configure wildcard DNS for your own DNS server, you should refer to the specific production documentation for guidance.
Once you have setup a wildcard DNS for your VEBA deployment, you can refer to this sample PowerShell function which demonstrates how to create and test a custom webhook function.
Thanks for the comment!