Google App Engine – Flexible


In the previous article, we have discussed what is google app engine and how to deploy the application in the Google app engine – Standard. In this tutorial, we are going to see how to Flex-app engine works. 

What is App Engine Flexible?


app engine datacloudies
Photo by Antoine Petitteville 
App engine flex offers a range of options to tweak kinds of stuff and customize the environment. We can choose any versions of runtime and then need to specify our own Docker files, which can take your own runtime and OS image that would need to use. 
Though it is far easier and more practical to do with the Kubernetes engine, app engine flex is suitable for having a single container in a managed deployment without having to set up a Kube cluster and use them in a multi-cloud environment.

How to deploy a python application to App Engine Flexi

Do check out the below video tutorial for the below steps as well.




1. Connect to a project
gcloud config set project project_id
2. create a directory and generate the application code. Let us use the sample app code downloaded from GCP Github
git clone https://github.com/GoogleCloudPlatform/python-docs-samples
3. install the dependencies like flask for this example. If you don’t have a virtual environment, install the same.
pip install virtualenv
app engine datacloudies
virtualenv env
app engine datacloudies
source env/bin/activate
app engine datacloudies
pip install –r requirement.txt
4. verify the application locally, by checking browser output
python main.py 
app engine datacloudies
Now, deploy the application to app engine flex,
gcloud app deploy
app engine datacloudies
5. verify the output by curling the app engine default domain.
app engine datacloudies
6. Schedule the task using the cron.YAML file. The below example, shows how to schedule the job run every day. 
cron:

- description: "daily summary job"

  url: /tasks/summary
  schedule: every 24 hours
- description: "monday morning mailout"
  url: /mail/weekly
  schedule: every monday 09:00
  timezone: Australia/NSW
- description: "new daily summary job"
  url: /tasks/summary
  schedule: every 24 hours
  target: beta

gcloud app deploy cron.yaml
app engine datacloudies
Refer to this link for more details with regards to cron job scheduling. 

Recent Posts