Skip to content

Commit 9145620

Browse files
committed
Revert "fix: datadog 에이전트를 사이드카로 수정"
This reverts commit d0199f1.
1 parent 4f905ee commit 9145620

File tree

2 files changed

+118
-86
lines changed

2 files changed

+118
-86
lines changed

terraform/dev/locals.tf

Lines changed: 51 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -63,71 +63,57 @@ locals {
6363
}
6464

6565
container_definitions_map = {
66-
for svc, task_def in local.task_definitions_with_roles : svc =>
67-
(svc == "api-dev" ?
68-
[
69-
{
70-
name = "api-dev"
71-
image = "${local.ecr_repo_urls["dev"]}:placeholder"
72-
cpu = task_def.cpu
73-
memory = contains(keys(task_def), "memory") ? task_def.memory : null
74-
essential = true
75-
command = [
76-
"java", "-javaagent:/dd-java-agent.jar",
77-
"-Ddd.logs.injection=true", "-Ddd.runtime-metrics.enabled=true",
78-
"-Ddd.service=eatda-api", "-Ddd.env=dev", "-Ddd.version=v1",
79-
"-Ddd.agent.host=127.0.0.1",
80-
"-Dspring.profiles.active=dev", "-jar", "/api.jar"
81-
]
82-
portMappings = [{ containerPort = 8080, hostPort = 0, protocol = "tcp" }]
83-
mountPoints = [{ sourceVolume = "dev-api-volume", containerPath = "/logs", readOnly = false }]
84-
},
85-
{
86-
name = "datadog-agent"
87-
image = "public.ecr.aws/datadog/agent:latest"
88-
cpu = 256
89-
memory = 128
90-
essential = true
91-
environment = [
92-
{ name = "DD_SITE", value = "us5.datadoghq.com" },
93-
{ name = "DD_PROCESS_AGENT_ENABLED", value = "true" },
94-
{ name = "DD_APM_ENABLED", value = "true" },
95-
{ name = "DD_LOGS_ENABLED", value = "true" },
96-
{ name = "DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL", value = "true" },
97-
{ name = "DD_DOGSTATSD_NON_LOCAL_TRAFFIC", value = "false" },
98-
]
99-
secrets = [{ name = "DD_API_KEY", valueFrom = "/dev/DD_API_KEY" }]
100-
mountPoints = [
101-
{ sourceVolume = "docker_sock", containerPath = "/var/run/docker.sock", readOnly = true },
102-
{ sourceVolume = "proc", containerPath = "/host/proc", readOnly = true },
103-
{ sourceVolume = "cgroup", containerPath = "/host/sys/fs/cgroup", readOnly = true }
104-
]
105-
}
106-
]
107-
:
108-
[
109-
{
110-
name = svc
111-
image = task_def.container_image
112-
cpu = task_def.cpu
113-
memory = task_def.memory
114-
essential = true
115-
portMappings = [
116-
for m in lookup(task_def, "port_mappings", []) :
117-
{ containerPort = m.container_port, hostPort = m.host_port, protocol = m.protocol }
118-
]
119-
environment = [for k, v in lookup(task_def, "environment", {}) : { name = k, value = v }]
120-
secrets = [for s in lookup(task_def, "secrets", []) : { name = s.name, valueFrom = s.valueFrom }]
121-
mountPoints = [
122-
for vol in lookup(task_def, "volumes", []) : {
123-
sourceVolume = vol.name
124-
containerPath = (svc == "mysql-dev" && vol.name == "dev-mysql-volume") ? "/var/lib/mysql" :
125-
vol.containerPath
126-
readOnly = false
127-
}
128-
]
129-
}
130-
])
66+
for svc, def in local.task_definitions_with_roles : svc => [
67+
{
68+
name = svc
69+
image = svc == "api-dev" ? "${local.ecr_repo_urls["dev"]}:placeholder" : def.container_image
70+
cpu = def.cpu
71+
memory = def.memory
72+
essential = true
73+
stopTimeout = lookup(def, "stop_timeout", 30)
74+
command = svc == "api-dev" ? [
75+
"java",
76+
"-javaagent:/dd-java-agent.jar",
77+
"-Ddd.logs.injection=true",
78+
"-Ddd.runtime-metrics.enabled=true",
79+
"-Ddd.service=eatda-api",
80+
"-Ddd.env=dev",
81+
"-Ddd.version=v1",
82+
"-Ddd.agent.host=10.0.7.245",
83+
"-Dspring.profiles.active=dev",
84+
"-jar",
85+
"/api.jar"
86+
] : null
87+
portMappings = [
88+
for m in lookup(def, "port_mappings", []) : {
89+
name = "${svc}-${m.container_port}-${m.protocol}"
90+
containerPort = m.container_port
91+
hostPort = m.host_port
92+
protocol = m.protocol
93+
}
94+
]
95+
environment = [for k, v in lookup(def, "environment", {}) : { name = k, value = v }]
96+
secrets = svc == "datadog-agent-task" ? [
97+
{ name = "DD_API_KEY", valueFrom = "/dev/DD_API_KEY" }
98+
] : (svc == "mysql-dev" ? [
99+
{ name = "MYSQL_USER", valueFrom = "/dev/MYSQL_USER_NAME" },
100+
{ name = "MYSQL_ROOT_PASSWORD", valueFrom = "/dev/MYSQL_ROOT_PASSWORD" },
101+
{ name = "MYSQL_PASSWORD", valueFrom = "/dev/MYSQL_PASSWORD" }
102+
] : [
103+
for s in lookup(def, "secrets", []) : {
104+
name = s.name
105+
valueFrom = s.valueFrom
106+
}
107+
])
108+
mountPoints = [
109+
for vol in lookup(def, "volumes", []) : {
110+
sourceVolume = vol.name
111+
containerPath = vol.containerPath
112+
readOnly = vol.readOnly
113+
}
114+
]
115+
}
116+
]
131117
}
132118

133119
final_ecs_definitions_for_module = {

terraform/dev/terraform.tfvars

Lines changed: 67 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,18 @@ ecs_services = {
1111
mysql-dev = {
1212
task_definition = "mysql"
1313
}
14+
15+
datadog-agent-task = {
16+
task_definition = "datadog-agent-task"
17+
scheduling_strategy = "DAEMON"
18+
}
1419
}
1520

1621
ecs_task_definitions_base = {
1722
api-dev = {
18-
cpu = 512
19-
memoryReservation = 384
20-
network_mode = "bridge"
23+
cpu = 256
24+
memory = 256
25+
network_mode = "bridge"
2126
requires_compatibilities = ["EC2"]
2227

2328
port_mappings = [
@@ -31,24 +36,10 @@ ecs_task_definitions_base = {
3136
environment = {}
3237
volumes = [
3338
{
34-
name = "dev-api-volume"
35-
host_path = "/home/ec2-user/logs/"
36-
readOnly = false
37-
},
38-
{
39-
name = "docker_sock"
40-
host_path = "/var/run/docker.sock"
41-
readOnly = true
42-
},
43-
{
44-
name = "proc"
45-
host_path = "/proc/"
46-
readOnly = true
47-
},
48-
{
49-
name = "cgroup"
50-
host_path = "/sys/fs/cgroup/"
51-
readOnly = true
39+
name = "dev-api-volume"
40+
host_path = "/home/ec2-user/logs/"
41+
containerPath = "/logs"
42+
readOnly = false
5243
}
5344
]
5445
}
@@ -95,4 +86,59 @@ ecs_task_definitions_base = {
9586
}
9687
]
9788
}
89+
90+
"datadog-agent-task" = {
91+
cpu = 256
92+
memory = 128
93+
network_mode = "bridge"
94+
requires_compatibilities = ["EC2"]
95+
container_image = "public.ecr.aws/datadog/agent:latest"
96+
97+
port_mappings = [
98+
{
99+
container_port = 8126,
100+
host_port = 8126,
101+
protocol = "tcp"
102+
},
103+
{
104+
container_port = 8125,
105+
host_port = 8125,
106+
protocol = "udp"
107+
}
108+
]
109+
110+
environment = {
111+
DD_SITE = "us5.datadoghq.com"
112+
DD_PROCESS_AGENT_ENABLED = "true"
113+
DD_APM_ENABLED = "true"
114+
DD_LOGS_ENABLED = "true"
115+
DD_LOGS_CONFIG_CONTAINER_COLLECT_ALL = "true"
116+
DD_EC2_USE_IMDSV2 = "true"
117+
DD_DOGSTATSD_NON_LOCAL_TRAFFIC = "true"
118+
DD_SERVICE = "eatda-api"
119+
DD_ENV = "dev"
120+
DD_VERSION = "v1"
121+
}
122+
123+
volumes = [
124+
{
125+
name = "docker_sock"
126+
host_path = "/var/run/docker.sock"
127+
containerPath = "/var/run/docker.sock"
128+
readOnly = true
129+
},
130+
{
131+
name = "proc"
132+
host_path = "/proc/"
133+
containerPath = "/host/proc"
134+
readOnly = true
135+
},
136+
{
137+
name = "cgroup"
138+
host_path = "/sys/fs/cgroup/"
139+
containerPath = "/host/sys/fs/cgroup"
140+
readOnly = true
141+
}
142+
]
143+
}
98144
}

0 commit comments

Comments
 (0)