AKS icon indicating copy to clipboard operation
AKS copied to clipboard

CronJob doesn't work

Open kamoljan opened this issue 8 years ago • 4 comments

The following CronJob doesn't work for me:

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

When I try to create it:

k apply -f cronjob.yaml

is yelling:

error: unable to recognize "cronjob.yaml": no matches for batch/, Kind=CronJob

This is my environment

✗ kubectl api-versions
apiextensions.k8s.io/v1beta1
apiregistration.k8s.io/v1beta1
apps/v1beta1
authentication.k8s.io/v1
authentication.k8s.io/v1beta1
authorization.k8s.io/v1
authorization.k8s.io/v1beta1
autoscaling/v1
batch/v1
certificates.k8s.io/v1beta1
extensions/v1beta1
networking.k8s.io/v1
policy/v1beta1
rbac.authorization.k8s.io/v1alpha1
rbac.authorization.k8s.io/v1beta1
settings.k8s.io/v1alpha1
storage.k8s.io/v1
storage.k8s.io/v1beta1
v1

✗ k version
Client Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.6", GitCommit:"4bc5e7f9a6c25dc4c03d4d656f2cefd21540e28c", GitTreeState:"clean", BuildDate:"2017-09-14T06:55:55Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"7", GitVersion:"v1.7.7", GitCommit:"8e1552342355496b62754e61ad5f802a0f3f1fa7", GitTreeState:"clean", BuildDate:"2017-09-28T23:56:03Z", GoVersion:"go1.8.3", Compiler:"gc", Platform:"linux/amd64"}

kamoljan avatar Feb 09 '18 12:02 kamoljan

CronJob is only supported on Kubenetes 1.8 or higher, it appears your cluster is only on 1.7.7.

https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#prerequisites

scotta01 avatar Feb 09 '18 12:02 scotta01

@scotta01 oh, missed it. Thanks! Btw, after upgrade of k8s I am getting the following issue:

Unable to connect to the server: net/http: TLS handshake timeout

Is it a bug?

kamoljan avatar Feb 09 '18 15:02 kamoljan

Looks like there are several reports of TLS issues, most recently here #164

scotta01 avatar Feb 09 '18 15:02 scotta01

@scotta01 yeah...Thank you. I am having the same issue :( Going to close this issue, for now, will try to reinstall a new k8s from with the latest version instead.

kamoljan avatar Feb 10 '18 02:02 kamoljan