3
votes

Background

I have a Google cloud Pub-Sub queue that listen by Google Function python script. My function script is waiting for incoming messages on queue and execute them.

On of my tasks is to scale up\down my environment. This logic should happen every day on 00:00 (scale up) and on 12:00 (scale down).

I want to automate the message insertion for the queue on specific time.

Requirements:

  • Make it easy configurable (if the scaling time is changing for example).
  • Without need on virtual machine that cost me money all the day.

Possible solution were rejected

  1. Use Linux VM with crontab to run a local script. The script will en-queue a message for the gcp PubSub. Con: Need the machine working all day long for just few seconds.
  2. Use Kubernetes cronjob and run the script on specific time. Cons: too much configuration. Not easy to edit config. No needs to gcp Function - it can be the job itself.

The Question

What is the simplest way to do it?

1

1 Answers

4
votes

You can use Google Cloud Scheduler that would perfectly fit your needs here. The public documentation offers a tutorial to set up a job exactly for your use case. Note that it is required to create an App Engine app to use the Cloud Scheduler API but you won't be charged for it if you don't deploy any code to it.