In Part II of this series, we looked at setting up a Windows workstation with the prereqs for interacting with VEBA using the Knative event processor In Part III, we will deploy our first sample function – the Knative echo funciton.
The simplest way to test out your new VEBA appliance is to deploy the echo function. All it does is print out the payload of any event it receives.
First, you must clone the VEBA repo. On the repo homepage, click Code, then click the Copy button to copy the Github URL.

Clone the repo
git clone https://github.com/vmware-samples/vcenter-event-broker-appliance.git

This will create a folder named vcenter-event-broker-appliance with the project inside of it. If you’re using VS Code, you can open the folder that you just cloned with File>Open.
You can then browse to examples/knative/powershell/kn-ps-echo and open up README.md

VS code shows you the raw markup. If you want to see it rendered, you can right-click the file and select Open Preview.

Now it’s a little easier to read. We will follow these instructions to test and deploy the function.

Open a new terminal window.

My default is the Git bash terminal, which I prefer when working on Python projects. Since we’re deploying a PowerShell function here, it will be easiest to work in a PowerShell terminal.

You can change it to PowerShell here.


Then open a new terminal window and it will be PowerShell


Change to the kn-ps-echo function directory
cd .\examples\knative\powershell\kn-ps-echo\
Build the Docker image. Use your own Docker account name.
NOTE: If you get a build error, you may need to issue the ‘docker login’ command to log into Docker.
docker build -t kremerpatrick/kn-ps-echo:1.0 .
This will run for some time as the container image builds.

The build is finished.

Push the container image to the Docker registry
docker push kremerpatrick/kn-ps-echo:1.0
The push succeeds.

Now we highlight one of the best parts of running VEBA with Knative – the ability to test your functions locally without having to deploy them to VEBA.
We want 2 terminal windows side-by-side, which can be done with the split button.


Now we have 2 windows. Change to the kn-ps-echo directory in the right window.
cd .\examples\knative\powershell\kn-ps-echo\

Run the container image
docker run -e PORT=8080 -it --rm -p 8080:8080 kremerpatrick/kn-ps-echo:1.0

In the right terminal window, run test.ps1 to send a simulated CloudEvent payload to the container image.
.\test.ps1
The right terminal shows success.

The left terminal echoes the CloudEvent payload.


We now close the right terminal window with the trash can.

We terminate the Docker container with Ctrl-C

We edit function.yaml to point the container image to our newly built image.


Apply the configuration
kubectl apply -f function.yaml

Now we can watch the container being created by repeatedly running this command:
kubectl get pods -A
We see the container being created, and then see it transition to Running state after 30 seconds or so.


We now tail the logs of the kn-ps-echo deployment pod. Note that the name of your pod will be unique to your deployment.
kubectl logs -n vmware-functions kn-ps-echo-00002-deployment-7c4c9b466-v9c27 user-container -f
The function works! We are seeing all vCenter events echoed out by the echo function. You can cause events to happen by doing anything on your vCenter. Give it a try – log in, power up a VM, anything that happens on vCenter will show up here.

To clean up the pod, we will need to run the delete command. First, find the names of the echo deployment and trigger pods
kubectl get pods -A

We can delete both simultaneously with the command
kubectl delete pods -n vmware-functions kn-ps-echo-00002-deployment-7c4c9b466-v9c27 kn-ps-echo-trigger-dispatcher-7bc8f78d48-nnnb6

We have successfully deployed our first function using Knative! In Part IV, we will deploy the Slack PowerShell function – this function can send a Slack notification for any event in vCenter.
VMware Event Broker Appliance – Part VIII – Building a new PowerCLI Function - Preparation -
[…] the first set of instructions in Deploying the Echo Function to clone the code repo to your […]
VMware Event Broker Appliance – Part IV - Deploying the Slack Function (Knative) -
[…] Part III of this series, we deployed the Knative Powershell echo function. In this post, we will deploy the […]
VMware Event Broker Appliance – Part II - Sample Code Prereqs (Knative) -
[…] have now installed all of the prereqs for running our first sample function. In Part III, we will look deploy our first Knative […]