Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I deploy new service to the existing app in Google App Engine?

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?

like image 395
tank Avatar asked Sep 22 '19 20:09

tank


People also ask

How do I deploy Docker in Google App Engine?

Deploy to App Engine flexible environment You can deploy an image hosted by Artifact Registry to App Engine using the Google Cloud CLI. Create the App Engine configuration file for your app. Build a Docker image and push it to your repository. You can use Cloud Build to build and push your container to the repository.


Video Answer


2 Answers

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:

  • Configuration Files:

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

  • Can a default service/module in a Google App Engine app be a sibling of a non-default one in terms of folder structure?)
like image 191
Dan Cornilescu Avatar answered Sep 22 '22 20:09

Dan Cornilescu


Start with @Dan's answer, and follow this:

  • you will imperatively need to name your services inside of each .yaml file, using directive service: service_name

Example, for PHP, but also works for other languages: Documentation. Look for "service" element.

Deployment is conducted as this: (example given for Windows, hence the backslashes)

app_leveldir> gcloud app deploy dir1\service1.yaml dir2\service2.yaml [dirn\servicen.yaml]

Making sure that each <servicei>.yaml contains: service: myservice-name

Finally, note that each (microservice) will be available at URL: https://SERVICE-dot-PROJECT_ID.REGION_ID.r.appspot.com/

Knowing that there is one further granularity level, with versions: https://VERSION-dot-SERVICE-dot-PROJECT_ID.REGION_ID.r.appspot.com/

In the above URL, -dot- actually is that symbol, not a '.'

like image 45
Fabien Haddadi Avatar answered Sep 21 '22 20:09

Fabien Haddadi