You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
- Incorporate review feedback for README
- Enable OpenFaaS auth in the deployment manifest and describe how to
disable if needed
Signed-off-by: Michael Gasch <[email protected]>
Copy file name to clipboardExpand all lines: README.md
+29-23Lines changed: 29 additions & 23 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,16 +1,16 @@
1
1
# vcenter-connector
2
2
3
-
vcenter-connector is an OpenFaaS event connector built to consume events from vCenter from VMware vSphere.
3
+
vcenter-connector is an OpenFaaS event connector built to consume events from vCenter from vCenter.
4
4
5
5
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.
6
6
7
7
## Status
8
8
9
9
This project uses the [OpenFaaS Connector SDK](https://github.com/openfaas-incubator/connector-sdk).
10
10
11
-
The code is under **active development** and only suitable for early adopters. More examples and instructions for use in Kubernetes are being worked on, including improved handling of secrets (accounts and passwords).
11
+
The code is under **active development** and only suitable for early adopters. For the initial version the vCenter user credentials need to be stored in plain-text in your YAML files, but this will move to using [OpenFaaS secrets](https://docs.openfaas.com/reference/secrets/) in the next version.
12
12
13
-
**Note:** Currently only a pre-build Docker image is available (based on [PR#11](https://github.com/openfaas-incubator/vcenter-connector/pull/11)) and only [VM events](https://code.vmware.com/doc/preview?id=4206#/doc/vim.event.VmEvent.html) are supported.
13
+
**Note:** Currently only a pre-built Docker image is available (based on [PR#11](https://github.com/openfaas-incubator/vcenter-connector/pull/11)) and only [VM events](https://code.vmware.com/doc/preview?id=4206#/doc/vim.event.VmEvent.html) are reportable for now.
14
14
15
15
## Example: vCenter Tagging Function
16
16
@@ -28,53 +28,55 @@ The code is under **active development** and only suitable for early adopters. M
28
28
29
29
### How it works:
30
30
31
-
Functions can subscribe to events in vCenter through the "topic" [annotations](https://docs.openfaas.com/reference/yaml/#function-annotations) applied through your `stack.yml` file.
32
-
33
-
I.e. in the following example we will subscribe to the event "vm.powered.on" by adding an annotation to our function of "vm.powered.on"
31
+
Functions can subscribe to events in vCenter through the "topic" [annotations](https://docs.openfaas.com/reference/yaml/#function-annotations) applied through your `stack.yml` file. Based on these events a function can take action, e.g. tag a VM, run post-processing scripts, audit to an external system, etc.
34
32
35
33
### Get started with the vCenter Tagging Function example
36
34
35
+
In the following example we will subscribe to the event "vm.powered.on" by adding an annotation to our function of "vm.powered.on". The function will then add a specific tag to any VM when it is powered on.
36
+
37
37
1) Create a category/tag to be attached to a VM when it is powered on. Since we need the unique tag ID (i.e. vSphere URN) we will use [govc](https://github.com/vmware/govmomi/tree/master/govc) for this job. You can also use vSphere APIs (REST/SOAP) to retrieve the URN.
2) Take a note of the `urn:...` for `demotag1` as we will need it in a bit
54
+
2) Take a note of the `urn:...` for `demotag1` as we will need it for the next steps
55
55
3) In a separate terminal download the example function
56
56
57
57
```bash
58
58
git clone https://github.com/embano1/pytagfn
59
59
cd pytagfn
60
60
```
61
61
62
-
4) Configure the Python tagging function `stack.yaml`. The example cloned from Github already has the annotation to subscribe to VM power on events. More details in the [README](https://github.com/embano1/pytagfn/blob/master/README.md).
62
+
4) Configure the Python tagging function `stack.yaml`.
63
+
64
+
> **Note:** The example cloned from Github already has the annotation to subscribe to VM power on events. More details in the [README](https://github.com/embano1/pytagfn/blob/master/README.md).
63
65
64
66
```yaml
65
67
environment:
66
-
VC: vcenter.ip # must be reachable/resolvable from OpenFaaS
67
-
VCUSERNAME: VCUSER # WIP: migration to secrets
68
-
VCPASSWORD: VCPASSWORD # WIP: migration to secrets
69
-
# Replace TAGURN example below with the one you created with govc above
6) Download and deploy the OpenFaaS vCenter Connector deployment manifest in a separate
85
87
88
+
> **Note:** The deployment assumes you have [basic authentication](https://docs.openfaas.com/reference/authentication/#for-the-api-gateway) configured for the OpenFaaS gateway. Thus, the deployment assumes a secret `basic-auth` to be available (`volumes` section in the YAML). If you don't use authentication for the gateway, remove the volumes section as the deployment would fail, not being able to mount the secret to the pod.
In the next step we will power on a VM to trigger an event in vCenter ("VM powered on..."). This event will be received by the connector and forwarded to the OpenFaaS function subscribed to the corresponding event type (`vm.powered.on`). The function will then add the tag we created above (`demotag1`) to the VM.
107
+
102
108
```bash
103
109
# Note: This can be done in vCenter UI or via govc
104
110
# Pick a VM that is powered off and does not have already "demotag1", then in the running govc container power on the VM
0 commit comments