Skip to content

Publish an event source to your cluster

  1. Start a minikube cluster:

    minikube start
    
  2. Setup ko to use the minikube docker instance and local registry:

    eval $(minikube docker-env)
    export KO_DOCKER_REPO=ko.local
    
  3. Apply the CRD and configuration YAML:

    ko apply -f config
    
  4. 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.

    apiVersion: serving.knative.dev/v1
    kind: Service
    metadata:
      name: event-display
      namespace: knative-samples
    spec:
      template:
        spec:
          containers:
            - image: gcr.io/knative-releases/knative.dev/eventing/cmd/event_display
    ---
    apiVersion: samples.knative.dev/v1alpha1
    kind: SampleSource
    metadata:
      name: sample-source
      namespace: knative-samples
    spec:
      interval: "10s"
      sink:
        ref:
          apiVersion: serving.knative.dev/v1
          kind: Service
          name: event-display
    
    ko apply -f example.yaml
    
  5. Once reconciled, you can confirm the ksvc is outputting valid cloudevents every 10s to align with our specified interval.

    % kubectl -n knative-samples logs -l serving.knative.dev/service=event-display -c user-container -f
    
    ☁️  cloudevents.Event
    Validation: valid
    Context Attributes,
      specversion: 1.0
      type: dev.knative.sample
      source: http://sample.knative.dev/heartbeat-source
      id: d4619592-363e-4a41-82d1-b1586c390e24
      time: 2019-12-17T01:31:10.795588888Z
      datacontenttype: application/json
    Data,
      {
        "Sequence": 0,
        "Heartbeat": "10s"
      }
    ☁️  cloudevents.Event
    Validation: valid
    Context Attributes,
      specversion: 1.0
      type: dev.knative.sample
      source: http://sample.knative.dev/heartbeat-source
      id: db2edad0-06bc-4234-b9e1-7ea3955841d6
      time: 2019-12-17T01:31:20.825969504Z
      datacontenttype: application/json
    Data,
      {
        "Sequence": 1,
        "Heartbeat": "10s"
      }
    

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK