Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 106 additions & 0 deletions docs/services/gcppubsub.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
# GCP Pub/Sub

## Parameters

This notification service is capable of sending messages to Google Cloud Pub/Sub topics.

* `project` - GCP project ID where the Pub/Sub topic is located.
* `topic` - name of the Pub/Sub topic you are intending to send messages to. Can be overridden with target destination annotation.
* `keyFile` - optional, path to GCP service account key file. If not provided, uses Application Default Credentials

## Example

### Using Service Account Key File

Resource Annotation:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.gcppubsub: "override-topic"
```

ConfigMap:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.gcppubsub: |
project: "my-gcp-project"
topic: "my-topic"
keyFile: "/var/secrets/gcp/key.json"

template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
gcppubsub:
attributes:
app: "{{.obj.metadata.name}}"
environment: "production"

trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
```

### Using Workload Identity (GKE)

When running on GKE with Workload Identity enabled, you can omit the `keyFile` parameter and the service will use the default credentials from the service account bound to the Kubernetes service account.

Resource Annotation:
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
annotations:
notifications.argoproj.io/subscribe.on-deployment-ready.gcppubsub: ""
```

ConfigMap:
```yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-notifications-cm
data:
service.gcppubsub: |
project: "my-gcp-project"
topic: "my-topic"

template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
gcppubsub:
attributes:
app: "{{.obj.metadata.name}}"
status: "{{.obj.status.conditions[0].type}}"

trigger.on-deployment-ready: |
- when: any(obj.status.conditions, {.type == 'Available' && .status == 'True'})
send: [deployment-ready]
- oncePer: obj.metadata.annotations["generation"]
```

## Message Attributes

Pub/Sub messages support custom attributes (key-value pairs) that can be used for filtering or routing. You can include attributes in your template:

```yaml
template.deployment-ready: |
message: |
Deployment {{.obj.metadata.name}} is ready!
gcppubsub:
attributes:
severity: "info"
app: "{{.obj.metadata.name}}"
namespace: "{{.obj.metadata.namespace}}"
timestamp: "{{(call .time.Now).Unix}}"
```

Attributes support template variables just like the message body, allowing you to dynamically populate metadata from the object being monitored.
26 changes: 17 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ module github.com/argoproj/notifications-engine
go 1.24.0

require (
cloud.google.com/go/pubsub v1.49.0
github.com/Masterminds/sprig/v3 v3.3.0
github.com/OvyFlash/telegram-bot-api v0.0.0-20241219171906-3f2ca0c14ada
github.com/PagerDuty/go-pagerduty v1.8.0
Expand Down Expand Up @@ -33,7 +34,7 @@ require (
go.yaml.in/yaml/v3 v3.0.4
golang.org/x/time v0.11.0
gomodules.xyz/notify v0.1.1
google.golang.org/api v0.223.0
google.golang.org/api v0.227.0
k8s.io/api v0.34.0
k8s.io/apimachinery v0.34.0
k8s.io/client-go v0.34.0
Expand All @@ -42,9 +43,11 @@ require (
)

require (
cloud.google.com/go v0.120.0 // indirect
cloud.google.com/go/auth v0.15.0 // indirect
cloud.google.com/go/auth/oauth2adapt v0.2.7 // indirect
cloud.google.com/go/compute/metadata v0.6.0 // indirect
cloud.google.com/go/iam v1.4.2 // indirect
dario.cat/mergo v1.0.1 // indirect
github.com/Masterminds/goutils v1.1.1 // indirect
github.com/Masterminds/semver/v3 v3.3.0 // indirect
Expand Down Expand Up @@ -75,7 +78,7 @@ require (
github.com/google/go-querystring v1.1.0 // indirect
github.com/google/go-tpm v0.9.5 // indirect
github.com/google/s2a-go v0.1.9 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.4 // indirect
github.com/googleapis/enterprise-certificate-proxy v0.3.6 // indirect
github.com/googleapis/gax-go/v2 v2.14.1 // indirect
github.com/gorilla/websocket v1.5.4-0.20250319132907-e064f32e3674 // indirect
github.com/hashicorp/go-cleanhttp v0.5.2 // indirect
Expand All @@ -102,22 +105,27 @@ require (
github.com/spf13/pflag v1.0.6 // indirect
github.com/stretchr/objx v0.5.2 // indirect
github.com/x448/float16 v0.8.4 // indirect
go.opencensus.io v0.24.0 // indirect
go.opentelemetry.io/auto/sdk v1.1.0 // indirect
go.opentelemetry.io/contrib/instrumentation/google.golang.org/grpc/otelgrpc v0.59.0 // indirect
go.opentelemetry.io/contrib/instrumentation/net/http/otelhttp v0.59.0 // indirect
go.opentelemetry.io/otel v1.34.0 // indirect
go.opentelemetry.io/otel/metric v1.34.0 // indirect
go.opentelemetry.io/otel/trace v1.34.0 // indirect
go.opentelemetry.io/otel v1.35.0 // indirect
go.opentelemetry.io/otel/metric v1.35.0 // indirect
go.opentelemetry.io/otel/trace v1.35.0 // indirect
go.yaml.in/yaml/v2 v2.4.2 // indirect
golang.org/x/crypto v0.38.0 // indirect
golang.org/x/net v0.38.0 // indirect
golang.org/x/oauth2 v0.27.0 // indirect
golang.org/x/oauth2 v0.28.0 // indirect
golang.org/x/sync v0.14.0 // indirect
golang.org/x/sys v0.33.0 // indirect
golang.org/x/term v0.32.0 // indirect
golang.org/x/text v0.25.0 // indirect
gomodules.xyz/envconfig v1.3.1-0.20190308184047-426f31af0d45 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250219182151-9fdb1cabc7b2 // indirect
google.golang.org/grpc v1.70.0 // indirect
google.golang.org/protobuf v1.36.5 // indirect
google.golang.org/genproto v0.0.0-20250303144028-a0af3efb3deb // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20250313205543-e70fdf4c4cb4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20250313205543-e70fdf4c4cb4 // indirect
google.golang.org/grpc v1.71.0 // indirect
google.golang.org/protobuf v1.36.6 // indirect
gopkg.in/alexcesaro/quotedprintable.v3 v3.0.0-20150716171945-2caba252f4dc // indirect
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/gomail.v2 v2.0.0-20160411212932-81ebce5c23df // indirect
Expand Down
Loading
Loading