Knative reference mapping

Flag name: kreference-mapping

Stage: Alpha, disabled by default

Tracking issue: #5593

Persona: Administrator, Developer

When enabled, this feature allows you to provide mappings from a Knative reference to a templated URI.

Note

Currently only PingSource supports this experimental feature.

For example, you can directly reference non-addressable resources anywhere that Knative Eventing accepts a reference, such as for a PingSource sink, or a Trigger subscriber.

Mappings are defined by a cluster administrator in the config-reference-mapping ConfigMap. The following example maps JobDefinition to a Job runner service:

  1. apiVersion: v1
  2. kind: ConfigMap
  3. metadata:
  4. name: config-kreference-mapping
  5. namespace: knative-eventing
  6. data:
  7. JobDefinition.v1.mygroup: "https://jobrunner.{{ .SystemNamespace }}.svc.cluster.local/{{ .Name }}"

The key must be of the form <Kind>.<version>.<group>. The value must resolved to a valid URI. Currently, the following template data are supported:

  • Name: The name of the referenced object
  • Namespace: The namespace of the referenced object
  • UID: The UID of the referenced object
  • SystemNamespace: The namespace of where Knative Eventing is installed

Given the above mapping, the following example shows how you can directly reference JobDefinition objects in a PingSource:

  1. apiVersion: sources.knative.dev/v1
  2. kind: PingSource
  3. metadata:
  4. name: trigger-job-every-minute
  5. spec:
  6. schedule: "*/1 * * * *"
  7. sink:
  8. ref:
  9. apiVersion: mygroup/v1
  10. kind: JobDefinition
  11. name: ajob