I am trying to deploy an java spring application on app engine with multiple versions. I am using docker images to deploy the app. I want to create a single app.yaml file in which I can define my both versions of the application and run them from a single file.
I am not able to understand how to write app.yaml for both version in a single file. Currently my yaml file looks like:
runtime: java
api_version: '1.0'
env: flexible
threadsafe: true
Now how to add the second version details in the same yaml and deploy both simultaneously.
I do not think that it's possible to do one gcloud app deploy and deploy 2 versions from the same app.yaml at the same time.
What I'm thinking you can do to solve what you need is to attempt to do 2 gcloud deploy with different $ENV_VARIABLES that have your version names. All of this within the docker image so you can automate it. After that you can also split the traffic between them 2 and achieve what I think you are looking for.
It would be something like this inside your docker image:
RUN gcloud app deploy -v $ENV_VAR && gcloud app deploy -v $ENV_VAR2 --no-promote
RUN gcloud app services set-traffic [SERVICE] --splits:$ENV_VAR1:.5, $ENV_VAR2:.5
More information how to set-traffic between versions.
Hope this helps.