How can my python script make http requests within a GKE cronjob

  docker, google-kubernetes-engine, python

I am in the process of creating a cronJob on GKE to run weekly.

It will consist of a Python script contained within a Docker image on a GKE cluster.

The Python script will use the requests modules to call web URLs and so should be able to make http(s) requests.

I have created my GKE cluster but I haven’t attached any services to it.

In order for the Python script to work, do I need to:

  • Ensure my docker image listens on port 80/443? or is that not necessary here?
  • Set the port 80/443 in my cronJob YAML file? – is this even possible?
  • Or, do I need to attach a service (LoadBalancer for example) to my GKE cluster to handle http requests to and from my GKE job?

What would be the most straightforward way to ensure the Python script works?

Source: Docker Questions

LEAVE A COMMENT