4
votes

I want to create and deploy a new service to the existing app in App-engine in Google Cloud Platform.

The app can be accessed by URL test.appspot.com

I want to create a new service with a simple web page that can be accessed using URL my-service.test.appspot.com in the app-engine.

I know I need to create the app.yaml and deploy it, but I am not sure if I need to use the existing app.yaml which was already deployed previously or I can create a new app.yaml with a new service name and deploy it.

Will deploying with new app.yaml overwrite the app and existing services or just create my new service in the App-engine?

What are the steps I need to follow to deploy new service to existing app in App-engine?

2

2 Answers

8
votes

While it might be possible to use the existing app.yaml to deploy a new service by specifying different deployment command arguments, I wouldn't recommend it as it's IMHO too brittle, you'd risk affecting of the existing app (technically the default service of your existing single-service app). It's also rather unlikely you want to deploy the exact same code in the new service (the code being deployed is the one from the directory where the .yaml file exists).

I'd highly recommend (re-)structuring your app taking your services into account:

  • the app's top level directory contains app-level config files, not service-level files
  • each service has its own sub-directory under the app's top level dir, each with its own code and .yaml file (which doesn't even have to be called app.yaml
  • services would be deployed independently, each from its own sub-directory

Getting there from a single-service app directory is relatively simple: just create a sub-directory (for the default service) and move the existing app.yaml and the code into it, check that the functionality is unaffected and re-deploy from the new location. Then create sub-directories for additional services and their code.

See also:

Typically, you create a directory for each service, which contains the service's YAML files and associated source code. Optional application-level configuration files (dispatch.yaml, cron.yaml, index.yaml, and queue.yaml) are included in the top level app directory. The example below shows three services. In service1 and service2, the source files are at the same level as the YAML file. In service3, there are YAML files for two versions.

enter image description here

0
votes

Appengine is designed to think "microservice". Each service are isolated, thus each service has its own source code and configuration. By the way you can mix standard and flexible version, you can mix language, static and dymanics resources,...

By the way, deploy your microservices and use the dispatch to route the query to the right deployment.

However 1 advice: keep the services consistent. I mean, don't deploy 2 apps without relation between them, prefer to create 2 projects for these reasons:

  • If one app grow, you will be disturbed by a side services, with consequence:
    • The dispatch.yaml file is limited to 20 rules
    • A dedicated team could be affected to this app, role and authorization has to seperated in each app
  • In AppEngine standard, you have 28h of default instance (F1) free per day. Split your app for gaining more free quota!