CronJob: add support for server_version == 1.4 (ScheduledJob) and server_version >= 1.5 (CronJob)
@@ -10,6 +10,7 @@ from kubernetes.models.unversioned.BaseModel import BaseModel
from kubernetes.models.v1.ObjectMeta import ObjectMeta
from kubernetes.models.v2alpha1.CronJobSpec import CronJobSpec
from kubernetes.models.v2alpha1.CronJobStatus import CronJobStatus
+from kubernetes.utils import server_version
class CronJob(BaseModel):
@@ -20,7 +21,12 @@ class CronJob(BaseModel):
def __init__(self, model=None):
super(CronJob, self).__init__()
+ v = server_version()
+ if int(v['major']) == 1 and int(v['minor']) == 4:
self.kind = 'ScheduledJob'
+ if int(v['major']) == 1 and int(v['minor']) >= 5:
+ self.kind = 'CronJob'
+
self.api_version = "batch/v2alpha1"
self.spec = CronJobSpec()
self.status = CronJobStatus()
