This documentation is for the Latest version of Cloud Run for Anthos, which uses Anthos fleets and Anthos Service Mesh. Learn more.

The past version has been archived but the documentation remains available for existing users.

Configuring Events for Cloud Run for Anthos

Stay organized with collections Save and categorize content based on your preferences.

Learn how to enable and configure Events for Cloud Run for Anthos, including creating an event broker that can route messages from an event source to a receiver, such as a service in Cloud Run for Anthos.

Creating a GKE cluster with Cloud Run enabled

You must have Cloud Run for Anthos enabled in your cluster before you can get started with Events for Cloud Run for Anthos.

  1. Set up the Google Cloud CLI

  2. Create a GKE cluster with Cloud Run for Anthos enabled

  3. Configure the Google Cloud CLI to use your GKE cluster

Initializing Events for Cloud Run for Anthos

To initialize Events for Cloud Run for Anthos:

  1. Install the Google Cloud CLI beta components:

    gcloud components install beta
    
  2. Enable services used in this tutorial:

    gcloud services enable cloudapis.googleapis.com
    
  3. Initialize Events for Cloud Run for Anthos using the gcloud command-line tool:

    gcloud beta events init
    

    This creates pods in the cloud-run-events and knative-eventing namespaces.

  4. Optional: Ensure that both pods are created:

    To check pods in the cloud-run-events namespace, run:

    kubectl get pods -n cloud-run-events
    

    The output is similar to the following:

    NAME                         READY   STATUS    RESTARTS   AGE
    controller-9cc679b67-2952n   1/1     Running   0          22s
    webhook-8576c4cfcb-dhz82     1/1     Running   0          16m
    

    To check pods in the knative-eventing namespace, run:

    kubectl get pods -n knative-eventing
    

    The output is similar to the following:

    NAME                                   READY   STATUS    RESTARTS   AGE
    eventing-controller-77f46f6cf8-kj9ck   1/1     Running   0          17m
    eventing-webhook-5bc787965f-hcmwg      1/1     Running   0          17m
    

Creating an event broker

You create an event broker to handle routing events from your event sources to the event consumer, for example a destination service.

To create a broker:

  1. Create a namespace:

    kubectl create namespace NAMESPACE
    
  2. Initialize the namespace with the default secret:

    gcloud beta events namespaces init NAMESPACE \
      --copy-default-secret
    
  3. Create the event broker:

    gcloud beta events brokers create default \
      --namespace NAMESPACE
    
  4. Optional: Run the following command to ensure that the event broker is running:

    kubectl get brokers \
      -n NAMESPACE
    

    where NAMESPACE is the same namespace as your events broker.

    The output is similar to the following:

    NAME      READY   REASON   URL
    default   True             http://default-brokercell-ingress.cloud-run-events.svc.cluster.local/default/default