[英]Update the task definition of a fargate scheduled task in ECS cluster
我有一個到 ecs 集群的管道設置,我在其中更新服務的任務定義,然后啟動新的部署。 例如:
# Update task definition
- aws ecs register-task-definition --cli-input-json file://aws/task-definition${TASK_SUFFIX}.json --region $AWS_DEFAULT_REGION
- TASK_REVISION=`aws ecs describe-task-definition --task-definition ${SERVICE_NAME}${TASK_SUFFIX} | egrep "revision" | tr "/" " " | awk '{print $2}' | sed 's/"$//'`
# Request service update:
- aws ecs update-service --service ${SERVICE_NAME} --cluster ${CLUSTER_NAME} --task-definition ${SERVICE_NAME}${TASK_SUFFIX}:${TASK_REVISION} --force-new-deployment
我有一個計划任務,它使用相同的服務任務定義,都使用 Fargate。 但是,當我更新我的服務的任務定義時,我必須手動將我的計划任務更新到最新版本。
每當我更新我的服務的任務定義時,我想將我的計划任務的任務定義更新為最新版本。 可能嗎?
所以對我來說這是有效的
aws events put-targets --cli-input-json file://.app_generic.json
app_generic.json
{
"Rule": "rule--app--generic",
"Targets": [
{
"Id": "app--generic",
"Arn": "arn:aws:ecs:us-east-1:xxxxxxx:cluster/my-cluster",
"RoleArn": "arn:aws:iam::xxxxxxx:role/ecsEventsRole",
"EcsParameters": {
"TaskDefinitionArn": "arn:aws:ecs:us-east-1:xxxxxxxx:task-definition/my-task-definitions",
"TaskCount": 1,
"LaunchType": "FARGATE",
"NetworkConfiguration": {
"awsvpcConfiguration": {
"Subnets": [
"subnet-xxxxx"
],
"SecurityGroups": [
"sg-xxxxxxx"
],
"AssignPublicIp": "ENABLED"
}
},
"PlatformVersion": "1.4.0"
}
}
]
}
基本上我必須重新制定規則,但是通過在 TaskDefinitionArn 中省略修訂號,它會更新為最新修訂,而其他容器參數(命令、環境變量等)仍然存在。 我想這在技術上仍然是“手動”的,但是該命令可以在 CI/CD、bash 腳本等中的服務更新后添加。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.