openfaas-incubator / vcenter-connector

Extend vCenter with OpenFaaS
MIT License
28 stars 8 forks source link
connector-sdk event-driven events faas kubernetes openfaas serverless vcenter vms vmware

OpenFaaS vcenter-connector

vcenter-connector is an OpenFaaS event-connector built to consume events from vCenter and to trigger functions.

Build Status

Overview

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.

Status

This project uses the OpenFaaS Connector SDK. vCenter credentials are stored using Kubernetes secrets.

Supported Events

The following event types (incl. their subtypes) are supported and can be used to trigger functions:

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.

Credentials

Credentials within Kubernetes

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.

Using credentials outside of Kubernetes

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.

Examples / community

VEBA

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.

Contributing

Please propose changes in an Issue before submitting a PR and sign-off commits.

See the contribution guide for OpenFaaS for more.

License

MIT

Acknowledgements

This project is hosted and maintained by OpenFaaS Ltd

It makes use of the following components:

The contact for OpenFaaS Ltd is Alex Ellis

The contact for VMware is Michael Gasch (VMware)