Reputation: 41
I am new to openshift and i am having issues/errors when creating a Cron job that will run a stored procedure.
I thought the easiest way for me to run this would be to use the OpenShift CLI in a cron job which would just navigate to the pod, connect to the Database and then run the stored procedure. I am not sure if this is even the best\correct approach.
My code for testing CLI:
apiVersion: batch/v1
kind: CronJob
metadata:
name: pgschedulertest
spec:
schedule: "*/20 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: ps-container
image: openshift4/ose-cli
command: ["oc", "exec", "postgresql-2-bl4gr", "psql --help"]
restartPolicy: Never
It errors and states "Image Pull Back-off". I had a brief read online and I can't figure out how to use the open shift UI to access this open shift CLI/Find out if the image or what images even exist. Alternatively, if there is a better way to schedule PostgresSql stored procedures in Openshift i would love to know?
Upvotes: 4
Views: 697
Reputation: 11950
The problem you face at the moment has to do with trying to pull the container image from Docker Hub. This has to be changed to pulling from Openshift Registry:
apiVersion: batch/v1
kind: Job
metadata:
name: pgschedulertest
spec:
template:
spec:
containers:
- name: ps-container
image: registry.redhat.io/openshift4/ose-cli
command: ["oc", "exec", "postgresql-2-bl4gr", "psql --help"]
restartPolicy: Never
Once fixed, you will run into RBAC issues, which will have to get rectified by giving more permissions to the Service Account this job runs under.
Upvotes: 2