Home > Back-end >  How to mix Cloud Run and App Engine deployments in one project?
How to mix Cloud Run and App Engine deployments in one project?

Time:12-11

I have a Quarkus application already deployed on Google Cloud Run. It depends on MySQL, hence there is an instance started on Cloud SQL.

Next step in my deployment process is to add keycloak. From what I've read the best option seems to be Google App Engine.

The approved answer in this question gave me some good insight of what needs to be done ... mostly. What I did was:

  • Locally I made a sub-directory in the main project.
  • In that directory I added the app.yaml and the Dockerfile (as described here for instance).
  • There I executed the said two commands: gcloud init and gcloud app deploy.

I had my doubts about this set up and they were backed up by the error I got eventually:

ERROR: (gcloud.app.deploy) INVALID_ARGUMENT: The first service (module) you upload to a new application must be the 'default' service (module). Please upload a version of the 'default' service (module) before uploading a version for the 'morph-keycloak-service' service (module). 

I understand my set up breaks the overall structure of the project but I'm not sure how to mix those two application with the right services. I understand keycloak is a stateful application, hence cannot live on Cloud Run (by the way the intention is for keycloak to use the same database instance shared with the application).

So does any one know a more sensible set up, or what can I move in mine in order to fix it?

CodePudding user response:

In short: The answer really is in reading the error message (thanks @gaefan) - about the error itself it explains enough. So I just commented out the service: my-keycloak-service line in the app.yaml (thus leaving gcloud to implicitly mark it as the default one) and the deployment continued.

Eventually keycloak didn't connect to the database but if I don't manage to adjust the configurations that would probably be a subject to a different question.

On the point of project structure and functionality:

First off, thanks @NoCommandLine and @guillaume-blaquiere for your input!

@NoCommandLine the application on Cloud Run is sort of a headless REST API enabled backend. Most of the API calls are secured by keycloack. A next step in the deployment process would be to port an existing UI (React) client on the Firebase hosting (or on another suitable service - I'm still not completely sure which approach is best) and in order for the users to work with this client properly they must make an SSO through keycloak first.

I'm quite new to GCP and the number and variants of the available options are still overwhelming to me - one must get familiar with the nuances but I guess it takes time. So I'm still taking suggestions on how to adjust my project structure to fit better the services stack. Thanks!

  • Related