Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

cronjob points to a go function defined as an http request

Hi...I have a go-code function that works as an http request. I want to run this frequently, I know I will use a cronjob type in the YAML configuration file; but How I declared/define that in this configuration file:
apiVersion: batch/v1
kind: CronJob
metadata:
name: statsWorker
spec:
schedule: "* * * * *"
jobTemplate:
spec:
template:
spec:
containers:
selector:
app: nw-runs-ingest
????????????????????
HOW TO REFERENCE THE FUNCTION
restartPolicy: OnFailure

Thanks

0 1 117
1 REPLY 1

Hello emrosales,

Welcome to GCC!

You can Create a CronJob using a manifest file. For example, the following YAML manifest prints the current time and a string once every minute, while retaining the default values for CronJob parameters:


# cronjob.yaml
apiVersion: batch/v1
kind: CronJob
metadata:
  name: hello
spec:
  schedule: "*/1 * * * *"
  concurrencyPolicy: Allow
  startingDeadlineSeconds: 100
  suspend: false
  successfulJobsHistoryLimit: 3
  failedJobsHistoryLimit: 1
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo "Hello, World!"
          restartPolicy: OnFailure

You can also use this document for additional info.

Top Labels in this Space
Top Solution Authors