Search code examples
cronopenshiftopenshift-3

Openshift cron job curl


I have Java Rest application on Openshift. I need to create cron for link in my application. Is it possible?

I tried this example

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: pi
spec:
  schedule: "*/1 * * * *"  
  jobTemplate:             
    spec:
      template:
        metadata:
          labels:          
            parent: "cronjobpi"
        spec:
          containers:
          - name: pi
            image: perl
            command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
          restartPolicy: OnFailure 

this job works well, but I dont know how I need to change it from perl to curl correctly.

Thank you for advice.


Solution

  • I think you can run curl command if you change the image to rhel7 as follows.

    ...
    spec:
      containers:
      - name: pi
        image: rhel7
        command: ["curl",  "-kvs", "https://www.google.com/"]
    ...
    

    I hope it help you. :^)