Using ContainerSource with OpenShift Service Mesh
Prerequisites
- 
You have followed the setup Service Mesh with OpenShift Serverless procedure 
Procedure
- 
Create a Servicein a namespace that is member of theServiceMeshMemberRoll:apiVersion: serving.knative.dev/v1 kind: Service metadata: name: event-display namespace: <namespace> (1) spec: template: metadata: annotations: sidecar.istio.io/inject: "true" (2) sidecar.istio.io/rewriteAppHTTPProbers: "true" spec: containers: - image: quay.io/openshift-knative/knative-eventing-sources-event-display:latest1 A namespace that is member of the ServiceMeshMemberRoll.2 Injects Service Mesh sidecars into the Knative service pods. 
- 
Apply the Serviceresource:$ oc apply -f <filename>
- 
Create a ContainerSourcein a namespace that is member of theServiceMeshMemberRolland sink set to theevent-display:apiVersion: sources.knative.dev/v1 kind: ContainerSource metadata: name: test-heartbeats namespace: <namespace> (1) spec: template: metadata: (2) annotations: sidecar.istio.io/inject": "true" sidecar.istio.io/rewriteAppHTTPProbers: "true" spec: containers: # This corresponds to a heartbeats image URI that you have built and published - image: quay.io/openshift-knative/heartbeats name: heartbeats args: - --period=1s env: - name: POD_NAME value: "example-pod" - name: POD_NAMESPACE value: "event-test" sink: ref: apiVersion: serving.knative.dev/v1 kind: Service name: event-display-service1 A namespace that is part of the ServiceMeshMemberRoll.2 Enables Service Mesh integration with a ContainerSource
- 
Apply the ContainerSourceresource:$ oc apply -f <filename>
Verification
You can verify that the events were sent to the Knative event sink by looking at the message dumper function logs.
- 
Enter the command: $ oc get pods
- 
Enter the command: $ oc logs $(oc get pod -o name | grep event-display) -c user-containerExample output☁️ cloudevents.Event Validation: valid Context Attributes, specversion: 1.0 type: dev.knative.eventing.samples.heartbeat source: https://knative.dev/eventing-contrib/cmd/heartbeats/#event-test/mypod id: 2b72d7bf-c38f-4a98-a433-608fbcdd2596 time: 2019-10-18T15:23:20.809775386Z contenttype: application/json Extensions, beats: true heart: yes the: 42 Data, { "id": 1, "label": "" }