How do you config Google Cloud Platform for european server ? - google-app-engine

When I do google cloud platform tutorial to deploy a spring boot java web app
https://github.com/GoogleCloudPlatform/getting-started-java/tree/master/helloworld-springboot
I get stuck with the following error :
INVALID_ARGUMENT: Flexible Environment deployments are not supported in the apps region 'europe-west'.
Is there a way to not use the Flexible Environment deployments (or to make it works). I cannot even find other possible values for the yaml file
runtime: java
env: flex
runtime_config: # Optional
jdk: openjdk8
handlers:
- url: /.*
script: this field is required, but ignored
secure: always # Require HTTPS
manual_scaling:
instances: 1

From App Engine Locations:
Note: The europe-west region only supports the standard environment. You must select a different region to use the
flexible environment.
So you have 2 alternatives:
use an alternate GAE-offering region, I'd choose us-east1
see if you can convert your app to use the standard environment instead

If you want to change your region to US West, run this:
gcloud config set compute/region us-west1

Related

Error deploying java google app engine flexible application - Timed out waiting for the app infrastructure to become healthy

Writing this issue as I have no idea how to investigate it.
We're having problems in deploying an app engine flexible application.
The problem is, that the only error we get is the following:
GCLOUD: ERROR: (gcloud.app.deploy) Error Response: [4] Timed out waiting for the app infrastructure to become healthy.
I tried already the following:
Try a simple helloWorld app, to make sure it's not an application issue
Check quota settings -> All green
Check activity stream for warnings or errors
Check logs for warngings or errors
Grant owner role to service account which is deploying the app
App.yaml:
service: test-service # Id of the service
env: flex # Flex environment
runtime: java # Java runtime
runtime_config:
jdk: openjdk8 # use OpenJDK 8
resources:
cpu: 1
memory_gb: 2.8
gcloud version
Google Cloud SDK 214.0.0 alpha 2018.08.24
app-engine-java 1.9.64
app-engine-python 1.9.74 beta 2018.08.24 bq 2.0.34
cloud-datastore-emulator 2.0.2
core 2018.08.24
gsutil 4.33
kubectl 2018.08.24
pubsub-emulator 2018.08.24
After contacting the google technical support, we found out, that the default app engine service account didn't have the Editor role. After assigning the editor role the deployment worked again.
This error is often reported when your application has reached the quota limit for "In-use IP addresses". Similar error was reported on this Google Cloud Platform issue link. The default value for the in-use addresses is '8', and this quota value can be increased clicking the 'Edit' button in the Cloud Console — Ensure you are editing the value for In-use IP addresses.
The Google engineer confirmed that there is a planned improvement to the quota error details to be implemented in one of the next versions of gcloud SDK. You can track updates on the CloudSDK within this Google Group link

Elasticsearch deployment on google app engine flex

Is it possible to deploy Elasticsearch on App engine flex environment using a docker image.
I have tried the following
My files on the local machine
Folder : elasticsearch
app.yaml
Dockerfile
docker-entrypoint.sh
config folder(containing elasticsearch.yml)file
Contents of app.yaml
runtime: custom
env: flex
Dockerfile and docker-entrypoint.sh copied from https://github.com/GoogleCloudPlatform/elasticsearch-docker/tree/master/5/5.2.0
Modifications to the Dockerfile
replaced EXPOSE 9200 9300 to EXPOSE 8080
Modification to the elasticsearch.yml
cluster.name: "beaconinside-docker-cluster"
path.data: /usr/share/elasticsearch/data
http.host: 0.0.0.0
http.port: 8080
discovery.zen.minimum_master_nodes: 1
I build a container using the docker file on my local machine
docker build -t elasticdemo .
Then, I run the container
docker run -p 8080:8080 elasticdemo
I am able to access elasticsearch on 0.0.0.0:8080
Problem:
I am trying to deploy elasticsearch as an app to Google app engine flex environment
gcloud app deploy app.yaml --version elasticdocker --project myproject
The deployment fails with the following error
Updating service [default]...failed.
ERROR: (gcloud.app.deploy) Error Response: [9]
I was expected elasticsearch to deploy as an app and be available on the deployed url.
Could you please provide pointers/help/suggestions with this approach?
While you can deploy ES to App Engine Flexible environment it's not particularly useful. The VMs hosting GAE Flexible containers are restarted regularly as part of maintenance and whatever data is stored on the local disk will be lost on restart. If you want to use local disk for long term storage, I'd suggest to deploy the GCE VM's (or alternatively use a solution from the GCP Marketplace) or deploy to GKE which supports persistent disks
As for the actual question: you probably don't have a health check handler and therefore App Engine Flexible environment doesn't consider your app healthy after deploying it. The error message is useless, I agree.
From the GAE Flexible docs for building custom images:
"A health check is an HTTP request to the URL /_ah/health. A healthy application should respond with status code 200."
Alternatively you can turn off health checks by adding into app.yaml
enable_health_check: False

How to deploy a GAE project in flexible environment without billing?

I've been developing some REST service using Flask and other third party libraries and I want to deploy it to GAE in the flexible environment. I usually deploy to the GAE standard environment but I wanted to try the new flexible environment. At the moment I wish to deploy to flexible environment without enabling billing, and the Google support assured me that it was possible to deploy over GAE flexible environment without enabling billing.
Running my code locally works fine, and have the following yaml file:
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT whereismybus230.starter:app
runtime_config:
python_version: 3
So I created a new project on through the Google cloud console web page (as usual), and created a new gcloud profile on my local machine so I deploy it to this new project.
Then I run:
gcloud app deploy --verbosity=info
I get that a docker image is being build and at some point it will be pushed to a Compute Engine but it fails after a few minutes here:
Successfully built sophiabus230 aniso8601 future docopt itsdangerous MarkupSafe
Installing collected packages: Werkzeug, click, MarkupSafe, Jinja2, itsdangerous, Flask, jsonschema, pytz, six, python-dateutil, aniso8601, flask-restplus, beautifulsoup4, future, sophiabus230, coverage, requests, docopt, coveralls
Successfully installed Flask-0.12 Jinja2-2.9.4 MarkupSafe-0.23 Werkzeug-0.11.15 aniso8601-1.2.0 beautifulsoup4-4.5.3 click-6.7 coverage-4.3.4 coveralls-1.1 docopt-0.6.2 flask-restplus-0.9.2 future-0.16.0 itsdangerous-0.24 jsonschema-2.5.1 python-dateutil-2.6.0 pytz-2016.10 requests-2.12.5 six-1.10.0 sophiabus230-0.4
---> 3e3438680079
Removing intermediate container bd9f8ccb6f4a
Step 8 : ADD . /app/
---> bde0915f6720
Removing intermediate container e3193eb4ef70
Step 9 : CMD gunicorn -b :$PORT whereismybus230.starter:app
---> Running in 022d38d769f8
---> 36893d0a549a
Removing intermediate container 022d38d769f8
Successfully built 36893d0a549a
PUSH
The push refers to a repository [us.gcr.io/whereismy230/appengine/default.20170120t131841]
e5f488ee94c5: Preparing
8d27ce27f03c: Preparing
3d5800d45c36: Preparing
06ba8a2a8ec3: Preparing
c0fb81dae3c6: Preparing
2e4eabdbeed3: Preparing
b5d474284f52: Preparing
c307273999be: Preparing
d73750730c30: Preparing
63bbaf04cf0b: Preparing
badb9b2d625b: Preparing
40c928fd4dcc: Preparing
dfcf8dbe47e1: Preparing
6d820e13990c: Preparing
2e4eabdbeed3: Waiting
b5d474284f52: Waiting
c307273999be: Waiting
d73750730c30: Waiting
63bbaf04cf0b: Waiting
badb9b2d625b: Waiting
40c928fd4dcc: Waiting
dfcf8dbe47e1: Waiting
6d820e13990c: Waiting
denied: Unable to create the repository, please check that you have access to do so.
The push refers to a repository [us.gcr.io/whereismy230/appengine/default.20170120t131841]
...
ERROR: (gcloud.app.deploy) Error Response: [2] Build failed; check build logs for details
Using the IAM service, I made sure my account was the owner of the project, and even checked all permissions.
Since the flexible environment relies on the Compute Engines (VMs), I tried to check from the web page and it's telling me that I need to enable billing to be able to use this functionality.
Am I doing something wrong ?
Thanks !
From App Engine Pricing:
Instances within the standard environment have access to a daily
limit of resource usage that is provided at no charge defined by a set
of quotas. Beyond that level, applications will incur charges as
outlined below. To control your application costs, you can set a
spending limit. To estimate costs for the standard environment,
use the pricing calculator.
Go to the pricing calculator
For instances within the flexible environment, services and APIs are
priced as described below.
And from Flexible environment instances:
Applications running in the App Engine flexible environment are
deployed to virtual machine types that you specify. This table
summarizes the hourly billing rates of the various computing
resources:
US
Resource Unit Unit cost
vCPU per core hour $0.0526
Memory per GB hour $0.0071
Persistent disk per GB per month $0.0400
Unlike the standard env, the flex env has no free quota. Which is inline with your observation that the developer console requires billing to be enabled to run GAE flex instances.
Without billing enabled you might be able to deploy your app (but without actually launching a GAE instance for it, so unsure of its usefulness, since you want to try it) by using the --no-promote option:
--promote
Promote the deployed version to receive all traffic.
True by default. To change the default behavior for your current
environment, run:
$ gcloud config set app/promote_by_default false
Overrides the default promote_by_default property value for this
command invocation. Use --no-promote to disable.
Side note: when you encounter problems you may also want to use --verbosity=debug to potentially get more relevant info about the failures.

I can't delete google compute instance in "console"

I use node managed vm on google app engine. After I delete google compute instance at console.cloud.google.com , I see instance created automatically in "Operations". (This happens before, I used to delete instances at appengine.google.com which moved to "console" now.) How this happened? And How can I delete it?
When the instance can not be deleted it is because, either when creating an instance the protection against the deletion was checked or because after creating an instance we activated the protection from Gcloud with the following command:
$ gcloud compute instances update < INSTANCE_PATH> --deletion-protection
Sample of Instance path: projects/your-project-265315/zones/us-central1-a/instances/your-instance-v3
Solution:
Active Google Cloud Shell:
Precondition:
Request permission for the user to access the machine (regardless of the SSH connection to the instance) to avoid 403: Insufficient Permission.
$ gcloud auth login
If the deletion of the instance is protected, eliminate the protection.
$ gcloud compute instances update <INSTANCE_PATH> --no-deletion-protection
Then we delete the instance by selecting the zone correctly.
$ gcloud compute instances delete <instance-path>
GL
Preventing accidental vm deletion
Auth login
You have to delete deployed version for Flexible VM. Since it's only one version, you have to deploy another one, for standard vm.
Most simple solution would be to deploy an empty version, w/o any code, just one static file. To do that create following app.yaml:
module: default
runtime: python27
api_version: '1.0'
threadsafe: true
handlers:
- url: /
static_files: index.html
upload: index.html
resources:
cpu: 0.1
memory_gb: 0.5
disk_size_gb: 10
put an empty index.html in same dir. And deploy it using:
gcloud preview app deploy app.yaml
After this, you'll be able to route all traffic to this dummy version, and then delete previous version deployed for Flexible VM.
You need to delete the module from your app description. Otherwise App Engine will keep spinning new instances in accordance with the scale settings in your module description.

Is scrapy supported on google app engine?

It has following dependencies:
- Twisted 2.5.0, 8.0 or above
- lxml or libxml2 (if using libxml2, version 2.6.28 or above is highly recommended)
- simplejson
- pyopenssl
You cannot use C extensions on App Engine, which rules out lxml and (I believe) libxml2 and pyopenssl.
I doubt most of what Twisted does is possible in the App Engine sandbox either; you can't directly open sockets or spawn threads.
EDIT (January 2013): The Python 2.7 runtime does include some C extensions, including lxml. However, it's still not possible to use C extensions that aren't provided by Google with the runtime; most likely scrapy is still unusable at this time.
No but you could try AWS (http://dev.scrapy.org/wiki/AmazonEC2)
Update for 2019:
Scrapy indeed works on GAE. I can confirm that Scrapy can be deployed on GAE Python 3 standard environment using ScrapyRT.
Your scrapy.cfg file must be in the same directory as app.yaml to be picked up accordingly and a minimal setup would look like this:
runtime: python37
instance_class: F2
env_variables:
PORT: 8080
entrypoint: scrapyrt -i 0.0.0.0 -p $PORT -s LOG_DIR=/tmp
Note how LOG_DIR is set to /tmp which is most likely not what anyone would want for production environment. I might extend this answer once i figured out how to approach this appropriately.

Resources