发生了什么:
我用lambda在AWS中创建了一个deploy,用于设置Kubernetes集群中的映像。你知道吗
我想在CronJob中设置映像:
克朗:
NAME SCHEDULE SUSPEND ACTIVE
LAST SCHEDULE AGE cronjob.batch/analytics-staging-0 */5 * * * *
False 0 4m23s 144m Describe cronjob:
Name: analytics-staging-0 Namespace:
staging-app Labels: app=analytics-staging-0
Annotations: <none> Schedule:
*/5 * * * * Concurrency Policy: Replace Suspend: False Successful Job History Limit: 824641908604 Failed Job History
Limit: 1 Starting Deadline Seconds: <unset> Selector:
<unset> Parallelism: 1 Completions:
1 Pod Template: Labels: <none> Containers:
analytics-staging-0:
Image: accountid.dkr.ecr.eu-west-1.amazonaws.com/app:latest
Port: <none>
Host Port: <none>
Command:
/opt/app/analytics
Environment:
AWS_REGION: eu-west-1
Mounts: <none> Volumes: <none> Last Schedule Time: Tue, 24 Dec 2019 15:20:00 +0100 Active Jobs:
analytics-staging-0-1577197200
Python代码:
def set_image_job(image, namespace, name, conn):
api_instance = conn.BatchV1beta1Api()
body = {
"spec": {
"template": {
"spec": {
"containers": [
{
"image": image
}
]
}
}
}
}
try:
response = api_instance.patch_namespaced_cron_job(name, namespace, body, pretty=True)
print(response)
except Exception as e:
print("Exception when calling BatchV2alpha1Api->patch_namespaced_cron_job: %s\n" % e)
if __name__ == "__main__":
conn = get_connection_eks()
eks_resource = EKSResources('staging-app', conn)
jobs = eks_resource.get_cron_jobs()
for item in jobs:
set_image_job('accountid.dkr.ecr.eu-west-1.amazonaws.com/app:latest',
'staging-app', item, conn)
注:item=analytics-staging-0
响应正常,但不要更改图像。你知道吗
你能帮我吗?你知道吗
谢谢!你知道吗
环境:
Kubernetes版本(kubectl版本):
Client Version: version.Info{Major:"1", Minor:"14",
GitVersion:"v1.14.0",
GitCommit:"641856db18352033a0d96dbc99153fa3b27298e5",
GitTreeState:"clean", BuildDate:"2019-03-25T15:53:57Z",
GoVersion:"go1.12.1", Compiler:"gc", Platform:"darwin/amd64"} Server
Version: version.Info{Major:"1", Minor:"14+",
GitVersion:"v1.14.9-eks-c0eccc",
GitCommit:"c0eccca51d7500bb03b2f163dd8d534ffeb2f7a2",
GitTreeState:"clean", BuildDate:"2019-12-22T23:14:11Z",
GoVersion:"go1.12.12", Compiler:"gc", Platform:"linux/amd64"}
Python版本(Python--version)
Python 3.7版
目前没有回答
相关问题 更多 >
编程相关推荐