Skip to content

Instantly share code, notes, and snippets.

@embano1
Last active November 23, 2021 09:30
Show Gist options
  • Save embano1/c4603792531d4e31f82062682f8b4192 to your computer and use it in GitHub Desktop.
Save embano1/c4603792531d4e31f82062682f8b4192 to your computer and use it in GitHub Desktop.
End-to-End Installation of VMware Event Router with kind

End-to-End Installation of VMware Event Router with kind

The following steps describe the installation of the VMware Event Router (also part of the VEBA project) in a local Kubernetes and Knative environment.

The steps assume a Mac OSX environment but the links provide resources to install the components for other platforms.

Install Knative with KonK.

Requires:

export KIND_CLUSTER_NAME=kind
curl -sL get.konk.dev | bash

Install Knative CLI kn

kn lets you work with Knative resources, e.g. services, brokers, etc. instead of using kubectl.

brew install knative/client/kn

kn version
Version:      v0.23.0
Build Date:   2021-05-19 07:42:12
Git Revision: 3cc608f9
Supported APIs:
* Serving
  - serving.knative.dev/v1 (knative-serving v0.23.0)
* Eventing
  - sources.knative.dev/v1 (knative-eventing v0.23.0)
  - eventing.knative.dev/v1 (knative-eventing v0.23.0)

Install Sockeye (recommended)

Sockeye lets you view incoming events in the browser, which can be helpful with troubleshooting.

kubectl apply -f https://github.com/n3wscott/sockeye/releases/download/v0.7.0/release.yaml
service.serving.knative.dev/sockeye created

Open the Sockeye UI:

kn service list
NAME      URL                                       LATEST          AGE    CONDITIONS   READY   REASON
hello     http://hello.default.127.0.0.1.nip.io     hello-00001     14m    3 OK / 3     True
sockeye   http://sockeye.default.127.0.0.1.nip.io   sockeye-00001   6m4s   3 OK / 3     True

open http://sockeye.default.127.0.0.1.nip.io

💡 The KonK stack uses nip.io so you can access Knative services from your local machine via the shown URLs.

To avoid missing an event, disable scale-to-zero for the Sockeye Knative service. Note that this might only happen because we're using an in-memory broker using goroutines as channels which is not intended for production use.

kn service update --scale 1 sockeye
Updating Service 'sockeye' in namespace 'default':

  0.032s The Configuration is still working to reflect the latest desired specification.
  4.340s Traffic is not yet migrated to the latest revision.
  4.411s Ingress has not yet been reconciled.
  4.470s Waiting for load balancer to be ready
  4.611s Ready to serve.

Service 'sockeye' updated to latest revision 'sockeye-00002' is available at URL:
http://sockeye.default.127.0.0.1.nip.io

Install vCenter Simulator (Event Source)

To trigger events, e.g. from vSphere, we can use vcsim.

cat << EOF | kubectl create -f -
apiVersion: apps/v1
kind: Deployment
metadata:
  name: vcsim
spec:
  selector:
    matchLabels:
      app: vcsim
  template:
    metadata:
      labels:
        app: vcsim
    spec:
      containers:
        - name: vcsim
          image: vmware/vcsim:latest
          args: ["/vcsim", "-l", ":8989"]
          ports:
            - name: https
              containerPort: 8989

---
apiVersion: v1
kind: Service
metadata:
  name: vcsim
spec:
  selector:
    app: vcsim
  ports:
    - name: https
      port: 443
      targetPort: 8989
EOF

deployment.apps/vcsim created
service/vcsim created

Install govc

govc is used to perform operations against the (simulated) vCenter, e.g. powering off a virtual machine which will trigger a corresponding event.

brew install govc

govc about
govc: specify an ESX or vCenter URL

Install Helm

The easiest way to deploy the VMware Event Router is via Helm.

brew install helm

helm version
version.BuildInfo{Version:"v3.5.4", GitCommit:"1b5edb69df3d3a08df77c9902dc17af864ff05d1", GitTreeState:"dirty", GoVersion:"go1.16.3"}

Add the VMware Event Router Helm Repo

helm repo add vmware-veba https://projects.registry.vmware.com/chartrepo/veba

# update index in case the repo was already installed
helm repo update

# ignore the index error message which is due to the Harbor environment
helm search repo event-router
index.go:339: skipping loading invalid entry for chart "event-router" "release-0.5.0" from /Users/mgasch/Library/Caches/helm/repository/vmware-veba-index.yaml: validation: chart.metadata.version "release-0.5.0" is invalid
NAME                            CHART VERSION   APP VERSION     DESCRIPTION
vmware-veba/event-router        v0.6.5          development     The VMware Event Router is used to connect to v...

Deploy VMware Event Router

Before installing the VMware Event Router create a configuration (Helm "override") file (passed via -f - and read from stdin).

The following commands assume a Knative broker in the default Kubernetes namespace with the name example-broker. As of writing this document these are the values used by the KonK stack. You can verify this via:

kubectl get brokers -A
NAMESPACE   NAME             URL                                                                               AGE   READY   REASON
default     example-broker   http://broker-ingress.knative-eventing.svc.cluster.local/default/example-broker   28m   True

It is also assumed that you created the vcsim deployment as shown above, otherwise change the address and settings if you have done a custom deployment.

# create the deployment "router" in the "vmware" namespace
cat << EOF | helm install -n vmware --create-namespace -f - router vmware-veba/event-router
eventrouter:
  config:
    logLevel: debug
  vcenter:
    address: https://vcsim.default.svc.cluster.local
    username: user
    password: pass
    insecure: true # ignore TLS certs
  eventProcessor: knative
  knative:
    destination:
      ref:
        apiVersion: eventing.knative.dev/v1
        kind: Broker
        name: example-broker
        namespace: default
EOF

Verify the router is correctly running, otherwise make sure you followed the steps as described above:

kubectl -n vmware logs deploy/router

 _    ____  ___                            ______                 __     ____              __
| |  / /  |/  /      ______ _________     / ____/   _____  ____  / /_   / __ \____  __  __/ /____  _____
| | / / /|_/ / | /| / / __  / ___/ _ \   / __/ | | / / _ \/ __ \/ __/  / /_/ / __ \/ / / / __/ _ \/ ___/
| |/ / /  / /| |/ |/ / /_/ / /  /  __/  / /___ | |/ /  __/ / / / /_   / _, _/ /_/ / /_/ / /_/  __/ /
|___/_/  /_/ |__/|__/\__,_/_/   \___/  /_____/ |___/\___/_/ /_/\__/  /_/ |_|\____/\__,_/\__/\___/_/

2021-07-16T08:36:33.882Z        WARN    [VCENTER]       vcenter/vcenter.go:126  using potentially insecure connection to vCenter        {"address": "https://vcsim.default.svc.cluster.local", "insecure": true}
2021-07-16T08:36:33.883Z        INFO    [MAIN]  router/main.go:112      connecting to vCenter   {"commit": "82df3ff", "version": "v0.6.1", "address": "https://vcsim.default.svc.cluster.local"}
2021-07-16T08:36:33.883Z        INFO    [KNATIVE]       injection/injection.go:61       Starting informers...
2021-07-16T08:36:33.994Z        INFO    [MAIN]  router/main.go:159      created Knative processor       {"commit": "82df3ff", "version": "v0.6.1", "sink": "http://broker-ingress.knative-eventing.svc.cluster.local/default/example-broker"}
2021-07-16T08:36:33.995Z        WARN    [METRICS]       metrics/server.go:58    disabling basic auth: no authentication data provided
2021-07-16T08:36:33.995Z        INFO    [METRICS]       metrics/server.go:97    starting metrics server {"address": "http://0.0.0.0:8082/stats"}
2021-07-16T08:36:33.997Z        INFO    [VCENTER]       vcenter/vcenter.go:213  checkpointing disabled, setting begin of event stream   {"beginTimestamp": "2021-07-16 08:36:33.9963237 +0000 UTC"}
2021-07-16T08:36:35.000Z        DEBUG   [VCENTER]       vcenter/vcenter.go:313  no new events, backing off      {"delaySeconds": 1}
2021-07-16T08:36:36.001Z        DEBUG   [VCENTER]       vcenter/vcenter.go:313  no new events, backing off      {"delaySeconds": 2}

💡 You can easily remove the Helm installation with helm -n vmware uninstall router.

Trigger an Event

Trigger an event and observe the output in the Sockeye UI (browser).

Notes:

  • If you reload the Sockeye UI it will discard previous events (stateless)
  • Since we're using an in-memory Knative Broker (non-production) in rare cases some events are lost - if you feel the event should have gone through please retry by triggering the event again

Create a Knative Trigger to subscribe to the Broker for (all) incoming events:

# assumes example-broker in default namespace
kn trigger create sockeye --broker example-broker --sink ksvc:sockeye
Trigger 'sockeye' successfully created in namespace 'default'.

# conditions must show 5/5 indicating READY
kn trigger list
NAME            BROKER           SINK                 AGE   CONDITIONS   READY   REASON
hello-display   example-broker   ksvc:hello-display   53m   5 OK / 5     True
sockeye         example-broker   ksvc:sockeye         10s   5 OK / 5     True

💡 Optionally a filter to only subscribe to specific events can be specified.

Open the Sockeye UI:

open http://sockeye.default.127.0.0.1.nip.io

In a separate terminal create a Kubernetes port-forwarding so we can use govc to connect to vcsim running inside Kubernetes.

kubectl port-forward deploy/vcsim 8989:8989
Forwarding from 127.0.0.1:8989 -> 8989
Forwarding from [::1]:8989 -> 8989

Open another terminal to trigger an event. First, set govc environment variables (connection):

export GOVC_INSECURE=true
export GOVC_URL=https://user:[email protected]:8989/sdk

# verify govc connects correctly by printing the vcsim inventory
govc ls
/DC0/vm
/DC0/host
/DC0/datastore
/DC0/network

Trigger an event and observe the output in Sockeye:

govc vm.power -off /DC0/vm/DC0_H0_VM0
Powering off VirtualMachine:vm-54... OK

Sockeye should show a VmStoppingEvent followed by a VmPoweredOffEvent.

image

If you don't see any output, make sure you followed all steps above, with correct naming and that all resources (broker, trigger, service, router, etc.) are in a READY state.

CONGRATULATIONS 🥳

You just deployed an end-to-end event-driven pipeline using a serverless platform connected to a vCenter environment.

Next, you might want to create your own services (functions) and create more event pipelines:

(*) Note that the VEBA examples assume a different Broker name/namespace so adjust the values accordingly during installation.

Uninstallation

Simply remove the kind cluster with:

kind delete cluster --name kind
Deleting cluster "kind" ...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment