如何使用 kubectl 查看 CronJob 的 restartPolicy?

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

有没有办法查看使用 kubectl 的 CronJob 的 restartPolicy?

这是我的 Kubernetes 版本信息:

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"}

这就是我在 运行 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>

你为什么不试试这样的东西 -

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

这将为您提供该命名空间中的所有 cronjobs

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

这将显示用于创建 cronjob 的 yaml