Skip to content

Serverless functions atop of cloud‐edge deployments

LaiRuiqi edited this page Oct 20, 2023 · 11 revisions

Quickstart Guide

This page introduces how to setup and deploy serverless functions to cloud-edge devices.

It supports setting up a Kubernetes cluster using kubeadm and then deploy OpenYurt and Knative on it. It is compatible with vHive stock-only mode.

Prerequisite

  1. The scripts has been tested on cloud-lab, suggested profile is: openyurt-demo, with one master node, one cloud worker node and one edge worker node
  2. Ensure that SSH authentication is possible from local device to all nodes.
  3. git clone https://github.com/vhive-serverless/vHive.git && git checkout origin/easy_oy
  4. cd vHive/scripts/openyurt_deployer && go build .
  5. Change the contents in conf.json to following format:
{
  "master": "{user}@{master-node-ip}",
  "workers": {
    "cloud": [
      "{user}@{cloud-node-ip}"
    ],
    "edge": [
      "{user}@{edge-node-ip}"
    ]
  }
}

Infrastructure Setup

./openyurt_deployer deploy # deploy openyurt on the cluster 

If it gives out error like:

FATA[0001] Failed to connect to: username@host

Please execute:

eval `ssh-agent -s` && ssh-add ~/.ssh/<your private key>

For example:

eval `ssh-agent -s` && ssh-add ~/.ssh/id_rsa

And try again

Example Deployment

Deploy functions on cloud or edge nodes

The demo would deploy a helloworld function to cloud node pool or edge node pool

Deploy the demo:

./openyurt_deployer demo-c

or:

./openyurt_deployer demo-e

where demo-c would deploy the service to the cloud node pool and demo-e would deploy the service to the edge node pool.

The demo code will also show information about node pool after deployment. The deployment name for demo-c would be helloworld-cloud, while the name for demo-e would be helloworld-edge It will also show the services' URL so you can try to invoke it on the master node.

You can check the nodepool information simply by:

./openyurt_deployer demo-print

Or:

kubectl get np

Or delete the services deployed on nodepool by:

./openyurt_deployer demo-clear

Invoke the functions

You can try to invoke the services created by demo-c or demo-e on master node. First, ssh to master node, following commands should all be executed on master node.

ssh <master-user>@<master-ip>
git clone https://github.com/vhive-serverless/vSwarm.git
cd vSwarm/tools/test-client && go build .
./test-client --addr $URL:80 --name "Hello there"

Here $URL should be the URL returned in the previous part when deploying cloud and edge services, you can also get it from: kubectl get ksvc, but discarding the http:// at the beginning.

After invoking, you can use kubectl get pods -o wide to check whether the pods have been auto-scaled.