问题原文
原帖链接 · Bostone · CC BY-SA 3.0
I have the following Kubernetes Job configuration:
---
apiVersion: batch/v1
kind: Job
metadata:
name: dbload
creationTimestamp:
spec:
template:
metadata:
name: dbload
spec:
containers:
- name: dbload
image: sdvl3prox001:7001/pbench/tdload
command: ["/opt/pbench/loadTpcdsData.sh", "qas0063", "dbc", "dbc", "1"]
restartPolicy: Never
imagePullSecrets:
- name: pbenchregkey
status: {}
When I do kubectl create -f dbload-deployment.yml --record the job and a pod are created, Docker container runs to completion and I get this status:
$ kubectl get job dbload
NAME DESIRED SUCCESSFUL AGE
dbload 1 1 1h
$ kubectl get pods -a
NAME READY STATUS RESTARTS AGE
dbload-0mk0d 0/1 Completed 0 1h
This job is one time deal and I need to be able to rerun it. If I attempt to rerun it with kubectl create command I get this error
$ kubectl create -f dbload-deployment.yml --record
Error from server: error when creating "dbload-deployment.yml": jobs.batch "dbload" already exists
Of course I can do kubectl delete job dbload and then run kubectl create but I'm wondering if I can somehow re-awaken the job that already exists?
已采纳解答
原帖链接 · cohadar · CC BY-SA 4.0
No. There is definitely no way to rerun a kubernetes job. You need to delete it first.
You can however create a new job based on existing job configuration that will be executed immediately:
kubectl create job --from=job/dbload new-dbload -n <namespace>
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
