Built on the Kaniko/Knative approach of building a runtime environment for injecting a C/C++ based serverless function so that it could be loaded into a Knative enabled Kubernetes Environment.
Take a look at the example-dump directory for a sample "hello world" style application that can provide some http connection details. The only file that would need to be modified is app.c
.
The example directory is setup to use docker to perform the build, however the header files in runtime/httpstatus.h and runtime/knativeruntime.h can be used. To build using make on the local system, the knativeruntime.a
will need to be built and copied into the service directory.
The example service can be deployed in a Kubernetes cluster running Knative and Tekton pipeline.
The sample serverless.yaml
file references a Kubernetes base docker registry by default, but this can be changed to reflect the user's preferred registry.
The service can be deployed using the Triggermesh CLI as:
$ cd knative-c-runtime/example-dump && tm deploy
Uploading "." to dump-service-dump-function-mxx7j-pod-e74534
Waiting for taskrun "dump-service-dump-function-mxx7j" ready state
Deployment started. Run "tm -n default describe service dump-service-dump-function" to see details
The initial build process will take several minutes to complete, and will help to
monitor the progress of the service using tm get service
.
The build can be done using docker, or it can be built using make.
The Knative C Runtime is dependent upon libhttp. Clone the repo, and use the master branch to build the libhttp.a. Note that this may require applying a patch to build successfully. From the root of the libhttp source directory, copy the lib/libhttp.a
file and include/libhttp.h
file, and place it in the runtime directory. Then build the runtime library using make
.
- Add a malloc/free library to track per-request allocations to prevent leaks in a thread-safe manner