This guide explains how to set up GCP PubSub listener in order to allow Just In Time Rotation for GCP Secrets Manager.

How it Works

reloader will listen for audit log events from a given GCP PubSub, and, based on pattern matching, will trigger an ExternalSecret reconciliation if that object queries the GCP Secret Manager key that had its version updated. The diagram below gives an overview of the setup: Architecture Light Architecture Dark

Setting Up GCP

In order to set up GCP, four steps are needed:
  • Create a Topic and a Subscription on GCP Pub/Sub
  • Create a Log Router to send information from Audit Logs to PubSub
  • Create a Service Account & Permissions for reloader
  • Install reloader in your cluster
The following terraform code contains a recipe for everything needed within GCP using service account keys. We recommend using it with a local kind cluster for a quick onboarding experience - use workload identity in production environments.
The only action remaining is to install reloader within your cluster.
After all these steps - we are ready to install & use reloader

Example Configuration

Before applying this manifest, be sure to have installed reloader first.
apiVersion: reloader.external-secrets.io/v1alpha1
kind: Config
metadata:
  name: gcp-sample
spec:
  notificationSources:
    - type: GooglePubSub
      googlePubSub:
        subscriptionID: value-from-subscription-id
        projectID: value-from-project-id
        auth:
        # If using service account keys
          secretRef:
            secretAccessKeySecretRef:
              name: secret-name
              namespace: secret-namespace
              key: creds_json
        # If using Workload Identity
          workloadIdentity:
            clusterName: name-of-your-cluster-if-on-different-project
            clusterLocation: us-east1
            clusterProjectID: cluster-project-if-different
            serviceAccountRef:
              name: service-account-name
              namespace: service-account-namespace
  destinationsToWatch:
    - type: ExternalSecret
      externalSecret:
        labelSelectors:
          matchLabels:
            app: my-app
After that, every new AddSecretVersion message will automatically update your Kubernetes Secret values!