Serverless Architecture
Serverless relies heavily on Kubernetes resources. It uses Deployments, Services and HorizontalPodAutoscalers to deploy and manage Functions, and Kubernetes Jobs to create Docker images. See how these and other resources process a Function within a Kyma cluster:
CAUTION: Serverless imposes some requirements on the setup of Namespaces. For example, if you create a new Namespace you have to enable sidecar injection in it, as Serverless needs Istio for other resources to communicate with Functions correctly. Also, if you apply custom LimitRanges for a new Namespace, they must be higher than or equal to the limits for building Jobs' resources.
NOTE: To enable Istio sidecar proxy injection, which is disabled on the Kyma clusters by default, set the istio-injection=enabled
flag at the Namespace level.
Create a Function either through the UI or by applying a Function custom resource (CR). This CR contains the Function definition (business logic that you want to execute) and information on the environment on which it should run.
Before the Function can be saved or modified, it is first updated and then verified by the defaulting and validation webhooks respectively.
Function Controller (FC) detects the new, validated Function CR.
FC creates a ConfigMap with the Function definition.
Based on the ConfigMap, FC creates a Kubernetes Job that triggers the creation of a Function image.
The Job creates a Pod which builds the production Docker image based on the Function's definition. The Job then pushes this image to a Docker registry.
FC monitors the Job status. When the image creation finishes successfully, FC creates a Deployment that uses the newly built image.
FC creates a Service that points to the Deployment.
FC creates a HorizontalPodAutoscaler that automatically scales the number of Pods in the Deployment based on the observed CPU utilization.
FC waits for the Deployment to become ready.