Skip to content

Commit 4f1aa2c

Browse files
author
Gwonsoo Lee
committed
add new features and fix logging format
1 parent 0150f25 commit 4f1aa2c

File tree

15 files changed

+399
-35
lines changed

15 files changed

+399
-35
lines changed

configs/hello.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ stacks:
9898
ebs_optimized: true
9999

100100
# API Test Enabled
101-
api_test_enabled: false
101+
api_test_enabled: true
102102

103103
# instance_market_options is for spot usage
104104
# You only can choose spot as market_type.
@@ -116,7 +116,7 @@ stacks:
116116
# You can set autoscaling mixedInstancePolicy to use on demand and spot instances together.
117117
# if mixed_instance_policy is set, then `instance_market_options` will be ignored.
118118
mixed_instances_policy:
119-
enabled: true
119+
enabled: false
120120

121121
# instance type list to override the instance types in launch template.
122122
override_instance_types:
@@ -129,7 +129,7 @@ stacks:
129129

130130
# Proportion of on-demand instances.
131131
# By default, this value will be 100 which means no spot instance.
132-
#on_demand_percentage: 50
132+
on_demand_percentage: 50
133133

134134
# spot_allocation_strategy means in what strategy you want to allocate spot instances.
135135
# options could be either `lowest-price` or `capacity-optimized`.
@@ -156,9 +156,9 @@ stacks:
156156

157157
# capacity
158158
capacity:
159-
min: 2
160-
max: 2
161-
desired: 2
159+
min: 1
160+
max: 1
161+
desired: 1
162162

163163
# autoscaling means scaling policy of autoscaling group
164164
# You can find format in autoscaling block upside
@@ -277,6 +277,11 @@ api_test_template:
277277
request_per_second: 10
278278
apis:
279279
- method: GET
280-
url: https://hello.devops-art-factory.com
281-
- method: GET
282-
url: https://hello.devops-art-factory.com/notfound
280+
url: https://hello-wedapne2.weplydev.io
281+
- method: POST
282+
url: https://hello-wedapne2.weplydev.io/adduser
283+
body:
284+
- id=198355
285+
- username=Gwonsoo
286+
- test=test
287+

docs/content/en/schemas/schema.json

Lines changed: 104 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,86 @@
66
],
77
"type": "object",
88
"definitions": {
9+
"APIManifest": {
10+
"properties": {
11+
"body": {
12+
"items": {
13+
"type": "string",
14+
"default": "\"\""
15+
},
16+
"type": "array",
17+
"description": "list of body value as JSON format",
18+
"x-intellij-html-description": "list of body value as JSON format",
19+
"default": "[]"
20+
},
21+
"header": {
22+
"items": {
23+
"type": "string",
24+
"default": "\"\""
25+
},
26+
"type": "array",
27+
"description": "list of header value as JSON format",
28+
"x-intellij-html-description": "list of header value as JSON format",
29+
"default": "[]"
30+
},
31+
"method": {
32+
"type": "string",
33+
"description": "of API Call: [ GET, POST, PUT ... ]",
34+
"x-intellij-html-description": "of API Call: [ GET, POST, PUT ... ]",
35+
"default": "\"\""
36+
},
37+
"url": {
38+
"type": "string",
39+
"description": "Full URL of API",
40+
"x-intellij-html-description": "Full URL of API",
41+
"default": "\"\""
42+
}
43+
},
44+
"additionalProperties": false,
45+
"preferredOrder": [
46+
"method",
47+
"url",
48+
"body",
49+
"header"
50+
],
51+
"description": "Configuration of API test",
52+
"x-intellij-html-description": "Configuration of API test"
53+
},
54+
"APITestTemplate": {
55+
"properties": {
56+
"apis": {
57+
"items": {
58+
"$ref": "#/definitions/APIManifest"
59+
},
60+
"type": "array"
61+
},
62+
"duration": {
63+
"description": "of api test which means how long you want to test for API test",
64+
"x-intellij-html-description": "of api test which means how long you want to test for API test"
65+
},
66+
"name": {
67+
"type": "string",
68+
"description": "of test template",
69+
"x-intellij-html-description": "of test template",
70+
"default": "\"\""
71+
},
72+
"request_per_second": {
73+
"type": "integer",
74+
"description": "Request per second to call",
75+
"x-intellij-html-description": "Request per second to call",
76+
"default": "0"
77+
}
78+
},
79+
"additionalProperties": false,
80+
"preferredOrder": [
81+
"name",
82+
"duration",
83+
"request_per_second",
84+
"apis"
85+
],
86+
"description": "Templates for API Test",
87+
"x-intellij-html-description": "Templates for API Test"
88+
},
989
"AlarmConfigs": {
1090
"properties": {
1191
"alarm_actions": {
@@ -228,6 +308,12 @@
228308
"x-intellij-html-description": "Whether or not to use mixedInstancesPolicy",
229309
"default": "false"
230310
},
311+
"on_demand_base_capacity": {
312+
"type": "integer",
313+
"description": "Minimum capacity of on-demand instance",
314+
"x-intellij-html-description": "Minimum capacity of on-demand instance",
315+
"default": "0"
316+
},
231317
"on_demand_percentage": {
232318
"type": "integer",
233319
"description": "Percentage of On Demand instance",
@@ -267,9 +353,10 @@
267353
"preferredOrder": [
268354
"enabled",
269355
"override_instance_types",
356+
"on_demand_base_capacity",
270357
"on_demand_percentage",
271-
"spot_allocation_strategy",
272358
"spot_instance_pools",
359+
"spot_allocation_strategy",
273360
"spot_max_price"
274361
],
275362
"description": "of autoscaling group",
@@ -329,8 +416,8 @@
329416
},
330417
"region": {
331418
"type": "string",
332-
"description": "name",
333-
"x-intellij-html-description": "name",
419+
"description": "AWS region ID",
420+
"x-intellij-html-description": "AWS region ID",
334421
"default": "\"\""
335422
},
336423
"scheduled_actions": {
@@ -521,6 +608,12 @@
521608
"description": "CloudWatch alarm for autoscaling action",
522609
"x-intellij-html-description": "CloudWatch alarm for autoscaling action"
523610
},
611+
"api_test_enabled": {
612+
"type": "boolean",
613+
"description": "Whether or not to run API test",
614+
"x-intellij-html-description": "Whether or not to run API test",
615+
"default": "false"
616+
},
524617
"assume_role": {
525618
"type": "string",
526619
"description": "IAM Role ARN for assume role",
@@ -638,6 +731,7 @@
638731
"assume_role",
639732
"polling_interval",
640733
"ebs_optimized",
734+
"api_test_enabled",
641735
"instance_market_options",
642736
"mixed_instances_policy",
643737
"block_devices",
@@ -676,6 +770,11 @@
676770
},
677771
"YamlConfig": {
678772
"properties": {
773+
"api_test_template": {
774+
"$ref": "#/definitions/APITestTemplate",
775+
"description": "API Test configuration",
776+
"x-intellij-html-description": "API Test configuration"
777+
},
679778
"name": {
680779
"type": "string",
681780
"description": "Application Name",
@@ -720,7 +819,8 @@
720819
"userdata",
721820
"tags",
722821
"scheduled_actions",
723-
"stacks"
822+
"stacks",
823+
"api_test_template"
724824
],
725825
"description": "Yaml configuration from manifest file",
726826
"x-intellij-html-description": "Yaml configuration from manifest file"
Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
---
2+
name: hello
3+
userdata:
4+
type: local
5+
path: scripts/userdata.sh
6+
7+
autoscaling: &autoscaling_policy
8+
- name: scale_out
9+
adjustment_type: ChangeInCapacity
10+
scaling_adjustment: 1
11+
cooldown: 60
12+
- name: scale_in
13+
adjustment_type: ChangeInCapacity
14+
scaling_adjustment: -1
15+
cooldown: 180
16+
17+
alarms: &autoscaling_alarms
18+
- name: scale_out_on_util
19+
namespace: AWS/EC2
20+
metric: CPUUtilization
21+
statistic: Average
22+
comparison: GreaterThanOrEqualToThreshold
23+
threshold: 50
24+
period: 120
25+
evaluation_periods: 2
26+
alarm_actions:
27+
- scale_out
28+
- name: scale_in_on_util
29+
namespace: AWS/EC2
30+
metric: CPUUtilization
31+
statistic: Average
32+
comparison: LessThanOrEqualToThreshold
33+
threshold: 30
34+
period: 300
35+
evaluation_periods: 3
36+
alarm_actions:
37+
- scale_in
38+
39+
# Tags should be like "key=value"
40+
tags:
41+
- project=test
42+
- repo=hello-deploy
43+
44+
stacks:
45+
- stack: artd
46+
polling_interval: 30s
47+
account: dev
48+
env: dev
49+
assume_role: ""
50+
replacement_type: BlueGreen
51+
iam_instance_profile: 'app-hello-profile'
52+
ansible_tags: all
53+
ebs_optimized: true
54+
api_test_enabled: true
55+
instance_market_options:
56+
market_type: spot
57+
spot_options:
58+
block_duration_minutes: 180
59+
instance_interruption_behavior: terminate # terminate / stop / hibernate
60+
max_price: 0.3
61+
spot_instance_type: one-time # one-time or persistent
62+
block_devices:
63+
- device_name: /dev/xvda
64+
volume_size: 10
65+
volume_type: "gp2"
66+
- device_name: /dev/xvdb
67+
volume_type: "st1"
68+
volume_size: 500
69+
capacity:
70+
min: 1
71+
max: 2
72+
desired: 1
73+
autoscaling: *autoscaling_policy
74+
alarms: *autoscaling_alarms
75+
lifecycle_callbacks:
76+
pre_terminate_past_cluster:
77+
- service hello stop
78+
79+
regions:
80+
- region: ap-northeast-2
81+
instance_type: t3.medium
82+
ssh_key: test-master-key
83+
ami_id: ami-01288945bd24ed49a
84+
use_public_subnets: true
85+
vpc: vpc-artd_apnortheast2
86+
detailed_monitoring_enabled: false
87+
security_groups:
88+
- hello-artd_apnortheast2
89+
- default-artd_apnortheast2
90+
healthcheck_target_group: hello-artdapne2-ext
91+
availability_zones:
92+
- ap-northeast-2a
93+
- ap-northeast-2b
94+
- ap-northeast-2c
95+
target_groups:
96+
- hello-artdapne2-ext
97+
98+
99+
api_test_template:
100+
name: api-test
101+
duration: 5s
102+
request_per_second: 10
103+
apis:
104+
- method: GET
105+
url: https://example.com
106+
- method: POST
107+
url: https://example.com/post
108+
body:
109+
- id=1234
110+
- username=art
111+
- test=test

pkg/aws/ec2.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -560,10 +560,10 @@ func (e EC2Client) CreateAutoScalingGroup(name, launchTemplateName, healthcheckT
560560
if mixedInstancePolicy.Enabled {
561561
input.MixedInstancesPolicy = &autoscaling.MixedInstancesPolicy{
562562
InstancesDistribution: &autoscaling.InstancesDistribution{
563-
OnDemandBaseCapacity: aws.Int64(mixedInstancePolicy.OnDemandBaseCapacity),
564-
SpotAllocationStrategy: aws.String(mixedInstancePolicy.SpotAllocationStrategy),
565-
SpotInstancePools: aws.Int64(mixedInstancePolicy.SpotInstancePools),
566-
SpotMaxPrice: aws.String(mixedInstancePolicy.SpotMaxPrice),
563+
OnDemandBaseCapacity: aws.Int64(mixedInstancePolicy.OnDemandBaseCapacity),
564+
SpotAllocationStrategy: aws.String(mixedInstancePolicy.SpotAllocationStrategy),
565+
SpotInstancePools: aws.Int64(mixedInstancePolicy.SpotInstancePools),
566+
SpotMaxPrice: aws.String(mixedInstancePolicy.SpotMaxPrice),
567567
},
568568
LaunchTemplate: &autoscaling.LaunchTemplate{
569569
LaunchTemplateSpecification: &lt,

0 commit comments

Comments
 (0)