Reputation: 5
I'm deploying a Python application into GAE for the first time, which is using Flask-restful as REST server, and i can't get the concept of how to configure the deployment properly.
I'm trying with the minimal flask-restful application example minimal.py
from flask import Flask
from flask_restful import Resource, Api
app = Flask(__name__)
api = Api(app)
class HelloWorld(Resource):
def get(self):
return {'hello': 'world'}
api.add_resource(HelloWorld, '/')
if __name__ == '__main__':
app.run(debug=True, host='0.0.0.0')
And i've configured the deployment app.yaml
file in the following way, where the network section is trying to give access to the default 5000 port of flask-restful:
runtime: python
env: flex
entrypoint: python minimal.py
runtime_config:
python_version: 3
network:
instance_tag: instance-1
name: default
forwarded_ports:
- 5000
The name default is the only network configured in my VPC.
The deployment instruction was the following, in order to remove previous trials I did:
gcloud app deploy --promote --stop-previous-version
So, when I try with curl to post, i receive a 502 error, which i can see in my server also.
I'm missing a step somewhere... probably in the VPC network or in the app.yaml configuration, but i'm lost at this point...
Any help will be very appreciated :)
Upvotes: 0
Views: 796
Reputation: 11695
Try to update your configuration of yaml
.
runtime: python
env: flex
entrypoint: gunicorn -b :$PORT minimal:app
runtime_config:
python_version: 3
manual_scaling:
instances: 1
resources:
cpu: 1
memory_gb: 0.5
disk_size_gb: 10
Reference: https://cloud.google.com/appengine/docs/flexible/python/configuring-your-app-with-app-yaml
Upvotes: 1