Google PubSub. Communication From AppEngine to Kubernetes pod and from one Kubernetes pod to another Kubernetes pod

4/28/2020

How can I send and receive messages in those two cases?

We are migrating our app from appengine to kubernetes. We have two microservices distributed in this way:

Development environment

  • Service 1: Running on a Kubernetes pod (cluster named 1). It was running on AppEngine
  • Service 2:Running on a Kubernetes pod (cluster named 1). It was running on AppEngine

Problem is that Service 1 keeps sending pubsub messages to service 2 on AppEngine. It should send pubsub messages to service 2 running on Kubernetes

Production environment

  • Service 1: Running on AppEngine but soon it will be running on a Kubernetes pod (cluster named 1)
  • Service 2: Running on AppEngine but soon it will be running on a Kubernetes pod (cluster named 1)

In production environment, nowadays service 1 and 2 communicate via pubsub. Which (and in what order) is the best way to start migrating both services in production environment to Kubernetes pods?

I was thinking about moving both service 1 and 2 at the same time to Kubernetes and start using http rest to send and receives message between them (that would mean stop using Google PubSub) but I am not sure. Another problem I see is that Push endpoints require https and my external ip from my kubernetes service is http

-- pablofiumara
docker
google-app-engine
google-cloud-pubsub
kubernetes
kubernetes-pod

2 Answers

4/30/2020

The solution was:

1) To change pubsub subscription to pull type

2) Create service account credentials

3) Adapted service code (now running in Kubernetes) so that it actually pulls pubsub messages

-- pablofiumara
Source: StackOverflow

4/29/2020

PubSub messages are sent to a topic. Every listener to that topic (E.g. both GAE service 2 and k8s service 2) will receive the messages sent.

If you want to differentiate the messages based on the origin (GAE and k8s) the easiest way to create another topic. And only configure this new topic in the k8s services.

However, I don't see which could be the issue of sharing the pubsub topic if the services do the same.

-- Juancki
Source: StackOverflow