21 Running serverless functions in Kubernetes
Welcome to the last full chapter of the book - we're going to finish on a high note, learning how to turn your Kubernetes cluster into a serverless platform. There are lots of serverless platforms in the cloud but they're mostly bespoke systems and you can't easily move your AWS Lambda components to Azure Functions. The extensibility of Kubernetes makes it easy to deploy a serverless runtime in the cluster, which is just as portable as all your other apps. We'll cover some open-source projects in this chapter which give you a very Lambda-like experience, where you focus on the code and the platform packages and deploys it for you. Serverless functions run as containers in Pods so you manage them in the usual way, but the platform adds some higher-level abstractions.
There are several serverless platforms in the Kubernetes ecosystem which all take slightly different approaches. One of the most popular is the Knative project from Google, but it has an unusual workflow - you need to package your functions in Docker images yourself, and then Knative deploys them for you. I much prefer the code-first approach where you bring your code and the platform runs it in a container; that fits the goal of a very simple workflow for serverless functions. In this chapter we'll use Kubeless, another popular platform, and we'll also see how to abstract the serverless platform itself with the Serverless project.