Publishing to your Kubernetes cluster

Run the sample source locally

Start a minikube cluster.

If you already have a Kubernetes cluster running, you can skip this step. The cluster must be 1.15+

  1. minikube start

Setup ko to use the minikube docker instance and local registry

  1. eval $(minikube docker-env)
  2. export KO_DOCKER_REPO=ko.local

Apply the CRD and configuration yaml

  1. ko apply -f config

Once the sample-source-controller-manager is running in the knative-samples namespace, you can apply the example.yaml to connect our sample-source every 10s directly to a ksvc.

  1. apiVersion: serving.knative.dev/v1
  2. kind: Service
  3. metadata:
  4. name: event-display
  5. namespace: knative-samples
  6. spec:
  7. template:
  8. spec:
  9. containers:
  10. - image: gcr.io/knative-releases/knative.dev/eventing-contrib/cmd/event_display
  11. ---
  12. apiVersion: samples.knative.dev/v1alpha1
  13. kind: SampleSource
  14. metadata:
  15. name: sample-source
  16. namespace: knative-samples
  17. spec:
  18. interval: "10s"
  19. sink:
  20. ref:
  21. apiVersion: serving.knative.dev/v1
  22. kind: Service
  23. name: event-display
  1. ko apply -f example.yaml

Once reconciled, you can confirm the ksvc is outputting valid cloudevents every 10s to align with our specified interval.

  1. % k logs -n knative-samples event-display-zrjgm-deployment-84f6bfdfc6-2jc67 user-container -f
  1. ☁️ cloudevents.Event
  2. Validation: valid
  3. Context Attributes,
  4. specversion: 1.0
  5. type: dev.knative.sample
  6. source: http://sample.knative.dev/heartbeat-source
  7. id: d4619592-363e-4a41-82d1-b1586c390e24
  8. time: 2019-12-17T01:31:10.795588888Z
  9. datacontenttype: application/json
  10. Data,
  11. {
  12. "Sequence": 0,
  13. "Heartbeat": "10s"
  14. }
  15. ☁️ cloudevents.Event
  16. Validation: valid
  17. Context Attributes,
  18. specversion: 1.0
  19. type: dev.knative.sample
  20. source: http://sample.knative.dev/heartbeat-source
  21. id: db2edad0-06bc-4234-b9e1-7ea3955841d6
  22. time: 2019-12-17T01:31:20.825969504Z
  23. datacontenttype: application/json
  24. Data,
  25. {
  26. "Sequence": 1,
  27. "Heartbeat": "10s"
  28. }