ScheduledJobs on Google Container Engine (kubernetes)

11/11/2016

Did someone has an experience running scheduled job? Due to the guide, ScheduledJobs available since 1.4 with enabled runtime batch/v2alpha1

So I was ensured with kubectl api-versions command:

autoscaling/v1
batch/v1
batch/v2alpha1
extensions/v1beta1
storage.k8s.io/v1beta1
v1

But when I tried sample template below with command kubectl apply -f job.yaml

apiVersion: batch/v2alpha1
kind: ScheduledJob
metadata:
  name: hello
spec:
  schedule: 0/1 * * * ?
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure

I got error

error validating "job.yaml": error validating data: couldn't find type: v2alpha1.ScheduledJob; if you choose to ignore these errors, turn validation off with --validate=false

It's possible that feature still not implemented? Or I made some error during template creation?

Thank you in advance.

-- Daniil Bolsun
google-cloud-platform
google-kubernetes-engine
kubectl
kubernetes

1 Answer

11/11/2016

Okay, I think I resolved this issue. ScheduledJobs is currently in alpha state and Google Container Engine supports this feature only for clusters with additionally enabled APIs. I was able to create such cluster with command:

gcloud alpha container clusters create my-cluster --enable-kubernetes-alpha

As a result now I have limited 30 day cluster with full feature support. I can see scheduled jobs with kubectl get scheduledjobs as well as create new ones with templates.

You can find more info about alpha clusters here.

-- Daniil Bolsun
Source: StackOverflow