Search code examples
google-cloud-platformkeycloakgoogle-cloud-run

Run Keycloak with GoogleCloud Run


I am currently running keycloak with kubernetes with no problems. everything works as expected but I would like to switch to cloud run(fully managed) and for now keycloak is giving me some problems:

I noticed that in cloud run you cannot connect trough tcp to the mysql database(google sql 2nd generation), but I did not find any documentation on how to set up keycloak to use socket connection. Is this currently possible with keycloak?


Solution

  • You should probably ask on Keycloak's community forum about how it can be configured to use a local Unix domain socket to connect to MySQL.

    It's also worth noting that certain kinds of applications are suitable for Cloud Run, and you should evaluate if Keycloak fits these requirements:

    • HTTP-based traffic (HTTP1/2, gRPC etc), other sorts of traffic (e.g. arbitrary TCP, UDP) will not work.
    • No sidecar containers (Kubernetes supports this, but Cloud Run does not)
    • Stateless application: Cloud Run will scale your app to multiple instances, or kill it due to inactivity (no incoming requests), Keycloak must be tolerant to this.
    • No background processing: Application container is suspended when there are no HTTP requests are being processed. If Keycloak relies on a container running at all times in the background, it won't work.
    • Local disk space is counted towards memory. Keycloak claims it needs at least 1G disk space. On Cloud Run, files written to disk count towards your container’s memory (RAM) limit, so if Keycloak uses a lot of disk, it can crash your container.