vcenter-connector is an OpenFaaS event-connector built to consume events from vCenter and to trigger functions.
With this project your functions can subscribe to events generated by the changes (i.e. events) in your vCenter installation - for instance a VM being created, turned on or deleted. This allows you to extend vCenter's functionality by writing functions to execute each time an event is fired. An example may be tagging a VM with the date it was last turned on or applying a tag showing which user made a change to an object.
This project uses the OpenFaaS Connector SDK. vCenter credentials are stored using Kubernetes secrets.
The following event types (incl. their subtypes) are supported and can be used to trigger functions:
- Alarm Event, e.g.
AlarmCreatedEvent
- Datastore Event, e.g.
DatastoreDestroyedEvent
- Host Event, e.g.
HostDisconnectedEvent
- Resource Pool Event, e.g.
ResourcePoolCreatedEvent
- VM Event, e.g.
VmPoweredOnEvent
For further details and naming see the vSphere Web Services API documentation.
A function can be subscribed to multiple events using a comma-delimited syntax in its stack configuration:
[...]
annotations:
topic: "drs.vm.powered.on,vm.powered.off"
Note: Wildcards for event subscriptions, e.g. "
vm.powered.*
", are not supported.
When using the connector in Kubernetes, you will need to create a secret for the connector in the openfaas
namespace.
kubectl create secret generic vcenter-secrets \
-n openfaas \
--from-literal vcenter-username=user \
--from-literal vcenter-password=pass
At runtime these secrets will be mounted at /var/openfaas/secrets/
. See /yaml/kubernetes/connector-dep.yml for more.
You can pass credentials via arguments (not recommended).
./vcenter-connector \
-vc-user="admin" \
-vc-pass="test1234" \
Or use a file and pass the name:
export secret_mount_path="/tmp/secrets/`
./vcenter-connector \
-vc-user="" \
-vc-pass="" \
-vc-user-secret-name=vcenter-username \
-vc-password-secret-name=vcenter-password
The default path is /var/openfaas/secrets/
which can be overridden by setting the secret_mount_path
environment variable.
-
You can find a detailed example using vSphere tags for
VmPoweredOnEvent
here. -
Robert Guske of VMware write up a detailed blog post on how he automated the integration between several VMware products with OpenFaaS and this vcenter-connector.
VMware have released an appliance which packages OpenFaaS and the OpenFaaS vcenter-connector (this repository) and called it the "vCenter Event Broker Appliance". The appliance uses Photon OS.
Please propose changes in an Issue before submitting a PR and sign-off commits.
See the contribution guide for OpenFaaS for more.
MIT
This project is hosted and maintained by OpenFaaS Ltd
It makes use of the following components:
- govmomi project providing Golang bindings for vCenter by Doug MacEachern, VMware
- vcsim simulator tool by Doug MacEachern, VMware
The contact for OpenFaaS Ltd is Alex Ellis
The contact for VMware is Michael Gasch (VMware)