Skip to main content

Set Up a Pub/Sub Topic

Create a Pub/Sub topic and let applications publish to it or subscribe to it. The platform encrypts topics at rest with Google-managed keys.

Prerequisites​

  • An Application manifest for each publisher and subscriber.
  • The names of your organization, organizational-unit, environment and project.

Steps​

  1. Create the PubSub manifest.

    apiVersion: lowops.manifests.v1
    kind: PubSub
    metadata:
    name: order-events
    project: payment-gateway
    environment: production
    organizational-unit: retail-banking
    organization: fincorp
    spec:
    description: "Events emitted when an order is created, updated, or completed"
    messageRetentionDurationSeconds: 604800 # 7 days

    messageRetentionDurationSeconds sets how long the topic keeps messages that no subscriber acknowledged. The schema also has the fields encrypted and allowedPersistenceRegions. The engine does not apply them yet. See the PubSub reference.

  2. Grant access in the accessControl block of each application.

    # In the publisher Application:
    spec:
    accessControl:
    pubsub:
    publishTo: [order-events] # grants roles/pubsub.publisher

    # In the subscriber Application:
    spec:
    accessControl:
    pubsub:
    subscribeTo: [order-events] # grants roles/pubsub.subscriber

    One application can have both lists.

  3. Commit all manifests in one pull request and merge it.

Verify​

The run shows the topic as created. The platform restarts each application that has new permissions.

Next​