Knative Serving code samples

Use the following code samples to help you understand the various Knative Serving resources and how they can be applied across common use cases. Learn more about Knative Serving resources.

See all Knative code samples

NameDescriptionLanguages
Hello WorldA quick introduction that highlights how to deploy an app using Knative Serving.C#, Go, Java (Spark), Java (Spring), Kotlin, Node.js, PHP, Python, Ruby, Scala, Shell
Cloud EventsA quick introduction that highlights how to send and receive Cloud Events.C#, Go, Node.js, Rust, Java (Vert.x)
Advanced DeploymentSimple blue/green-like application deployment pattern illustrating the process of updating a live application without dropping any traffic.YAML
AutoscaleA demonstration of the autoscaling capabilities of Knative.Go
Github WebhookA simple webhook handler that demonstrates interacting with Github.Go
gRPCA simple gRPC server.Go
Knative RoutingAn example of mapping multiple Knative services to different paths under a single domain name using the Istio VirtualService concept.Go
Knative SecretsA simple app that demonstrates how to use a Kubernetes secret as a Volume in Knative.Go
REST APIA simple Restful service that exposes an endpoint defined by an environment variable described in the Knative Configuration.Go
TelemetryThis sample runs a simple web server that makes calls to other in-cluster services and responds to requests with “Hello World!”. The purpose of this sample is to show generating metrics, logs, and distributed traces.Go
Traffic SplittingThis samples builds off the Creating a RESTful Service sample to illustrate applying a revision, then using that revision for manual traffic splitting.YAML