How do I see the restartPolicy of a CronJob using kubectl?

1/13/2021

Is there a way to see see the restartPolicy of a CronJob using kubectl?

Here's my Kubernetes version info:

Client Version: version.Info{Major:"1", Minor:"19", GitVersion:"v1.19.4", GitCommit:"d360454c9bcd1634cf4cc52d1867af5491dc9c5f", GitTreeState:"clean", BuildDate:"2020-11-12T01:09:16Z", GoVersion:"go1.15.4", Compiler:"gc", Platform:"darwin/amd64"}
Server Version: version.Info{Major:"1", Minor:"18+", GitVersion:"v1.18.9-eks-d1db3c", GitCommit:"d1db3c46e55f95d6a7d3e5578689371318f95ff9", GitTreeState:"clean", BuildDate:"2020-10-20T22:18:07Z", GoVersion:"go1.13.15", Compiler:"gc", Platform:"linux/amd64"}

And this is what I see when running kubectl describe cronjob -n default example-job:

Name:                          example-job
Namespace:                     default
Labels:                        app.kubernetes.io/instance=yogurt
                               app.kubernetes.io/managed-by=Helm
                               app.kubernetes.io/name=item-service
                               app.kubernetes.io/version=v0.1.4
                               helm.sh/chart=item-service-0.2.0
Annotations:                   meta.helm.sh/release-name: yogurt
                               meta.helm.sh/release-namespace: default
Schedule:                      4 */6 * * *
Concurrency Policy:            Replace
Suspend:                       False
Successful Job History Limit:  3
Failed Job History Limit:      1
Starting Deadline Seconds:     <unset>
Selector:                      <unset>
Parallelism:                   <unset>
Completions:                   <unset>
Pod Template:
  Labels:  <none>
  Containers:
   example-job:
    Image:      example.dkr.ecr.us-west-2.amazonaws.com/example-job:v1.1.1
    Port:       8099/TCP
    Host Port:  0/TCP
    Limits:
      memory:  600M
    Requests:
      memory:  500M
    Environment:
      server.port:                        8099
    Mounts:                               <none>
  Volumes:                                <none>
Last Schedule Time:                       Wed, 13 Jan 2021 06:04:00 -0600
Active Jobs:                              <none>
Events:                                   <none>
-- wubbalubba
kubectl
kubernetes

1 Answer

1/13/2021

why don't you try something like this -

kubectl -n {namespace-name-here} get cronjob

this will give you all cronjobs in that namespace

kubectl -n {namespace-name-here} get cronjob {cronjob-name} -o yaml

This will display the yaml used to create the cronjob

-- Tushar Mahajan
Source: StackOverflow