VMware Event Broker Appliance - vSphere HA Event Notification Function
Community
I recently had the pleasure to suppport a member out of the VMware Event Broker Appliance (VEBA) Slack Community with his function example contribution to the VEBA project. His name is Bob. He introduced his Powershell/ PowerCLI function on a remote session to me and I was immediately thrilled about what the function does. It covers a use case that one of my customers brought up some time ago when I first introduced VEBA to them.
Bob’s engagement was really contagious and getting work done was quite fun. All credits goes out to Bob!
Code
Bob developed a script some time ago, which functionality basically is, to send out a notification via Email after a vSphere HA event occurred. This Email will have the affected host mentioned as well as all affected VMs which has been restarted through vSphere HA. The problem was, that the execution of the script was a manual task every time a ESXi host outage took place…at least until he became aware of VEBA.
Then he started digging into it.
There is really good material available on “Getting started with VEBA” like for example this Series by Patrick Kremer as well as articles and documentation on “Writing your own function” like e.g. Writing your first Serverless Function by Partheeban Kandasamy (PK) and also here at the Documentation section at VEBA’s homepage.
You don’t have to reinvent the wheel! If you have great code
, like Bob, take it, make your hands dirty and write your first function in any of your preferred programming language. It is not that complicated and I promise you the joy of success when your first function does exactly what you built it for.
If you don’t have own code available, start looking here: VMware {code} Sample Exchange. The community is diligent and willing to share.
Contribution
You are probably wondering when I finally introduce the function, right? The reason for my long introduction in this post is that I want to encourage you to start building your own function(s) to unlock the potential of event-driven automation in your data center.
Like Bob successfully did. 😁
Here we go and waiting for it to get merged: VMware Event Broker Appliance PR #183 - Add function HA Restarted VMs Email Notification
I had to share my excitment on Twitter when I first contributed to the project. It’s a great and unique feeling and even better when the PR got merged.
Another moment for my "I'll never forget this box". 1st (last week) the feeling of having contributed to an #OpenSource project, my 1st PR (ever) was merged π₯³and then on top of that, a ded. coding session with no one else than @lamw today (PR#2 π¬) π. Thank you so much! #VEBA
— Robert Guske (@vmw_rguske) January 13, 2020
The HA Restart Function
I’m not going into the details on how to deploy the function, because it works basically like the vSphere Datastore Usage Email Notification function which deployment is well explained step-by-step here: vCenter Event Broker Appliance β Part IX β Deploying the Datastore Usage Email sample script in VMC.
Exactly two files are important to deploy the function. The vcconfig-ha-restarted-vms.json
and the stack.yml.
You have to fill out all the fields in the vcconfig-ha-restarted-vms.json
file to have the required information like e.g. for the vCenter Server as well as for the SMTP server stored as a Kubernetes Secret.
|
|
The below listed stack.yml
file describes on which vCenter Event the function will be invoked, where the function image is stored and on which VEBA instance the function will finally run.
topic: com.vmware.vc.HA.ClusterFailoverActionCompletedEvent
image: harbor.jarvis.lab/veba/veba-powercli-ha-restarted-vms:latest
gateway: https://veba041.jarvis.lab
|
|
I have built the function from scratch and pushed it into my local container registry Harbor. If you would like to read more about “How to push your function images to Harbor”, take a look here: Using Harbor with the VMware Event Broker Appliance.
After successfully deploying the function to my VEBA the next step is to simulate a host outage to trigger the aforementioned vCenter HA event.
ESXi Kernel Panic command
I’m using a nested vSphere Cluster in my Homelab to simulate the outage. Connect to your nested ESXi host via ssh
and execute the following command to perform a ESXi Kernel Panic. Please use this command with caution!
And here it goes! The below screenshot from the H5 vSphere client shows the affected host (top left: nesxi67-02.jarvis.lab) as well as the occurred vCenter event which triggers our function.
A more detailed view can be done via a terminal. Below you can see the deployed ha-restarted-vms function running as a Kubernetes POD on VEBA (lower left), the ESXi Kernel Panic command (lower right) and the invocation of the HA Restart Function triggered by the occurred vCenter HA event (top right).
You have mail!
If everything operates as expected, you should have received an email according to the following screenshot of the one I received.
Thanks Bob! Keep up the great work.