How to set label for cronjob(scheduledjob)?

Solution In Progress - Updated -

Issue

  • Job pods don't have label even though I created ScheduledJob/CronJobs as:
apiVersion: batch/v2alpha1
kind: ScheduledJob
metadata:
  name: hello
labels:
  job: test
spec:
  schedule: "* * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: busybox
            args:
            - /bin/sh
            - -c
            - date; echo Hello from the Kubernetes cluster
          restartPolicy: OnFailure
  • Following all pods don't take over the label.
$ oc get pod
NAME                     READY     STATUS      RESTARTS   AGE
hello-1160671760-tahw1   0/1       Completed   0          6h
hello-1160737296-ywvge   0/1       Completed   0          3h
hello-1160802832-3ciew   0/1       Completed   0          23h

Environment

  • OpenShift Container Platform
    • 3.x
  • openshift dedicated

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.