A Knative Service is a Kubernetes custom resource for deploying a containerized serverless workload and managing its complete serving lifecycle. One resource combines workload deployment with traffic management, while Knative creates the required Kubernetes and service-mesh resources. section 9.3.1 section 9.3.2
A Knative Service coordinates several responsibilities:
- Defines the container version and desired application configuration. section 9.3.2
- Creates a new Revision when the service configuration changes. section 9.3.2
- Uses immutable Revisions to represent the container version and configuration actually served. section 9.3.2
- Routes requests to one or more Revisions and supports traffic splitting between versions. section 9.3.2
- Replaces direct management of Deployments, native Services, VirtualServices, and related autoscaling resources for the workload. section 9.3.1 section 9.3.2
Deploy and test a Python service
With a containerized Python application available in Docker Hub, apply a manifest containing a serving.knative.dev/v1 Service, container image, and TARGET environment variable. Inspect the generated Pod, Service, Configuration, Revision, and Route resources with kubectl, retrieve the assigned URL, and test it with curl. A successful request returns “Hello Python Sample v1!”. section 9.3.6
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
name: helloworld
namespace: default
spec:
template:
spec:
containers:
- image: docker.io/{username}/helloworld
env:
- name: TARGET
value: "Python Sample v1"
Use the manifest example to see the Knative API version, resource kind, metadata, container image, and environment configuration. section 9.3.2
traffic: - tag: current revisionName: helloworld-v1 percent: 95% - tag: candidate revisionName: helloworld-v2 percent: 5% - tag: latest latestRevision: true percent: 0
Use the traffic example to inspect weighted routing, revision tags, and a latest-revision route with zero assigned traffic. section 9.3.2

