Installation
This document describes how to install Function Mesh based on your application in Kubernetes and how to start Function Mesh Worker service in case you want to use the pulsar-admin
CLI tool to manage Pulsar Functions and connectors.
Install Function Mesh
This section describes how to install Function Mesh through the install.sh
script or through the Helm.
Prerequisites
Before installing Function Mesh, ensure to perform the following operations.
- Kubernetes server v1.16 - v1.21.
- Create and connect to a Kubernetes cluster.
- Create a Pulsar cluster in the Kubernetes cluster.
- Deploy Pulsar Functions.
- (Optional) enable Role-based Access Control (RBAC).
Install Function Mesh through install.sh
script
This example shows how to use the install.sh
command to install Function Mesh on your laptop (Linux or Mac OS), including a local kind cluster, all the Custom Resource Definitions (CRDs), required service account configuration, and Function Mesh components.
curl -sSL https://github.com/streamnative/function-mesh/releases/download/v0.1.9/install.sh | bash
After executing the above command, you should be able to see the output indicating that the Function Mesh pod is up and running. For details, see verify installation.
Note
The
install.sh
command is suitable for trying Function Mesh out. If you want to deploy Function Mesh in production or other mission-critical scenarios, it is recommended to install Function Mesh through Helm.
Install Function Mesh through Helm
This example shows how to install Function Mesh through Helm.
Note
- Before installation, ensure that Helm v3 is installed properly.
- For the use of
kubectl
commands, see kubectl command reference.
Clone the StreamNative Function Mesh repository.
git clone https://github.com/streamnative/function-mesh.git
cd function-meshCreate the custom resource type.
curl -sSL https://github.com/streamnative/function-mesh/releases/download/v0.1.9/crd.yaml | kubectl create -f -
Install the Function Mesh Operator.
Create a Kubernetes namespace
function-mesh
. If no Kubernetes namespace is specified, thedefault
namespace is used.kubectl create ns function-mesh
Install Function Mesh Operator.
helm install function-mesh --values charts/function-mesh-operator/values.yaml charts/function-mesh-operator --namespace=function-mesh
Check whether Function Mesh is installed successfully.
kubectl get pods -l app.kubernetes.io/component=controller-manager
Output
NAME READY STATUS RESTARTS AGE
function-mesh-controller-manager-696f6467c9-mbstr 1/1 Running 0 77s
Verify installation
This example shows how to verify whether Function Mesh is installed successfully.
kubectl get pods -l app.kubernetes.io/component=controller-manager
Output
NAME READY STATUS RESTARTS AGE
function-mesh-controller-manager-696f6467c9-mbstr 1/1 Running 0 77sThis example shows how to verify whether Function Mesh can run properly.
After installing the Function Mesh Operator and deploying a Pulsar cluster, you can submit a sample CRD to create Pulsar Functions, source, sink, or Function Mesh. In this example, a CRD is submitted to the Pulsar cluster for creating a Pulsar Function. You can also submit other CRDs under the
./config/samples
directory.Submit a sample CRD to the Pulsar cluster.
kubectl apply -f config/samples/compute_v1alpha1_function.yaml
Verify your submission with the
kubectl
command, and you can see that the Function pod is running.kubectl get all
NAME READY STATUS RESTARTS AGE
pod/function-sample-0 1/1 Running 0 77s
Uninstall Function Mesh
Use the following command to uninstall Function Mesh through Helm.
helm delete function-mesh
Work with pulsar-admin
CLI tool
Function Mesh supports Function Mesh Worker service, which can forward requests to the Kubernetes cluster. After Function Mesh Worker service is started, users can use the pulsar-admin
CLI tool to manage Pulsar Functions and connectors.
Limitations
- Function Mesh Worker service is only available for Pulsar 2.8.0 or higher.
- The Function Mesh Worker service cannot manage the FunctionMesh CRD.
- You need to configure the
clusterName
,inputTypeClassName
,outputTypeClassName
parameters through thecustom-runtime-options
option when creating or updating Pulsar Functions or connectors.- You need to manually manage the
ConfigMap
, such as the Pulsar service URL.
To start Function Mesh Worker service, follow these steps.
Add the following Function Mesh Worker service configuration to your
functions_worker.yml
configuration file.functionsWorkerServiceNarPackage: /YOUR-NAR-PATH/function-mesh-worker-service-{version}.nar
Replace the
YOUR-NAR-PATH
variable with your real local path.Start Pulsar.
This example shows how to start Pulsar through Helm.
helm install \
--values examples/values-minikube.yaml \
--set initialize=true \
--namespace pulsar \
pulsar-mini apache/pulsarStart Function Mesh Operator.
helm install function-mesh --values charts/function-mesh-operator/values.yaml charts/function-mesh-operator --namespace=function-mesh
Verify whether the Function Mesh Worker service is started successfully.
./bin/pulsar-admin --admin-url WEB_SERVICE_URL functions status --tenant TENANT_NAME --namespace NAMESPACE_NAME --name FUNCTION_NAME
You should see a similar output as below.
Output
{
"numInstances" : 1,
"numRunning" : 1,
"instances" : [ {
"instanceId" : 0,
"status" : {
"running" : true,
"error" : "",
"numRestarts" : 0,
"numReceived" : 0,
"numSuccessfullyProcessed" : 0,
"numUserExceptions" : 0,
"latestUserExceptions" : [ ],
"numSystemExceptions" : 0,
"latestSystemExceptions" : [ ],
"averageLatency" : 0.0,
"lastInvocationTime" : 0,
"workerId" : ""
}
} ]
}