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?
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.
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:
.yaml
file (which doesn't even have to be called app.yaml
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. Inservice1
andservice2
, the source files are at the same level as the YAML file. Inservice3
, there are YAML files for two versions.
Start with @Dan's answer, and follow this:
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 '.'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With