Skip to content
This repository has been archived by the owner on Sep 29, 2023. It is now read-only.

gcloud 1x1

Jan Max Meyer edited this page Aug 30, 2018 · 10 revisions

This is a short wiki page about gcloud SDK handling with ViUR applications.

Installation

To install Google Cloud SDK, follow the instructions at https://cloud.google.com/sdk/. After installation, do

gcloud components install app-engine-python app-engine-python-extras cloud-datastore-emulator

To make the older "Python SDK for Google App Engine" available, modify your .bashrc (or other shell resource script) and add the following lines:

####################
# Google Cloud SDK #
####################

GCLOUDSDKPATH="/opt/google-cloud-sdk" # or wherever you've installed it to...

# The next line updates PATH for the Google Cloud SDK.
if [ -f "$GCLOUDSDKPATH/path.bash.inc" ]
then
        source "$GCLOUDSDKPATH/path.bash.inc"
fi

# The next line enables shell command completion for gcloud.
if [ -f "$GCLOUDSDKPATH/completion.bash.inc" ]
then
        source "$GCLOUDSDKPATH/completion.bash.inc"
fi

# The next line adds the original AppEngine Python SDK to the PATH
export PATH="$GCLOUDSDKPATH/platform/google_appengine:$PATH"

Project maintenance

Initialization

This is only done once for a new App Engine project. The project needs to be created here first before gcloud app create can be invoked.

gcloud app create --project=myproject-viur

Then, deploy the indexes and cron settings with

gcloud app deploy -q --project=myproject-viur index.yaml
gcloud app deploy -q --project=myproject-viur cron.yaml

Deployment

Deployment is done using gcloud app deploy.

Basic deployment of the application

This is usually done in the deploy/ or appengine/ folder of the ViUR project.

gcloud app deploy --project=myproject-viur --no-promote

Automatically deploys to a new version without promotion.

Shortcuts

Some shortcuts for easier handling. They do not ask for confirmation and provide an automatic version naming schema.

Deploy to development version named after username and postfixed "-dev":

gcloud app deploy --no-promote -q --project=myproject-viur --version=$USER-dev

Deploy to live version named after date and username, and promote it. Use this carefully!

gcloud app deploy -q --project=myproject-viur --version=`date +"%Y-%m-%d"-$USER`

Datastore

Rebuild datastore indexes

Completely rebuild datastore indexes, according to index.yaml:

gcloud datastore cleanup-indexes -q --project=myproject-viur index.yaml

Thats it for now! ;-)