Subscribe to an event through the Command Line Interface for external kafka brokers only.
You must deploy the latest version of Bare Metal Orchestrator.
Users can subscribe to events through the Command Line Interface for create, update, or delete operations on the following components:
- Server controller
- Hardware controller
- Tenant controller
- Site controller
Follow these steps to subscribe to an event:
- Establish a CLI session on the Bare Metal Orchestrator VM and log in. For high availability configurations, establish a CLI session using the virtual IP (VIP) of the Load Balancers for the Bare Metal Orchestrator cluster.
- Navigate to ~/samples/event-router and download any one sample configuration templates to your local machine based on your requirements:
- config-httpsink.json
- config-kafka.json
- Edit the json file and update the required attributes using Vim or a similar editor. For more information see Event field definitions.
The following is an example of config-httpsink.json file:
{
"sink": "http",
"httpSinkUrl": "http://httpsink.metalweaver.svc.cluster.local:5556/events",
"sinkOutputFormat": "cloudEvents",
"timeout": "30s",
"retryCount": 5,
"retryDelay": "10s",
"unsubscribe": false,
"subscribedEventTypes": "Normal Warning",
"subscribedObjects": "Server Site HardwareProfile Tenant Switch Stackdeployer",
"headers": {
"Authorization": "Bearer superSecret"
}The following is an example of config-kafka.json file:
{
"sink": "kafka",
"kafkaBrokers": "my-cluster-kafka-external-bootstrap.my-kafka-project.svc.cluster.local:9094",
"kafkaTopic": "my-topic",
"subscribedEventTypes": "Normal Warning",
"subscribedObjects": "Server Site HardwareProfile Tenant Switch Stackdeployer",
"unsubscribe": false,
"async": false,
"sinkOutputFormat": "cloudEvents"
} - Save the file and quit the editor.
- Run the following command to encode the json file using base64 encoding.
base64 -w 0 <filename>
For example:#base64 -w 0 config-httpsink.json
ewogICAgInNpbmsiOiAia2Fma2EiLAogICAgImthZmthQnJva2VycyI6ICJteS1jbHVzdGVyLWthZmthLWV4dGVybmFsLWJvb3RzdHJhcC5teS1rYWZrYS1wcm9qZWN0LnN2Yy5jbHVzdGVyLmxvY2FsOjkwOTQiLAogICAgImthZmthVG9waWMiOiAibXktdG9waWMiLAogICAgInN1YnNjcmliZWRFdmVudFR5cGVzIjogIk5vcm1hbCBXYXJuaW5nIiwKICAgICJzdWJzY3JpYmVkT2JqZWN0cyI6ICJTZXJ2ZXIgU2l0ZSBIYXJkd2FyZVByb2ZpbGUgVGVuYW50IFN3aXRjaCBTdGFja2RlcGxveWVyIiwKICAgICJ1bnN1YnNjcmliZSI6IGZhbHNlLAogICAgImFzeW5jIjogZmFsc2UsCiAgICAic2lua091dHB1dEZvcm1hdCI6ICJjbG91ZEV2ZW50cyIKICB9CiAgNote: Base64 encoding must be done whenever you update the json file.
- Run:
bmo edit secret <secretname> -n <namespace>
For example:bmo edit secret mw-event-router-secret -n mw-event-router-system
- Edit the mw-event-router-secret file in Vim or a similar editor to update the config.json field with the base64 encoded content that was generated earlier. The following is an example of the <secretfilename>.yaml file:
apiVersion: v1
data:
config.json: W2RlZmF1bHRdCmF3c19hY2Nlc3Nfa2V5X2lkID0gbXlhY2Nlc3NrZXkKYXdzX3NlY3JldF9hY2Nlc3Nfa2V5ID0gbXlzZWNyZXRrZXkK
kind: Secret
metadata:
name: mw-event-router-secret
namespace: mw-event-router-system
type: Opaque - Save the file and quit the editor.
In the unlikely event of a system error, the event router may restart. If the event router is restarted, events from the previous hour prior to the restart are processed again. This may cause duplicate event notifications.