1

I have an Amazon EKS Kubernetes cluster and have the need to run a CronJob on it. However, when I published the manifest to k8s, the object is there, I can list it, get it, but I cannot describe it and see its events. Also, it doesn't seem to start at all. According to my cron pattern, it should have started on the first hour.

What I have done so far:

I have created the manifest for the CronJob:

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: aws-ecr-token
  namespace: default
  labels:
    app: aws-ecr-token
    component: infrastructure
spec:
  schedule: "* */11 * * *"
  jobTemplate:
    metadata:
      name: aws-ecr-token
      namespace: default
      labels:
        app: aws-ecr-token
        component: infrastructure
    spec:
      completions: 1
      backoffLimit: 3
      activeDeadlineSeconds: 60
      parallelism: 1
      template:
        metadata:
          name: aws-ecr-token
          namespace: default
          labels:
            app: aws-ecr-token
            component: infrastructure
        spec:
          containers:
          - name: aws-ecr-token
            image: docker pull mesosphere/aws-cli
            command:
            - "sh"
            - "-c"
            - "$(aws ecr get-login --no-include-email)"
            env:
            - name: AWS_ACCESS_KEY_ID
              valueFrom:
                secretKeyRef:
                  name: aws-ecr
                  key: accessKey
            - name: AWS_SECRET_ACCESS_KEY
              valueFrom:
                secretKeyRef:
                  name: aws-ecr
                  key: secretKey
            - name: AWS_DEFAULT_REGION
              valueFrom:
                secretKeyRef:
                  name: aws-ecr
                  key: defaultRegion
            volumeMounts:
            - name: aws-ecr-config
              mountPath: /root/.docker
          restartPolicy: OnFailure
          volumes:
          - name: aws-ecr-config
            secret:
              secretName: aws-ecr-config

Deployed it using:

$ kubectl apply -f aws-ecr-token-cron-job.yaml

I can get it:

$ kubectl get cronjobs
NAME            SCHEDULE      SUSPEND   ACTIVE    LAST SCHEDULE   AGE
aws-ecr-token   * */11 * * *   False     0         <none>          26m

But it never gets scheduled.

When I try to describe it, it shows:

$ kubectl describe cronjobs
Error from server (NotFound): the server could not find the requested resource

Any ideas why?

My version is:

$ kubectl version
Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.0", GitCommit:"fc32d2f3698e36b93322a3465f63a14e9f0eaead", GitTreeState:"clean", BuildDate:"2018-03-26T16:55:54Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"10+", GitVersion:"v1.10.11-eks", GitCommit:"6bf27214b7e3e1e47dce27dcbd73ee1b27adadd0", GitTreeState:"clean", BuildDate:"2018-12-04T13:33:10Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"}

Thanks in advance :)

0

There was an error in Kubernetes that causes failure when using kubectl describe with the cronjob resource. It was fixed at some point between the v1.10.x and v1.12.x versions (more info in this issue #45418).

You said:

According to my cron pattern, it should have started on the first hour.

But your schedule is * */11 * * *, and it means: “At every minute past every 11th hour.”

I did not understand what you exactly meant with "on the first hour", but if you are talking about running the job on every new hour, the schedule should look like this: 0 * * * *

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.