gpt4 book ai didi

Kubernetes 工作永无止境

转载 作者:行者123 更新时间:2023-12-02 11:48:26 26 4
gpt4 key购买 nike

我有一个 k8 作业,使用 sqlpackage 工具发布一个 sql-server dacpac。作业运行,数据库部署成功,但作业卡在Running状态。

如何确保作业在 sqlpackage 完成运行后结束?


apiVersion: batch/v1
kind: Job
metadata:
name: my-publish-job
namespace: my-namespace
spec:
template:
metadata:
labels:
app: my-publish-job
namespace: my-namespace
spec:
containers:
- name: my-db-publish
image: my-db-image:v1.0.0
imagePullPolicy: Always
lifecycle:
postStart:
exec:
command:
- /bin/bash
- -c
- >
/sqlpackage/sqlpackage \
/Action:Publish \
/SourceFile:"/my-db.dacpac" \
/p:DropObjectsNotInSource=True \
/p:DoNotDropObjectTypes="Users;Permissions;RoleMembership;ServerRoleMembership" \
/p:IgnoreAuthorizer=True \
/p:IgnorePermissions=True \
/TargetUser:sa \
/TargetPassword:my_db_password \
/TargetDatabaseName:MyDb \
/TargetServerName:my.db.server
restartPolicy: Never

最佳答案

在 Kubernetes 中定义作业时,您可以设置属性 activeDeadlineSeconds

apiVersion: batch/v1
kind: Job
metadata:
name: your-job
spec:
activeDeadlineSeconds: 100
template:
spec:
containers:
- [...]

引用:https://kubernetes.io/docs/concepts/workloads/controllers/jobs-run-to-completion/

关于Kubernetes 工作永无止境,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52365032/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com