Origin: Cannot oc set image/env for CronJob

Created on 26 Jan 2017  路  8Comments  路  Source: openshift/origin

Hi,
I can get a scheduledJob working using the example in https://docs.openshift.com/container-platform/3.3/dev_guide/scheduled_jobs.html, but I am not able to use an IS in current project unless I specify the absolute image path in the format :5000/\. Note I cannot even use the public docker registry host name. This is different from how image can be specified in other resource types such as DeploymentConfig. It makes the template containing this resource not portable.

Version
C:\Users\x>oc version
oc v1.5.0-alpha.2+e4b43ee
kubernetes v1.5.2+43a9be4
features: Basic-Auth

Server https://<console_url>:8443
openshift v3.3.1.7
kubernetes v1.3.0+52492b4
kinbug prioritP2

Most helpful comment

Currently the suggestion from Michal is not working as expected, I'm getting:

$ oc set image cronjob/hello2 hello=openshift/python:3.5
error: cronjobs/hello2 no kind "CronJob" is registered for version "batch/v1

This should be fixed when we switch to k8s 1.6. With that I'm changing the tile accordingly to reflect the desired output of this issue.

@commandtab to answer your question specifically, the objects coming from k8s (iow. non-native OpenShift objects) don't know anything about ImageStreams and currently can't work with them. I've opened https://github.com/openshift/origin/issues/13042 to discuss this topic.

All 8 comments

@f-w the ScheduledJobs (soon to be CronJobs) are Kubernetes resources, so you can't just reference the IS name there as it won't be resolved.

You can use oc set image cronjob/foo and use the IS and that command will resolve it properly, however it is current broken :-(

If I understand correctly, I'm running into this as well. I'm hoping to run Jobs and/or ScheduledJobs in a container based on a tag of my application's ImageStream (usually :latest), which is stored within OpenShift's internal Docker registry. As @f-w mentioned, one can specify the full path to the OpenShift registry in the Job/ScheduledJob config, but then you're introducing a dependency on an implementation detail, which seems rather fragile.

Without being able to easily make use of an ImageStream with a Job or ScheduledJob, I'm not sure I see how either of them are particularly useful when running my own applications within OpenShift.

Any suggestions or future plans? Thanks so much!

Currently the suggestion from Michal is not working as expected, I'm getting:

$ oc set image cronjob/hello2 hello=openshift/python:3.5
error: cronjobs/hello2 no kind "CronJob" is registered for version "batch/v1

This should be fixed when we switch to k8s 1.6. With that I'm changing the tile accordingly to reflect the desired output of this issue.

@commandtab to answer your question specifically, the objects coming from k8s (iow. non-native OpenShift objects) don't know anything about ImageStreams and currently can't work with them. I've opened https://github.com/openshift/origin/issues/13042 to discuss this topic.

I have a similar issue for my django project. I have the django and postgresql pods being created just fine, but would like to create a django container for cron jobs to run manage.py tasks regularly, and as @f-w mentions, that is great when you specify the full path to the image in your job, but I'd rather add it to a template and have it use the environment for the image name (i.e. ${NAME:latest}

will i be able to 'templatize' cronjobs someday?

thanks,

will i be able to 'templatize' cronjobs someday?

Sorry for the late reply (was out for a bit :)). It's already possible, this example is working just fine with version 1.5+.

@soltysh Yes, I can get a standard YAML instance of CRON to work, but that hard-codes the image to use. I'm hoping to tie it into a true Openshift template that can pull the generated local image from it's registry without me specifying the name.

Hope this helps.

J

@jfmatth you man support for k8s resources being able to use Image Streams. That should be available already in 3.6 :) See this doc points 7, 8 and 9 will be what you're interested in. Be warned, this is a tech preview feature :)

The same problem applies to oc set env, it doesn't work with CronJobs.

Was this page helpful?
0 / 5 - 0 ratings