我在创造
读取数据。
问题是,它继续每两分钟创建一次豆荚,不管其他人是否终止,我试图终止吊舱,如果我从吊舱中得到像“空”一样的响应,在吊舱中运行的操作给出这样的响应,如果没有这样的响应,我想在10秒内终止。
发布于 2022-11-23 18:59:55
你可以做这样的事
kubectl wait --for=condition=complete job/jobname您还可以设置一个超时:
kubectl wait --for=condition=complete --timeout=10s job/jobname示例python脚本,它将检查redis
#!/usr/bin/env python
import time
import rediswq
host="redis"
# Uncomment next two lines if you do not have Kube-DNS working.
# import os
# host = os.getenv("REDIS_SERVICE_HOST")
q = rediswq.RedisWQ(name="job2", host=host)
print("Worker with sessionID: " + q.sessionID())
print("Initial queue state: empty=" + str(q.empty()))
while not q.empty():
item = q.lease(lease_secs=10, block=True, timeout=2)
if item is not None:
itemstr = item.decode("utf-8")
print("Working on " + itemstr)
time.sleep(10) # Put your actual work here instead of sleep.
q.complete(item)
else:
print("Waiting for work")
print("Queue empty, exiting")参考文献:https://kubernetes.io/docs/tasks/job/fine-parallel-processing-work-queue/
https://stackoverflow.com/questions/74547540
复制相似问题