When I want to run the demo, I get the error:
error: error validating "cronJob_example.yaml": error validating data: couldn't find type: v2alpha1.CronJob; if you choose to ignore these errors, turn validation off with --validate=false
Then I found:
Prerequisites You need a working Kubernetes cluster at version >= 1.4 (for ScheduledJob), >= 1.5 (for CronJob), with batch/v2alpha1 API turned on by passing --runtime-config=batch/v2alpha1=true while bringing up the API server (see Turn on or off an API version for your cluster for more).
The above conditions need to do --runtime-config=batch/v2alpha1=true
, but I don't know where and how to execute it
Here is it documented. https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/ we need to enable this feature in API server.
on the master server you need to add the line command section in this file /etc/kubernetes/manifests/kube-apiserver.yaml
. then restart whole cluster.
After restart check the api version. we should see the feature enabled.
kubectl api-versions |grep batch
batch/v1
batch/v2alpha1