Configuring events to trigger a pipeline

Google Pub/Sub is a cloud service best described as a managed version of Kafka or Rabbit MQ. We will use Google Pub/Sub to deliver notifications when a change is detected in our container registry. Let's perform the following steps:

  1. Use the following gcloud command to create a Cloud Pub/Sub topic:
$ gcloud pubsub topics create projects/devopscookbook/topics/gcrgcloud pubsub topics create projects/devopscookbook/topics/gcr
Created topic [projects/devopscookbook/topics/gcrgcloud].
Created topic [projects/devopscookbook/topics/pubsub].
Created topic [projects/devopscookbook/topics/topics].
Created topic [projects/devopscookbook/topics/create].
Created topic [projects/devopscookbook/topics/gcr].
  1. Create a pubsub subscription. The following command should return a Created subscription message, similar to the following:
$ gcloud pubsub subscriptions create gcr-triggers --topic projects/devopscookbook/topics/gcr
Created subscription [projects/devopscookbook/subscriptions/gcr-triggers].
  1. Replace the following devopscookbook in both places with your project name and add permission to your CI/CD service account, that is, cicd-account:
$ gcloud pubsub subscriptions add-iam-policy-binding \
gcr-triggers --role roles/pubsub.subscriber \
--member serviceAccount:cicd-account@devopscookbook.iam.gserviceaccount.com

With that, you've learned how to configure events to trigger a pipeline.