I'm using cloud build to automatically deploy new version of app when a specific github branch is updated.
Everything works great but I'd like to deploy the new version without starting it, keeping my previous version running.
I really prefer to schedule start of the new version in specific hours, but when cloud build finish the process, my new version is automatically running.
How can I change this behaviour?
To avoid that the new version is started you can deploy using the --no-promote flag.
To use this flag when deploying using gcloud just need to add it to the command and deploy like this:
gcloud app deploy --no-promote
To implement this as part of the CD with Cloud Build then you can edit the cloudbuild.yaml to add the flag like this:
steps:
- name: 'gcr.io/cloud-builders/gcloud'
args: ['app', 'deploy', '--no-promote']
timeout: '1600s'
Related
There are many answers to this question already, but they no longer work here in January 2021. All those answers come in 3 flavors:
Set local machine timeout with something like gcloud config set app/cloud_build_timeout 1600 then deploy with gcloud app deploy ...
Use a cloudbuild.yaml file instead with timeout: 1600s bits in the gcloud app deploy buildstep and the global configuration, then deploy with gcloud builds submit ...
Per google's own docs, don't set timeout: 1600s in the cloudbuild file, but rather do a mashup of the previous 2 flavors with a build step including args: ['-c', 'gcloud config set app/cloud_build_timeout 1600 && gcloud app deploy']
None of them have any impact on the app deploy build - it's stuck at 10mins. When using gcloud builds submit, it results in 2 Cloud Builds being kicked off: one for the cloudbuild.yaml, and one for the app engine deployment using buildpack. The above solutions can impact the first build, but once that first build kicks off the second build (gcloud app deploy, you can see at https://console.cloud.google.com/cloud-build in the Execution Details tab that the Timeout is still 10m.
IMO, solutions 2-3 are hacks since 1 doesn't work, but now that 2-3 don't work either, I'm looking for another hack. Does anyone have a solution which works in 2021? Since my app is using GAE Standard Environment, I can't prebuild an image - I'm stuck with Buildpack building my ruby app and pulling all the Gems every time, and this runs out the seemingly immutable 10m clock.
You cannot change the timeout property in App Engine standard and it's always 10min. The workaround is to use App Engine flex and this way you can use the gcloud config set app/cloud_build_timeout TIME_SECONDS.
There is a feature request to enable timeout edit for App Engine standard but seems still in progress.
I'm building a custom image for App Engine Flexible with gcloud app deploy currently. I've played with using Kaniko to get caching working with gcloud builds submit for other projects, but is it possible to enable Kaniko for a build submitted with gcloud app deploy?
I've tried running gcloud config set builds/use_kaniko True, which doesn't seem to change the build behavior.
It seems like one option would be to build an image first via gcloud builds submit, then use gcloud app deploy --image-url=..., but I wasn't sure if there was a more streamlined way.
As you already said in your question, a good approach would be to first use Google Cloud Build to create your own image using your Dockerfile to then use it when deploying your application to Google App Engine.
In Google Cloud Container Builder you can run Kaniko by adding it as a build step in the build config:
steps:
- name: gcr.io/kaniko-project/executor:latest
args: ["--dockerfile=<path to Dockerfile>",
"--context=<path to build context>",
"--destination=<gcr.io/[PROJECT]/[IMAGE]:[TAG]>"]
More information can be found in these two blog posts about Google Cloud and kaniko. Post 1 & 2.
After that you can deploy your application by specifying the --image-url flag in the gcloud command:
gcloud app deploy --image-url=gcr.io/[PROJECT]/[IMAGE]:[TAG]
The documentation describes how to deploy endpoints application with gcloud tool but is it possible to deploy the app with appcfg.py?
What I'd like is to use this command:
appcfg.py update [YOUR_APP_DIR] -A [YOUR_PROJECT_ID] -V [YOUR_VERSION_ID]
And don't have to edit the app.yaml file to set a new value for ENDPOINTS_SERVICE_VERSION variable every time I need to deploy a new version.
If I understand correctly YOUR_VERSION_ID application version is not the same as ENDPOINTS_SERVICE_VERSION but where this difference is important?
I have gcloud installed and working and a service account gets also activated. I run the following and get a success(?):
$ gcloud auth activate-service-account "${GAE_CLIENT_ACCOUNT}" --key-file "${GAE_CLIENT_KEY_JSON_FILE}"
Activated service account credentials for: [xxxxx#developer.gserviceaccount.com]
Then I run this:
$ gcloud preview app deploy app.yaml --project "${GAE_PROJECT_ID}" --quiet --version "${GAE_PROJECT_VERSION}"
You are about to deploy the following modules:
- ricochet-robots/default/dev From: [/home/travis/build/ricochetrobots/ricochetrobots-landing/app.yaml]
Updating module [default]...Go to the following link in your browser:
https://accounts.google.com/o/oauth2/auth?scope=https%3A%2F%2Fwww.googleapis.com%2Fauth%2Fappengine.admin&redirect_uri=urn%3Aietf%3Awg%3Aoauth%3A2.0%3Aoob&response_type=code&client_id=xxxxxxxx.apps.googleusercontent.com&access_type=offline
Updating module [default].../
As you can see, it prompts me to follow the link and do an oauth. Because I'm on a ci server, it's not possible to follow the link.
How kan I suppress that? Or is there a totally diffrent way of deploying the app automatically.
This is a known issue in version 0.9.61.
For now, you can work around by pinning to a previous version:
gcloud config set component_manager/fixed_sdk_version 0.9.60
gcloud components update
Since you're running in a CI server, you can also set the following environment variable, if you run gcloud components update in your script. This may be an easier fix, depending on your CI server.
CLOUDSDK_COMPONENT_MANAGER_SNAPSHOT_URL=https://dl.google.com/dl/cloudsdk/release/components-v0.9.60.json
Running gcloud preview app deploy --set-default using a service account has the same issue in versions 0.9.57 through 0.9.62. If you'd like to use this command, you can pin to 0.9.56.
We're targeting a fix for version 0.9.63 or shortly thereafter. Follow the issue on the gcloud bug tracker for more updates.
EDIT: This issue was fixed in version 0.9.63.
I've recently started with Appengine and I'd been using the regular old deployment method using appcfg.py.
Now I want to start deployment using release pipelines. I created a pipeline in my Project settings, then authenticated myself in gcloud.
Now if I do gcloud init myproj-id, I should theoretically get the content of my project pulled from the server right? But that doesn't happen.
https://developers.google.com/cloud/sdk/gcloud/reference/init
If you have enabled push-to-deploy in the Cloud Console, one of the
things that gcloud init will do for you is cloning the Google-hosted
git repository associated with PROJECT
So, my questions:
Why is the content not pulled?
What happens if I push my project via git now? How would Appengine manage my previously deployed project via appcfg.py versus my git push'd project?
Why is the content not pulled?
Did you configure your repository by using the Configure your repository link at the top of the pipeline configuration page?
What happens if I push my project via git now? How would Appengine manage my previously deployed project via appcfg.py versus my git push'd project?
Unless you use different versions, App Engine won't make a difference; your git pushed project will overwrite your previous one.