Knative: Operator’s Handbook

Pod Labels/Annotations

If you need to set Kubernetes labels and annotations on the Pods and Deployments created by Knative, configure KService’s spec.template.metadata field.

apiVersion: serving.knative.dev/v1alpha1
kind: Service
metadata:
  name: hello
spec:
  template:
    metadata:
      labels:
        test-label: "test-value"
      annotations:
        test-annotation: "test-value"
    spec:
      containers:
      - image: gcr.io/google-samples/hello-app:1.0

Default labels

When Knative deploys a Pod, by default it assigns certain Kubernetes labels to it. Most notably: