Kubernetes cluster as pubsub push subscriber

8/10/2018

If I want a Google Cloud Kubernetes cluster to act as a subscriber for a pubsub push notification, what is the best way to actually receive the notification on a node?

I assume I need to specify a load balancer as the end point for the subscription, but could\should I use nginx on each pod to receive the messages? Or something else?

Any patterns or examples available?

-- rossco
google-cloud-platform
google-cloud-pubsub
google-kubernetes-engine
kubernetes

1 Answer

8/23/2018

If you're referring to Cloud Pub/Sub, you can't have your application get a HTTP request when there's a new message on a Cloud Pub/Sub topic. That's simply not how Cloud Pub/Sub works.

Your application needs to listen to the messages using Cloud Pub/Sub API client.

There's a sample Pub/Sub application on GKE here: https://cloud.google.com/kubernetes-engine/docs/tutorials/authenticating-to-cloud-platform But it will not expose a load balancer and get the messages via an Ingress as you wanted.


By "pubsub", if you are referring to general "publish-subscribe pattern" in general, you can just create a multi-replica application, put them behind a load balancer (or Ingress), and have the message queue call your endpoint when there's a message.

But I'm not sure why this is a question in the first place, as I just described a simple load balanced app.

-- AhmetB - Google
Source: StackOverflow