The Kubeless function can be invoked through the command line or through a UI provided by Kubeless. The Kubeless UI can be provisioned by downloading the file locally and running it, or by using a Docker image and Dockerfile, or through the Kubernetes manifest that's available with the repository. For our tutorials, I will be using the Kubernetes manifest, as shown in the following code:
$ kubectl create -f https://raw.githubusercontent.com/kubeless/kubeless-ui/master/k8s.yaml
serviceaccount "ui-acct" created
clusterrole "kubeless-ui" created
clusterrolebinding "kubeless-ui" created
deployment "ui" created
service "ui" created
$ minikube service ui -n kubeless
The minikube command will pop a browser up and open a UI. The UI has the ability to create, edit, invoke, and delete the function, so invoke the function that we deployed. Let's add {"term":"New York"} in the textarea request, select the Request as POST, and click on Run Function. The function will be executed successfully, with the station data response output displayed, as shown in the following screenshot:
We can invoke the same function through the Serverless Framework as well, and the function will execute and get the required data, as shown in the following code:
$ serverless invoke --function bikesearch --data '{"term":"Albemarle"}' -l
Serverless: Calling function: bikesearch...
--------------------------------------------------------------------
[ { availableDocks: 12,
totalDocks: 15,
city: '',
altitude: '',
stAddress2: '',
longitude: -77.079382,
lastCommunicationTime: '2018-08-15 04:16:15 PM',
postalCode: '',
statusValue: 'In Service',
testStation: false,
stAddress1: 'Tenleytown / Wisconsin Ave & Albemarle St NW',
stationName: 'Tenleytown / Wisconsin Ave & Albemarle St NW',
landMark: '',
latitude: 38.947607,
statusKey: 1,
availableBikes: 1,
id: 80,
location: '' } ]