Building Your Own Serverless Platform with Knative
Build a local Knative Serving and Eventing lab with kind, test activation, traffic splitting and event delivery.

On this page
A serverless platform is not a single controller. It is a collection of contracts between routing, scaling, workload execution and event delivery.
The preceding articles explained those contracts separately. This lab brings them together on a disposable kind cluster. The objective is not to build a production platform on a laptop. It is to observe what Kubernetes and Knative actually do when a service disappears, returns and receives traffic across multiple revisions.
This covers the last article in our Serverless Kubernetes series.
Lab architecture and prerequisites

Use a Linux or macOS workstation with Docker, kind, kubectl and curl. Allocate sufficient Docker resources (a starting point is 4 CPUs and 8 GiB RAM). Internet access is required for images and manifests. The cluster uses a conventional worker runtime; no Virtual Kubelet or nested virtualization is required.
The scripts below use explicit release tags supplied by the operator. Select mutually compatible Knative Serving, Eventing, Kourier and kind Kubernetes versions from upstream release documentation. The lab deliberately does not guess the latest compatible versions. Record your selected versions and image digests for reproducibility.
Create the cluster and install the platform
Save the following setup script as install.sh:
#!/usr/bin/env bash
set -euo pipefail
: "${KIND_NODE_IMAGE:?}" "${SERVING_VERSION:?}" "${EVENTING_VERSION:?}" "${KOURIER_VERSION:?}"
if kind get clusters | grep -qx knative-lab; then
echo "Cluster 'knative-lab' already exists. Delete it first or choose another name." >&2
exit 1
fi
cat <<EOF | kind create cluster --name knative-lab --image "$KIND_NODE_IMAGE" --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
kubectl config use-context kind-knative-lab
s=https://github.com/knative/serving/releases/download/$SERVING_VERSION
e=https://github.com/knative/eventing/releases/download/$EVENTING_VERSION
k=https://github.com/knative/net-kourier/releases/download/$KOURIER_VERSION
kubectl apply -f "$s/serving-crds.yaml"
kubectl apply -f "$s/serving-core.yaml"
kubectl apply -f "$k/kourier.yaml"
kubectl -n knative-serving patch configmap config-network --type merge \
-p '{"data":{"ingress-class":"kourier.ingress.networking.knative.dev"}}'
kubectl -n knative-serving patch configmap config-domain --type merge \
-p '{"data":{"127.0.0.1.sslip.io":""}}'
kubectl apply -f "$e/eventing-crds.yaml"
kubectl apply -f "$e/eventing-core.yaml"
kubectl -n knative-eventing wait --for=condition=Available deployment --all --timeout=300s
kubectl apply -f "$e/in-memory-channel.yaml"
kubectl apply -f "$e/mt-channel-broker.yaml"
for ns in knative-serving kourier-system knative-eventing; do
kubectl -n "$ns" wait --for=condition=Available deployment --all --timeout=300s
doneExport your verified release tags and run the installation script:
export KIND_NODE_IMAGE='kindest/node:<verified-tag>'
export SERVING_VERSION='knative-v<verified-version>'
export EVENTING_VERSION='knative-v<verified-version>'
export KOURIER_VERSION='knative-v<verified-version>'
bash install.shThe script installs Serving CRDs and core controllers, Kourier networking, Eventing CRDs and core controllers, and the in-memory channel plus multi-tenant channel-based Broker. The latter is for demonstration, not durable production delivery. It selects the Kourier ingress class and waits for controller deployments.
Verify the installation:
kubectl get pods -n knative-serving
kubectl get pods -n kourier-system
kubectl get pods -n knative-eventingDeploy a service and expose it locally
Save the initial Service manifest as service.yaml:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
spec:
template:
metadata:
name: hello-v1
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
env:
- name: TARGET
value: "version 1"
traffic:
- revisionName: hello-v1
percent: 100Apply the manifest, wait for readiness and forward the Kourier ingress port locally:
kubectl apply -f service.yaml
kubectl wait --for=condition=Ready ksvc/hello --timeout=180s
kubectl -n kourier-system port-forward svc/kourier 8080:80 >/dev/null 2>&1 &
PF_PID=$!Derive the external host from the Service URL (hello.default.127.0.0.1.sslip.io) and send a request:
URL=$(kubectl get ksvc hello -o jsonpath='{.status.url}')
HOST=${URL#*://}; HOST=${HOST%%/*}
curl -fsS -H "Host: $HOST" http://127.0.0.1:8080/The Host header matters because Kourier selects the Knative Route by hostname. Patching config-domain to 127.0.0.1.sslip.io gives the Service an external domain so Kourier’s external gateway accepts the request without requiring a cloud load balancer. The sample image is a demonstration image; confirm availability and pin a digest before relying on it.
Observe scale-to-zero and activation
Stop sending traffic and watch the application Pods:
kubectl get pods -l serving.knative.dev/service=hello -wWait until the Revision has no application Pods. The shared controllers and ingress remain running. Then measure a cold request followed immediately by a warm request:
curl -sS -o /dev/null -w 'cold: status=%{http_code} total=%{time_total}s\n' \
-H "Host: $HOST" http://127.0.0.1:8080/
curl -sS -o /dev/null -w 'warm: status=%{http_code} total=%{time_total}s\n' \
-H "Host: $HOST" http://127.0.0.1:8080/Repeat immediately for a warm request. Repeat the cold experiment several times, confirming zero before each trial. Record failures as well as successful timings. Image caching and local machine load affect the result. This is an observation exercise, not a published performance benchmark.
Separate deployment from release
The first manifest created the named Revision hello-v1. Save service-v2.yaml to create hello-v2 with a different response while keeping 100% of traffic on hello-v1:
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: hello
spec:
template:
metadata:
name: hello-v2
spec:
containers:
- image: ghcr.io/knative/helloworld-go:latest
env:
- name: TARGET
value: "version 2"
traffic:
- revisionName: hello-v1
percent: 100Deploy hello-v2 and wait for it to become Ready:
kubectl apply -f service-v2.yaml
kubectl wait --for=condition=Ready revision/hello-v2 --timeout=180sNow update spec.traffic to distribute 90% to hello-v1 and 10% to hello-v2. Patching .spec.traffic directly avoids re-submitting the immutable hello-v2 Revision template:
kubectl patch ksvc hello --type merge \
-p '{"spec":{"traffic":[{"revisionName":"hello-v1","percent":90},{"revisionName":"hello-v2","percent":10}]}}'
kubectl get revision,route
for i in $(seq 1 100); do
curl -fsS -H "Host: $HOST" http://127.0.0.1:8080/
done | sort | uniq -c
Expect an approximate distribution, not exact 90 and 10 counts. Roll back by patching spec.traffic back to 100% on hello-v1 without deleting hello-v2:
kubectl patch ksvc hello --type merge \
-p '{"spec":{"traffic":[{"revisionName":"hello-v1","percent":100}]}}'In production, gate this progression on error rates and latency, not merely Pod readiness.
Deliver an event to a serverless subscriber
Save the Broker, Trigger and subscriber manifests as eventing.yaml:
apiVersion: eventing.knative.dev/v1
kind: Broker
metadata:
name: orders
---
apiVersion: eventing.knative.dev/v1
kind: Trigger
metadata:
name: order-created
spec:
broker: orders
filter:
attributes:
type: com.example.order.created
subscriber:
ref:
apiVersion: serving.knative.dev/v1
kind: Service
name: event-display
---
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: event-display
spec:
template:
spec:
containers:
- image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_displaySave the event producer helper as send-event.sh:
#!/usr/bin/env bash
set -euo pipefail
BROKER=$(kubectl get broker orders -o jsonpath='{.status.address.url}')
kubectl run sender --rm -i --restart=Never --image=curlimages/curl -- \
-fsS -X POST "$BROKER" \
-H 'ce-specversion: 1.0' -H 'ce-id: order-001' \
-H 'ce-source: /demo/orders' \
-H 'ce-type: com.example.order.created' \
-H 'Content-Type: application/json' -d '{"orderId":"001"}'Apply eventing.yaml, wait for the Broker, Trigger and subscriber to become Ready, send the CloudEvent and inspect the subscriber logs:
kubectl apply -f eventing.yaml
kubectl wait --for=condition=Ready broker/orders --timeout=180s
kubectl wait --for=condition=Ready trigger/order-created --timeout=180s
kubectl wait --for=condition=Ready ksvc/event-display --timeout=180s
bash send-event.sh
kubectl logs -l serving.knative.dev/service=event-display -c user-container --tail=50The Trigger filters on com.example.order.created. Change the type in the sender to test non-matching events. Because the lab uses an in-memory channel, do not infer durability or production delivery guarantees from a successful test. A subscriber at zero may need to activate before processing the event.
What to measure
| Experiment | Observation | Interpretation |
|---|---|---|
| Idle service | Application Pods reach zero | Lifecycle policy works |
| First request | Latency and status | Activation cost |
| Warm request | Latency and status | Baseline request path |
| Traffic split | Response counts | Approximate revision routing |
| Matching event | Subscriber log | Event routing works |
| Non-matching event | No matching delivery | Trigger filter works |
If a Service never becomes Ready, inspect kubectl describe ksvc hello, its Revision, Pod events and controller logs. If ingress fails, verify the Host header and Kourier service. If the Broker fails, inspect its conditions and channel implementation. Do not debug all layers simultaneously.
From lab to production
Production requires TLS and DNS, identity and authorization, resource quotas, observability, durable event infrastructure, upgrade management and failure-domain planning. Define latency objectives and minimum scale policies per service. Pin images and validate compatibility in CI. The platform team still owns the shared components even when developers no longer manage individual Deployments.
Next time someone mentions serverless, you have the mental model to explain what is actually happening beneath the API: an ingress path that buffers or routes on demand, a control loop reconciling replicas against concurrency or queue depth, and immutable revisions separating deployment from release.
Those mechanics are arguably more relevant today than ever. Consider a modern platform where each specialized AI agent or tool execution sandbox is packaged as an isolated, on-demand service. Agents sit idle between user prompts, wake up in bursts when an orchestrator dispatches an event or tool call, hold open network connections while waiting on model inference, and disappear when the task finishes. Designing that kind of platform comes down to the exact trade-offs explored in this series: cold-start budgets, concurrency limits, event-driven triggers, and knowing which layer of the stack owns the lifecycle.


