งานที่รันตามคำขอ: Aggregate เดียว สี่เป้าหมาย
งานcore/manual-trigger ปรับ
งานcore/manual-trigger คือ Feature สำหรับcore/compute/task ที่
พื้นที่
สิ่งที่ตัวอย่างนี้บิลด์
| อินสแตนซ์ | Component ของ | การ | สิ่ง |
|---|---|---|---|
data-fix | core/compute/task | core/manual-trigger | มี |
report | core/compute/task | ไม่มี | ตาราง |
การdata-fix เป็น นักinfra Release ไม่
ตารางreport เป็นreport_schedule ที่ Aggregate ประกาศschedule ของ
spec: parameters: report_schedule: type: string default: "" [… omitted: the parameter's description]
components: [… omitted: data-fix with its attachment, and the comment above each task] report: type: core/compute/task values: schedule: "{{ .parameters.report_schedule }}"เป็นreport_schedule และ Release ของ Docker Compose ปล่อย
data-fix บิลด์
Releases หกรายการ
| Release | Manifest | report_schedule | การ |
|---|---|---|---|
release-helm.yaml | manifest-helm.yaml | 30 2 * * 1-5 | เสร็จ |
release-compose.yaml | manifest-compose.yaml | ว่าง | เสร็จ |
release-terraform.yaml | manifest-terraform.yaml | 30 2 * * 1-5 | เสร็จ |
release-cloudformation.yaml | manifest-cloudformation.yaml | 30 2 * * 1-5 | เสร็จ |
release-compose-scheduled.yaml | manifest-compose.yaml | 30 2 * * 1-5 | หยุด |
release-terraform-unscheduled.yaml | manifest-terraform.yaml | ว่าง | หยุด |
Manifest แต่ละcore/compute/task ไปcore/manual-trigger กับ FeatureRecipe ของhelm/task กับ helm/manual-trigger, compose/task กับ compose/manual-trigger, terraform/task-ecs กับ terraform/manual-trigger และ cloudformation/task-ecs กับ cloudformation/manual-trigger Manifest ที่
Release แต่ละinfra.image เพราะ core/compute/task ไม่infra.overrides ถึงreport มี
ร่างตัวอย่าง
คุณ
เขียน
aggrega draft --example task-run-on-demandจาก
cd task-run-on-demandบิลด์
พื้นที่.aggrega-config.yaml ระบุ
aggrega build --release release-helm.yaml --auto-pull # one Releaseในaggrega draft --example ไม่มี ./check.sh บิลด์ Releases ทั้ง
RELEASE EXIT EXPECTED VERDICT----------------------------------------------------------------------------------------------------release-helm.yaml 0 complete OK: completed, the files the README showsrelease-compose.yaml 0 complete OK: completed, the files the README showsrelease-terraform.yaml 0 complete OK: completed, the files the README showsrelease-cloudformation.yaml 0 complete OK: completed, the files the README showsrelease-compose-scheduled.yaml 1 halt OK: halted with the expected refusalrelease-terraform-unscheduled.yaml 1 halt OK: halted with the expected refusal
check: every build ended as expected.กับผู้ช่วย AI
ผู้
ใช้เครื่องมือของ Aggrega เท่านั้น และอย่าสร้างโฟลเดอร์เอง หากโฟลเดอร์ Workspace ยังไม่มีโฟลเดอร์ `task-run-on-demand` ให้เรียกเครื่องมือ `draft` หนึ่งครั้งโดยตั้ง `example` เป็น `task-run-on-demand` และไม่ระบุ `dir` เครื่องมือจะเขียนตัวอย่างลงในโฟลเดอร์ `task-run-on-demand` ใหม่ จากนั้นเรียกเครื่องมือ `build` โดยตั้ง `workspace_root` เป็น `task-run-on-demand` ตั้ง `release` เป็น `release-helm.yaml` ตั้ง `auto_pull` เป็น true และตั้ง `write` เป็น true แล้วบอกฉันว่าบิลด์เขียนไฟล์ใดบ้าง ไฟล์เหล่านั้นอยู่ใต้ `task-run-on-demand/dist/`Kubernetes
release-helm.yaml เขียนdata-fix เป็น CronJob ที่
apiVersion: batch/v1kind: CronJobmetadata: name: data-fix [… omitted: the labels and annotations the build writes on every resource]spec: schedule: 0 0 30 2 * suspend: true jobTemplate: spec: template: [… omitted: the pod template's metadata, the same labels again] spec: containers: - name: main image: registry.example.com/orders-data-fix:2.0.1 [… omitted: the container's CPU and memory requests and limits] restartPolicy: NeverCronJob ต้อง0 0 30 2 * ระบุ
report เป็น CronJob บน
[… omitted: apiVersion, kind and metadata, as in data-fix-cronjob.yaml under report's name]spec: schedule: 30 2 * * 1-5 jobTemplate: [… omitted: the job template, as in data-fix-cronjob.yaml with report's image]การdata-fix หนึ่ง
kubectl create job data-fix-run-1 --from=cronjob/data-fixคำ--from=cronjob/report จะreport ระหว่าง
Docker Compose
release-compose.yaml เขียนdata-fix ยังmanual ด้วย และ report ไม่มี:
services: data-fix: image: registry.example.com/orders-data-fix:2.0.1 [… omitted: the labels the build writes on every service, and the service's network] restart: "no" [… omitted: the CPU and memory limits and reservations] profiles: - manual report: image: registry.example.com/orders-report:1.4.2 [… omitted: the labels and the network, as on data-fix] restart: "no" [… omitted: the CPU and memory limits and reservations, as on data-fix][… omitted: the network the services join]Compose เริ่มdocker compose up จะreport หนึ่งdata-fix ไว้data-fix เริ่ม--rm ลบ
docker compose -f dist/compose/docker-compose.yaml run --rm data-fixTerraform
release-terraform.yaml เขียน
# Root configuration for this boundary. Each component rendered here is one# module block below, and the directory that block points at holds that# component's own files. One configuration means one dependency graph, which is# what lets a reference or a depends_on reach from one component to another.
module "data-fix" { source = "./modules/data-fix"
assign_public_ip = false cluster = "arn:aws:ecs:eu-west-1:123456789012:cluster/example-cluster" cpu = "256" environment = {} execution_role_arn = "arn:aws:iam::123456789012:role/example-ecs-task-execution" image = "registry.example.com/orders-data-fix:2.0.1" memory = "512" name = "data-fix" security_groups = ["sg-0fedcba9876543210"] subnet_ids = ["subnet-0123456789abcdef0"]}
module "report" { source = "./modules/report"
assign_public_ip = false cluster = "arn:aws:ecs:eu-west-1:123456789012:cluster/example-cluster" cpu = "256" environment = {} execution_role_arn = "arn:aws:iam::123456789012:role/example-ecs-task-execution" image = "registry.example.com/orders-report:1.4.2" memory = "512" name = "report" schedule_expression = "cron(30 2 ? * 2,3,4,5,6 *)" schedule_expression_timezone = "UTC" scheduler_role_arn = "arn:aws:iam::123456789012:role/example-scheduler" security_groups = ["sg-0fedcba9876543210"] subnet_ids = ["subnet-0123456789abcdef0"]}โมดูลdata-fix จึง
[… omitted: the provider requirement, the Region lookup, the task definition and the comments on each]resource "aws_scheduler_schedule" "this" { count = var.schedule_expression == null ? 0 : 1[… omitted: the rest of the schedule]Recipe เขียนreport ใน30 2 * * 1-5 กลายcron(30 2 ? * 2,3,4,5,6 *) โดย
CloudFormation
release-cloudformation.yaml เขียนreport เท่านั้น:
{ "AWSTemplateFormatVersion": "2010-09-09", "Resources": { "DataFixTaskDefinition": { [… omitted: the provenance metadata the build writes on every resource] "Properties": { "ContainerDefinitions": [ { "Essential": true, "Image": "registry.example.com/orders-data-fix:2.0.1", "Name": "main" } ], "Cpu": "256", "ExecutionRoleArn": "arn:aws:iam::123456789012:role/example-ecs-task-execution", "Family": "data-fix", "Memory": "512", "NetworkMode": "awsvpc", "RequiresCompatibilities": [ "FARGATE" ] }, "Type": "AWS::ECS::TaskDefinition" }, "ReportSchedule": { [… omitted: the provenance metadata] "Properties": { "FlexibleTimeWindow": { "Mode": "OFF" }, "ScheduleExpression": "cron(30 2 ? * 2,3,4,5,6 *)", "ScheduleExpressionTimezone": "UTC", "Target": { "Arn": "arn:aws:ecs:eu-west-1:123456789012:cluster/example-cluster", "EcsParameters": { [… omitted: the launch type, the network configuration and the task count each run starts with] "TaskDefinitionArn": { "Ref": "ReportTaskDefinition" } }, "RoleArn": "arn:aws:iam::123456789012:role/example-scheduler" } }, "Type": "AWS::Scheduler::Schedule" }, "ReportTaskDefinition": { [… omitted: the same shape as DataFixTaskDefinition, with report's image and family] } }}ไม่มีDataFixTaskDefinition จึง
การเริ่มการรันบน Amazon ECS
บนdata-fix เริ่มinfra.overrides:
aws ecs run-task \ --cluster arn:aws:ecs:eu-west-1:123456789012:cluster/example-cluster \ --task-definition data-fix \ --launch-type FARGATE \ --network-configuration 'awsvpcConfiguration={subnets=[subnet-0123456789abcdef0],securityGroups=[sg-0fedcba9876543210],assignPublicIp=DISABLED}'เมื่อ
สิ่งที่การบิลด์ไม่ทำ
บิลด์dist/ การ
Releases สองรายการที่หยุด
release-compose-scheduled.yaml ระบุreport_schedule บน Docker Compose และcore/manual-trigger กับ report ด้วย บน Kubernetes และ AWS งานaggrega build --release release-compose-scheduled.yaml --auto-pull จะ
[… omitted: what resolving the lockfile prints, the same halt among it][CATALOG_ERROR E0033] Recipe/FeatureRecipe assertions caused by: Recipe "task" instance "report" assertion "schedule_refused": [… omitted: the template position and the assertion's own source]: error calling fail: assertion failed: the component "report" is scheduled "30 2 * * 1-5", and Docker Compose has no scheduler: nothing in a compose file starts a service at a time, so the run would happen at none of the times written. Map core/compute/task to helm/task in the Manifest, which runs it on its schedule as a Kubernetes CronJob; or remove the schedule from the component in the Aggregate to run it once at each docker compose up, or attach core/manual-trigger to it there to start each run with docker compose run --rmrelease-terraform-unscheduled.yaml ปล่อย report_schedule ว่างreport จึงcore/manual-trigger มีaggrega build --release release-terraform-unscheduled.yaml --auto-pull หยุด
[… omitted: what resolving the lockfile prints, the same halt among it][CATALOG_ERROR E0033] Recipe/FeatureRecipe assertions caused by: Recipe "task-ecs" instance "report" assertion "schedule_translates": [… omitted: the template position and the assertion's own source]: error calling fail: assertion failed: the component "report" has no schedule and carries no core/manual-trigger attachment, so it runs once, and nothing on AWS starts a run that happens once: neither Terraform nor CloudFormation runs an Amazon ECS task when it applies, so the run would never happen. Give the component a schedule in the Aggregate; attach core/manual-trigger to it there to deploy its task definition alone, for the operator to start each run with aws ecs run-task; or map core/compute/task to helm/task in the Manifest, which runs it once on Kubernetesที่report_schedule ดังrelease-terraform.yaml ทำ