apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: node-timer-analytics-parser-cronjob
spec:
schedule: "0 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- name: node-timer-analytics-parser-cronjob
image: round0.azurecr.io/node-timer-analytics-parser:latest
args:
- /bin/sh
- -c
- date; npm start
restartPolicy: OnFailure
imagePullSecrets:
- name: regsecret
I have a following YAML file which creates a cronjob but $ kubectl get cronjob cmd gives this $ kubectl get cronjob
NAME KIND
node-timer-analytics-parser-controller CronJob.v1beta1.batch
also $ kubectl get job says NO resources found.
I also tried this $ kubectl describe cronjob node-timer-analytics-parser-controller which gives
Name: node-timer-analytics-parser-controller
Namespace: default
Labels: <none>
Events: <none>
This docker image/container does some extensive sql queries(40-50 queries in parallel) to sql database.
I tested the docker container locally it runs without any issues. One complete execution probably takes around 1- 5 minutes. I don't understand why it is not working in Kubernetes
I even tried the example of the k8 documentation it seems to be working done know what is the issue with my cronjob.
Presumably you are running Kubernetes 1.8, according to the release notes 1.7.8 is the default version run in GKE. You can check which version you are running by using kubectl version
If you are running < 1.8 then you will need to enable cron jobs as per the CronJob documentation. I don't use GKE, but looks like you do this at cluster create time:
gcloud alpha container clusters create my-cluster --enable-kubernetes-alpha
For more info, take a look at About Alpha Features
Even with 1.8 is seems to be listed on the release notes as a new feature
You can now run CronJobs on your Container Engine cluster. CronJob is a Beta feature in Kubernetes version 1.8.
So you might need to run an upgrade.
I also notice that you are using an azure container. Might be worth starting with the example CronJob
to see if you can get that to work first.