Skip to content

VMWare Example

Connecting Direktiv and VMWare vSphere or ESXi via Knative Eventing is a very simple process because VMWare provides a Knative eventing source for their products. If Knative Eventing is configured with Direktiv there are just three simple steps required to connect these components.

VMWare Version

This example has been tested with 7.x and 8.x

Installing VMWare Tanzu Sources

The VMWare sources can be directly installed from the source repository with a kubectl command.

Apply Tanzu Source
kubectl apply -f

VMWare Source Version

Please check for the latest version of the VMWare sources

After running the command there shouild be three pods available in the namespace vmware-sources:

  • horizon-source-webhook
  • vsphere-source-webhook
  • horizon-source-controller

Creating Credentials

To connect to vSphere or ESXi the source needs the credentials and connectivity information. It requires a kubernetes secrets which will be consumed later by the actual source.

VMWare Secret
kubectl apply -f - <<EOF
apiVersion: v1
kind: Secret
  name: vsphere-credentials
  namespace: vmware-sources
  username: root
  password: MySecretPassword

The next stpe is to create the actual source. It requires the address and the reference to the crednetials used. The sink is the default Direktiv sink. The namespace of the sink might need to be adjusted to fit the installation namespace.

Create Source
kubectl apply -f - <<EOF
kind: VSphereSource
  name: source
  namespace: vmware-sources
  # Where to fetch the events, and how to auth.
  skipTLSVerify: true
    name: vsphere-credentials

  # Where to send the events.
      apiVersion: v1
      kind: Service
      name: direktiv-eventing
      namespace: default
    uri: /hello?filter=test # sending to namespace vmware

  # Adjust checkpointing and event replay behavior
    maxAgeSeconds: 300
    periodSeconds: 10

  # Set the CloudEvent data encoding scheme to JSON
  payloadEncoding: application/json

Testing And Filtering

By default there should be enough events generated within VMWare to see incoming events on the monitoring page of Direktiv. These events can be e.g. of type com.vmware.vsphere.VmBeingCreatedEvent.v0 or com.vmware.vsphere.VmStartingEvent.v0. Because there a many events it might be worthwhile to filter them.

For filtering there are two options. Either use the native Knative trigger/filter mechanism or Direktiv's built-in event filter in the gateway.

Direktiv's gateway supports filtering of event for events and this example will rename logout events, drop login events and pass through all other events as-is.

Direktiv Gateway Filter
direktiv_api: "endpoint/v1"
allow_anonymous: true
path: "/hello2"
  - "POST"
    type: "target-event"
      namespace: "ddd"
    - type: "event-filter"
        script: |
          if (event["type"] == "com.vmware.vsphere.UserLogoutSessionEvent.v0") {
            event["type"] = "vmware-logout"
          if (event["type"] == "com.vmware.vsphere.UserLoginSessionEvent.v0") {
              return null
          return event
        allow_non_events: false