From 42b6173440cbd7b92e1c318d9731ece4c70c6db0 Mon Sep 17 00:00:00 2001 From: Tetsuya Kikuchi <97105818+t-kikuc@users.noreply.github.com> Date: Fri, 1 Dec 2023 21:35:29 +0900 Subject: [PATCH] Add an example of ECS canary for Service Discovery (#4691) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: t-kikuc Signed-off-by: 鈴木 優耀 --- .../servicediscovery/canary/app.pipecd.yaml | 31 +++++++++++++++++++ .../servicediscovery/canary/servicedef.yaml | 26 ++++++++++++++++ .../ecs/servicediscovery/canary/taskdef.yaml | 20 ++++++++++++ 3 files changed, 77 insertions(+) create mode 100644 examples/ecs/servicediscovery/canary/app.pipecd.yaml create mode 100644 examples/ecs/servicediscovery/canary/servicedef.yaml create mode 100644 examples/ecs/servicediscovery/canary/taskdef.yaml diff --git a/examples/ecs/servicediscovery/canary/app.pipecd.yaml b/examples/ecs/servicediscovery/canary/app.pipecd.yaml new file mode 100644 index 0000000000..9dfb0d3c28 --- /dev/null +++ b/examples/ecs/servicediscovery/canary/app.pipecd.yaml @@ -0,0 +1,31 @@ +apiVersion: pipecd.dev/v1beta1 +kind: ECSApp +spec: + name: servicediscovery-canary + labels: + env: example + team: xyz + input: + serviceDefinitionFile: servicedef.yaml + taskDefinitionFile: taskdef.yaml + # When you use ECS Service Discovery for interservice networking, you must specify 'SERVICE_DISCOVERY' for 'accessType'. + accessType: SERVICE_DISCOVERY + # 'targetGroups' is not used in Service Discovery type. + pipeline: + stages: + # Rollout CANARY variant's workload. + # scale represents the percentage of workload will be rolled out, + # in this case 30% of the current PRIMARY variant's workload is set. + # Note: Rolled out variant DOES serve traffic at this time unlike the ELB type. + - name: ECS_CANARY_ROLLOUT + with: + scale: 100 + # Hold the deployment process for 150 seconds. + - name: WAIT + with: + duration: 150s + # Update the workload of PRIMARY variant to the new version. + # NOTE: The new PRIMARY variant will serve 100% of the traffic at this time. + - name: ECS_PRIMARY_ROLLOUT + # Destroy all workloads of CANARY variant. + - name: ECS_CANARY_CLEAN \ No newline at end of file diff --git a/examples/ecs/servicediscovery/canary/servicedef.yaml b/examples/ecs/servicediscovery/canary/servicedef.yaml new file mode 100644 index 0000000000..0f2b4c5d3b --- /dev/null +++ b/examples/ecs/servicediscovery/canary/servicedef.yaml @@ -0,0 +1,26 @@ +cluster: arn:aws:ecs:ap-northeast-1:XXXX:cluster/test-cluster +serviceName: nginx-canary-service +desiredCount: 2 +deploymentConfiguration: + maximumPercent: 200 + minimumHealthyPercent: 0 +schedulingStrategy: REPLICA +# CAUTION: To enable PipeCD controls the deployment +# DeploymentController of type EXTERNAL is required. +deploymentController: + type: EXTERNAL +enableECSManagedTags: true +propagateTags: SERVICE +launchType: FARGATE +networkConfiguration: + awsvpcConfiguration: + assignPublicIp: ENABLED + securityGroups: + - sg-YYYY + subnets: + - subnet-YYYY + - subnet-YYYY +# Service Discovery Config. +serviceRegistries: + # You need to specify the service id of the service discovery namespace. + - registryArn: arn:aws:servicediscovery:ap-northeast-1:XXXX:service/srv-XXXXX \ No newline at end of file diff --git a/examples/ecs/servicediscovery/canary/taskdef.yaml b/examples/ecs/servicediscovery/canary/taskdef.yaml new file mode 100644 index 0000000000..b16de161f9 --- /dev/null +++ b/examples/ecs/servicediscovery/canary/taskdef.yaml @@ -0,0 +1,20 @@ +family: nginx-service-fam +executionRoleArn: arn:aws:iam::XXXX:role/ecsTaskExecutionRole +containerDefinitions: + - command: null + cpu: 100 + image: XXXX.dkr.ecr.ap-northeast-1.amazonaws.com/nginx:1 + memory: 100 + mountPoints: [] + name: web + portMappings: + - containerPort: 80 +compatibilities: + - FARGATE +requiresCompatibilities: + - FARGATE +networkMode: awsvpc +memory: 512 +cpu: 256 +pidMode: "" +volumes: [] \ No newline at end of file