Brad Downey
Brad Downey

Reputation: 1

Google Cloud Run (fully managed) - Can a container redirect to another container?

Background: Trying to run Vault in Google Cloud Run (fully managed) and trying to decide if setting up HA is possible. Vault requires a single active node (container), and inbound requests to a standby node (container) need to be forwarded or redirected.

Forwarded means a side connection on another port (i.e. clients on tcp/8200 and pod-to-pod on tcp/8201). Is this possible, I don't see anything about this in docs.

Redirected means that a standby node (container) would need to 307 redirect to the active node's address. This would either be the Cloud Run url or the pod specific url. If it was the Cloud Run url then the load balancer could just send it right back to the standby node (loop); not good. It would need to be the pod url. Would the Cloud Run "proxy" (not sure what to call it) be able to accept the client request but do an internal redirect from pod to pod to reach the active pod?

Upvotes: 0

Views: 1242

Answers (1)

ahmet alp balkan
ahmet alp balkan

Reputation: 45214

It seems like you’re new to the programming and traffic serving model of Cloud Run. I recommend checking out documentation and https://github.com/ahmetb/cloud-run-faq for some answers.

Briefly answering some of your points:

  • only 1 port number can be exposed to the outside world from a container running on Cloud Run
  • Cloud Run apps are only accessible via HTTPS (includes gRPC) protocol over port :443.
  • you cannot ensure 2 running containers at a time on Cloud Run (that's not what it's designed for, that's something Kubernetes or VMs are more suitable for).
  • Cloud Run is, by definition, for running stateless HA apps
  • there's no such thing as "pod URL" in Cloud Run. multiple replicas of an app will have the same address.
  • as you said, Cloud Run cannot distinguish multiple instances of the same app. if a container forwards a request to its own URL, it might end up getting the request again.

Your best bet is to deploy these two containers as separate applications to Cloud Run, so they have different URLs and different lifecycles. You can set "maximum instances" to 1 to ensure these VaultService1 and VaultService2 never get additional replicas.

Upvotes: 1

Related Questions