Prashant
Prashant

Reputation: 1190

Error: '' is not a valid port number while trying to bring up Python flask application on GKE

I am trying to bring up a python flask application using gunicorn. I am referring to this code to create an image and then bring up a pod/deployment/service on GKE.

Pod bring up fails on GKE with "ContainersReady: False". On probing ContainerLogs i could see following error

Error: '' is not a valid port number

i have changed the dockerfile and rebuild the image by changing the following, but it error remains same.

CMD exec gunicorn --bind 0.0.0.0:8000 --workers 1 --threads 8 --timeout 0 main:app

i guess i am missing something basic here. Not sure what is it..

Upvotes: 6

Views: 3226

Answers (1)

Khalid
Khalid

Reputation: 714

Please check this example: https://cloud.google.com/kubernetes-engine/docs/quickstarts/deploying-a-language-specific-app#python_1

After adding

env:
  - name: PORT
    value: "8080"

under 'containers' in your deployment.yaml it shoud work.

Upvotes: 3

Related Questions