Event-driven interactions with vSphere using Functions as a Service
I am very happy to inform you that the below described idea has become a VMware Fling (completely OpenSource).
Official website of VMware Event Broker Appliance: https://vmweventbroker.io/
When was the last time that you were so much taken by a topic or better by a combination of several, that just by thinking about it your face is filled with enthusiasm?
For me, it’s only been a few days ago and it was in one of these afterwork-calls with my well appreciated colleague and friend Michael Gasch where we talked about things we were working on. I had just published my recent post on “Monitoring Container VMs with vRealize Operations Manager” were I described how I built a dashboard for & with vRealize Operations Manager to monitor the utilization and performance for two of the major objects from vSphere Integrated Containers, the Virtual Container Host (VCH) and the Container-VMs (cVM).
Michael told me that he had spent some time in digging deeper and deeper into the topic Functions as a Service…
knative might be the future of multi-cloud FaaS abstraction. Right now I still prefer OpenFaaS for it's simplicity (in the context of my work at VMware). It just works...
— Michael Gasch 🇩🇪🇺🇦 (@embano1) October 25, 2018
which was far away from being experienced by myself, but he got me right away from the very beginning of his telling. For those of you who want to know more about the topic but haven’t put your nose into it yet, like me before, you´ll find some links at the Resources section at the buttom.
I´m not going to explain what a Function/ FaaS is all about, instead of it Michael and I thought that this post should serve as an introduction of a project Michael is working on as well as to demonstrate how “just” two components are turning your vSphere environment into a Event-driven construct based on your annotations.
Before I´m going to start with the details and what should already be up and running, I`d like to quote the following description to explain what it means when it comes to the topic “Functions vs. Containers”.
Container:
Create a container which has all the required (Application) dependencies pre-installed, put your application code inside of it and run it everywhere the container runtime is installed.
FaaS:
Applications get split up into different functionalities (or services), which are in turn triggered by events. You upload your function code and attach an event source to it.
Source: Serverless (FaaS) vs. Containers - when to pick which?
Tagging vSphere objects by using a ƒ(x)
At the beginning I´ve mentioned that my last post was on the topic “Monitoring Container VMs with vRealize Operations Manager” and that I had to built a dashboard to do so. I´m using a widget in this dashboard called Object List to have the ability to select a specific Virtual Container Host, the Resource Pool not the Docker end-point VM(!), to display the utilization in terms of Limits & Reservations (CPU & Memory) of it.
While I was building this dashboard, one challange for me was, to find a way on which criteria these Resource-Pools will join a Dynamic Custom Group in vRealize Operations Manager (to appear automatically in the dashboard/ in the object list). Long story short, I decided to use vSphere Tags as a Membership-Criteria. But assigning a vSphere Tag is still a manually task (*1) and this is the point were Michaels function pytagfn or gotagfn, depending on the language you prefer, as well as the vCenter Connector comes into play.
vic-machine
utility to assign a vSphere-Tag during the VCH deployment is already open on Github:
https://github.com/vmware/vic/issues/8446The following flowchart will give you a high-level overview what it´s all about and what Michael and I will demo you in the Video below.
-
vCenter-Connector is listening to the event-stream coming from the vCenter Server and talks to the OpenFaaS-Gateway to retrieve a list of functions which are interested in incoming events.
-
pytag-fn
will get invoked by a specific event (e.g. resource.pool.created). -
vSphere Tag assignment through the triggered function.
-
vRealize Operations Manager is polling data from vCenter Server in certain intervals.
-
Resource Pool is added to the Dynamic Custom Group and is available in the dashboard/ object-list.
The recording
What you need | Pre-reqs
All you need is OpenFaaS running in Kubernetes. As shown in the flowchart as well as having been mentioned in the recording, I´m running VMware´s Enterprise-grade Kubernetes solution VMware PKS in my #Homelab in order to make all necessary pieces available.
Say "Hello" to the newest member in my #Homelab: #VMware #PKS 😎 Next step for tonight: Registry replication between my @project_harbor instance, which is running within #vSphereIntegratedContainers and PKS. #Kubernetes #containers pic.twitter.com/VW2abqBHSN
— Robert Guske (@vmw_rguske) January 27, 2019
Another pretty cool alternative way to run OpenFaaS on k8s is KinD which is a new tool from the Kubernetes community named Kubernetes in Docker.
Alex Ellis has already written a nice blog-post on it: “Get started with OpenFaaS and KinD”. Check it out!
Install OpenFaaS on Kubernetes
Installing OpenFaaS on Kubernetes is quite easy by using the “OpenFaaS-on-Kubernetes” Edition faas-netes. Go through the documentation and you´ll have it installed in a couple of steps.
Having followed the instructions in the documentation, you will end up with the following components installed:
-
Helm with the Helm client (
helm
) and the Helm server (Tiller - running in the namespace kube-system). -
OpenFaaS on Kubernetes
- deployed into the namespace openfaas
-
The faas-cli via e.g.
brew
orcurl
I hope you enjoyed reading and liked the recording.