Deploying VMware Event Broker on Kubernetes: A Hands-On Guide
=================================================================
In this article, we will explore how to deploy the VMware Event Broker (VEBA) services within an existing Kubernetes (K8S) cluster and use it to add/edit custom attributes information to virtual machines. We will also demonstrate how to create a Function-as-a-Service (FaaS) using OpenFaaS to listen for events in the VMware vCenter infrastructure and run specific tasks when filtered events occur.
Background Information
———————
VEBA stands for “VMware Event Broker Appliance”: a Photon OS based virtual machine, available in OVA format, with an embedded small K8S cluster to support the “VMware Event Broker” services. The VEBA deployment method provides a simple and easy-to-use way to deploy the event broker services within an existing K8S cluster.
The VMware Event Router is the VEBA component that watches for new events generated by an Event Stream Source and routes the event to the function-processor. The function-processor then forwards the event to the function-handler, which performs the desired actions based on the event type.
Why Use VEBA on Kubernetes?
——————————–
Using VEBA on K8S provides several benefits, including:
* Easy deployment and management of event broker services within an existing Kubernetes cluster.
* Support for multiple event sources, such as vCenter, NSX, and vSAN.
* Ability to handle a large number of events per second, making it suitable for large-scale virtualized infrastructure.
* Integration with OpenFaaS allows for the creation of Function-as-a-Service use cases, further expanding the capabilities of VEBA.
Prerequisites
—————-
Before beginning, ensure that you have the following prerequisites in place:
* An existing Kubernetes cluster with a working OpenFaaS installation.
* A valid vCenter server and credentials to access it.
* Custom attributes defined in vCenter for the virtual machines of interest.
Deploying VEBA on Kubernetes
——————————
To deploy VEBA on K8S, follow these steps:
1. Clone the sample repository:
“`bash
git clone https://github.com/lrivallain/veba-samples.git
“`
2. Create a secret to store the local configuration:
“`yaml
kubectl create secret generic vc-config –from-literal=vc-username=,vc-password=
“`
3. Deploy VEBA with OpenFaaS:
“`yaml
kubectl apply -f https://raw.githubusercontent.com/lrivallain/veba-samples/master/openfaas-fn.yaml
“`
4. Create a function-processor.yaml file in the same repository as the sample:
“`yaml
apiVersion: 1.0.0
kind: FunctionProcessor
metadata:
name: openfaas-fn
spec:
processor:
handler: path/to/your/function/handler.go
functions:
– name: my-function
handler: path/to/your/function/handler.go
“`
5. Apply the function-processor.yaml file:
“`yaml
kubectl apply -f function-processor.yaml
“`
6. Create a stack.yml file in the same repository as the sample:
“`yaml
services:
– name: veba
image:
ports:
– name: http
port: 31112
volumeMounts:
– name: secret
mountPath: /etc/veba/secret
– name: openfaas-fn
image:
ports:
– name: http
port: 31112
“`
7. Apply the stack.yml file:
“`yaml
kubectl apply -f stack.yml
“`
8. Verify the deployment by running the following command:
“`
kubectl get pods -n openfaas-fn
“`
Expected output:
“`
NAME READY STATUS RESTARTS AGE
openfaas-fn-6f45754881 1/1 Running 0 3m29s
“`
Creating a Function-as-a-Service Use Case
——————————————
Now that VEBA is deployed within the Kubernetes cluster, we can create a function-as-a-service use case to listen for events in vCenter and run specific tasks when filtered events occur. To do this, we will create a custom attribute in vCenter, power on a VM, and then invoke our function to update the custom attribute with the VM name.
Step 1: Create a Custom Attribute
———————————
First, let’s create a custom attribute in vCenter that will be used by our function. Log in to your vCenter server and follow these steps:
1. In the vSphere client, navigate to the “Home” tab and click on the “Edit” button next to the “Custom Attributes” option.
2. Click on the “Add Custom Attribute” button and enter a name for your attribute (e.g., “VM-Name”).
3. Click “OK” to save the new custom attribute.
Step 2: Power On a VM
—————————
Next, power on a VM of interest and wait for the custom attribute to be updated with the VM name. To do this, follow these steps:
1. In the vSphere client, navigate to the “Home” tab and click on the “Power” button next to the VM of interest.
2. Select “Power On” from the dropdown menu.
3. Wait for the custom attribute to be updated with the VM name.
Step 3: Invoke the Function
—————————–
Now that the VM is powered on and the custom attribute has been updated, we can invoke our function to update the custom attribute with the VM name. To do this, follow these steps:
1. Log in to your Kubernetes cluster using kubectl.
2. Run the following command to invoke our function:
“`bash
kubectl apply -f https://raw.githubusercontent.com/lrivallain/veba-samples/master/update-custom-attribute.yaml
“`
3. Wait for the custom attribute to be updated with the VM name.
Expected output:
“`
Custom Attribute “VM-Name” with value “my-vm” has been updated.
“`
Conclusion
———-
In this article, we have demonstrated how to use VEBA on Kubernetes to listen for events in vCenter and update custom attributes based on those events. We have also shown how to create a function-as-a-service use case to accomplish this task. With this information, you should now be able to leverage the power of VEBA and OpenFaaS to automate your virtualized infrastructure management tasks.