liveBook · Manning

Knative Service

As explained in Google Anthos in Action

A Knative Service is a resource that defines and manages a deployable serverless application, including its configuration, revisions, and traffic route.

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

How Google Anthos in Action covers it

How deep it goes
Defines Service, Configuration, Revision, and Route responsibilities, then demonstrates deployment and verification without detailing controller internals.
Examples
Uses a Hello World Python container, YAML manifests, kubectl resource inspection, generated URLs, curl requests, and weighted revision traffic.
What it assumes
Assumes a running Knative installation and a containerized application image, while demonstrating the Service manifest structure from the deployment step.
What you can do after
Builds and operates a deployment via kubectl, then verifies generated resources, obtains its URL, and tests the application over HTTP.
How it connects
Connects Kubernetes CRDs with Configuration, Revision, Route, Deployments, Services, VirtualServices, service meshes, and HorizontalPodAutoscaler.

Also explained in

Compare how 2 books explain Knative Service →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Google Anthos in Action. The section links point to the parts of the book it draws on.