赞
踩
添加任务调试测试的test-centos-cronjob.yaml
这里我们做一个测试,每小时的20分,自动拉起一个centos容器,执行打印100行的命令,然后退出。
kind: CronJob apiVersion: batch/v1beta1 metadata: name: test-centos-cronjob namespace: test labels: app: test-centos-cronjob spec: schedule: 20 * * * * concurrencyPolicy: Allow suspend: false jobTemplate: metadata: labels: app: test-centos-cronjob spec: parallelism: 1 completions: 1 activeDeadlineSeconds: 30 backoffLimit: 6 template: metadata: labels: app: test-centos-cronjob spec: containers: - name: test-centos-cronjob image: '10.41.10.81:5000/centos' command: - /bin/sh args: ["-c","for i in $(seq 0 100); do echo hello$i;done;"] imagePullPolicy: IfNotPresent securityContext: privileged: true restartPolicy: Never schedulerName: default-scheduler successfulJobsHistoryLimit: 3 failedJobsHistoryLimit: 3
使其生效
kubectl apply -f test-centos-cronjob.yaml
kubectl get cronjob #查看一下效果
查看有哪个Job执行了
查看一下这个job的情况,找一下pod
看下这个pod的日志
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。