Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit264093a

Browse files
matifalibpmct
andauthored
chore: add agent metadata to example templates (#7044)
* add `display_name`* fix typos and `terraform validate`* update display_name* Add agent metadata* add % to cpu usage* update disk usage check script* remove metadata from containers and pods workspaces* removes disk metadata from container workspaces---------Co-authored-by: Ben <me@bpmct.net>
1 parentaf24aea commit264093a

File tree

13 files changed

+388
-152
lines changed

13 files changed

+388
-152
lines changed

‎examples/templates/aws-ecs-container/main.tf‎

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.6.17"
5+
version="~> 0.7.0"
66
}
77
aws={
88
source="hashicorp/aws"
@@ -20,19 +20,21 @@ variable "ecs-cluster" {
2020
}
2121

2222
data"coder_parameter""cpu" {
23-
name="cpu"
24-
description="The number of CPU units to reserve for the container"
25-
type="number"
26-
default="1024"
27-
mutable=true
23+
name="cpu"
24+
display_name="CPU"
25+
description="The number of CPU units to reserve for the container"
26+
type="number"
27+
default="1024"
28+
mutable=true
2829
}
2930

3031
data"coder_parameter""memory" {
31-
name="memory"
32-
description="The amount of memory (in MiB) to allow the container to use"
33-
type="number"
34-
default="2048"
35-
mutable=true
32+
name="memory"
33+
display_name="Memory"
34+
description="The amount of memory (in MiB) to allow the container to use"
35+
type="number"
36+
default="2048"
37+
mutable=true
3638
}
3739

3840
# configure AWS provider with creds present on Coder server host

‎examples/templates/aws-linux/main.tf‎

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.6.17"
5+
version="~> 0.7.0"
66
}
77
aws={
88
source="hashicorp/aws"
@@ -14,10 +14,11 @@ terraform {
1414
# Last updated 2023-03-14
1515
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
1616
data"coder_parameter""region" {
17-
name="Region"
18-
description="The region to deploy the workspace in."
19-
default="us-east-1"
20-
mutable=false
17+
name="region"
18+
display_name="Region"
19+
description="The region to deploy the workspace in."
20+
default="us-east-1"
21+
mutable=false
2122
option {
2223
name="Asia Pacific (Tokyo)"
2324
value="ap-northeast-1"
@@ -106,10 +107,11 @@ data "coder_parameter" "region" {
106107
}
107108

108109
data"coder_parameter""instance_type" {
109-
name="Instance Type"
110-
description="What instance type should your workspace use?"
111-
default="t3.micro"
112-
mutable=false
110+
name="instance_type"
111+
display_name="Instance Type"
112+
description="What instance type should your workspace use?"
113+
default="t3.micro"
114+
mutable=false
113115
option {
114116
name="2 vCPU, 1 GiB RAM"
115117
value="t3.micro"
@@ -169,6 +171,40 @@ resource "coder_agent" "main" {
169171
curl -fsSL https://code-server.dev/install.sh | sh -s -- --method=standalone --prefix=/tmp/code-server --version 4.11.0
170172
/tmp/code-server/bin/code-server --auth none --port 13337 >/tmp/code-server.log 2>&1 &
171173
EOT
174+
175+
metadata {
176+
key="cpu"
177+
display_name="CPU Usage"
178+
interval=5
179+
timeout=5
180+
script=<<-EOT
181+
#!/bin/bash
182+
set -e
183+
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}'
184+
EOT
185+
}
186+
metadata {
187+
key="memory"
188+
display_name="Memory Usage"
189+
interval=5
190+
timeout=5
191+
script=<<-EOT
192+
#!/bin/bash
193+
set -e
194+
free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }'
195+
EOT
196+
}
197+
metadata {
198+
key="disk"
199+
display_name="Disk Usage"
200+
interval=600# every 10 minutes
201+
timeout=30# df can take a while on large filesystems
202+
script=<<-EOT
203+
#!/bin/bash
204+
set -e
205+
df /home/coder | awk '$NF=="/"{printf "%s", $5}'
206+
EOT
207+
}
172208
}
173209

174210
resource"coder_app""code-server" {

‎examples/templates/aws-windows/main.tf‎

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.6.17"
5+
version="~> 0.7.0"
66
}
77
aws={
88
source="hashicorp/aws"
@@ -14,10 +14,11 @@ terraform {
1414
# Last updated 2023-03-14
1515
# aws ec2 describe-regions | jq -r '[.Regions[].RegionName] | sort'
1616
data"coder_parameter""region" {
17-
name="Region"
18-
description="The region to deploy the workspace in."
19-
default="us-east-1"
20-
mutable=false
17+
name="region"
18+
display_name="Region"
19+
description="The region to deploy the workspace in."
20+
default="us-east-1"
21+
mutable=false
2122
option {
2223
name="Asia Pacific (Tokyo)"
2324
value="ap-northeast-1"
@@ -106,10 +107,11 @@ data "coder_parameter" "region" {
106107
}
107108

108109
data"coder_parameter""instance_type" {
109-
name="Instance Type"
110-
description="What instance type should your workspace use?"
111-
default="t3.micro"
112-
mutable=false
110+
name="instance_type"
111+
display_name="Instance Type"
112+
description="What instance type should your workspace use?"
113+
default="t3.micro"
114+
mutable=false
113115
option {
114116
name="2 vCPU, 1 GiB RAM"
115117
value="t3.micro"

‎examples/templates/azure-linux/main.tf‎

Lines changed: 54 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.6.17"
5+
version="~> 0.7.0"
66
}
77
azurerm={
88
source="hashicorp/azurerm"
@@ -12,11 +12,12 @@ terraform {
1212
}
1313

1414
data"coder_parameter""location" {
15-
name="Location"
16-
description="What location should your workspace live in?"
17-
default="eastus"
18-
icon="/emojis/1f310.png"
19-
mutable=false
15+
name="location"
16+
display_name="Location"
17+
description="What location should your workspace live in?"
18+
default="eastus"
19+
icon="/emojis/1f310.png"
20+
mutable=false
2021
option {
2122
name="US (Virginia)"
2223
value="eastus"
@@ -150,11 +151,12 @@ data "coder_parameter" "location" {
150151
}
151152

152153
data"coder_parameter""instance_type" {
153-
name="Instance Type"
154-
description="What instance type should your workspace use?"
155-
default="Standard_B4ms"
156-
icon="/icon/azure.png"
157-
mutable=false
154+
name="instance_type"
155+
display_name="Instance Type"
156+
description="What instance type should your workspace use?"
157+
default="Standard_B4ms"
158+
icon="/icon/azure.png"
159+
mutable=false
158160
option {
159161
name="Standard_B1ms (1 vCPU, 2 GiB RAM)"
160162
value="Standard_B1ms"
@@ -202,12 +204,13 @@ data "coder_parameter" "instance_type" {
202204
}
203205

204206
data"coder_parameter""home_size" {
205-
name="Home Volume Size"
206-
description="How large would you like your home volume to be (in GB)?"
207-
default=20
208-
type="number"
209-
icon="/icon/azure.png"
210-
mutable=false
207+
name="home_size"
208+
display_name="Home Volume Size"
209+
description="How large would you like your home volume to be (in GB)?"
210+
default=20
211+
type="number"
212+
icon="/icon/azure.png"
213+
mutable=false
211214
validation {
212215
min=1
213216
max=1024
@@ -226,6 +229,40 @@ resource "coder_agent" "main" {
226229
os="linux"
227230
auth="azure-instance-identity"
228231
login_before_ready=false
232+
233+
metadata {
234+
key="cpu"
235+
display_name="CPU Usage"
236+
interval=5
237+
timeout=5
238+
script=<<-EOT
239+
#!/bin/bash
240+
set -e
241+
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}'
242+
EOT
243+
}
244+
metadata {
245+
key="memory"
246+
display_name="Memory Usage"
247+
interval=5
248+
timeout=5
249+
script=<<-EOT
250+
#!/bin/bash
251+
set -e
252+
free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }'
253+
EOT
254+
}
255+
metadata {
256+
key="disk"
257+
display_name="Disk Usage"
258+
interval=600# every 10 minutes
259+
timeout=30# df can take a while on large filesystems
260+
script=<<-EOT
261+
#!/bin/bash
262+
set -e
263+
df /home/coder | awk '$NF=="/"{printf "%s", $5}'
264+
EOT
265+
}
229266
}
230267

231268
locals {

‎examples/templates/do-linux/main.tf‎

Lines changed: 62 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ terraform {
22
required_providers {
33
coder={
44
source="coder/coder"
5-
version="~> 0.6.17"
5+
version="~> 0.7.0"
66
}
77
digitalocean={
88
source="digitalocean/digitalocean"
@@ -52,10 +52,12 @@ variable "step2_do_admin_ssh_key" {
5252
}
5353

5454
data"coder_parameter""droplet_image" {
55-
name="Which Droplet image would you like to use for your workspace?"
56-
default="ubuntu-22-04-x64"
57-
type="string"
58-
mutable=false
55+
name="droplet_image"
56+
display_name="Droplet Image"
57+
description="Which Droplet image would you like to use?"
58+
default="ubuntu-22-04-x64"
59+
type="string"
60+
mutable=false
5961
option {
6062
name="Ubuntu 22.04"
6163
value="ubuntu-22-04-x64"
@@ -109,11 +111,13 @@ data "coder_parameter" "droplet_image" {
109111
}
110112

111113
data"coder_parameter""droplet_size" {
112-
name="Which Droplet configuration would you like to use?"
113-
default="s-1vcpu-1gb"
114-
type="string"
115-
icon="/icon/memory.svg"
116-
mutable=false
114+
name="droplet_size"
115+
display_name="Droplet Size"
116+
description="Which Droplet configuration would you like to use?"
117+
default="s-1vcpu-1gb"
118+
type="string"
119+
icon="/icon/memory.svg"
120+
mutable=false
117121
option {
118122
name="1 vCPU, 1 GB RAM"
119123
value="s-1vcpu-1gb"
@@ -142,24 +146,26 @@ data "coder_parameter" "droplet_size" {
142146

143147

144148
data"coder_parameter""home_volume_size" {
145-
name="How large would you like your home volume to be (in GB)?"
146-
description="This volume will be mounted to /home/coder."
147-
type="number"
148-
default="20"
149-
mutable=false
149+
name="home_volume_size"
150+
display_name="Home Volume Size"
151+
description="How large would you like your home volume to be (in GB)?"
152+
type="number"
153+
default="20"
154+
mutable=false
150155
validation {
151156
min=1
152157
max=999999
153158
}
154159
}
155160

156161
data"coder_parameter""region" {
157-
name="Which region would you like to use?"
158-
description="This is the region where your workspace will be created."
159-
icon="/emojis/1f30e.png"
160-
type="string"
161-
default="ams3"
162-
mutable=false
162+
name="region"
163+
display_name="Region"
164+
description="This is the region where your workspace will be created."
165+
icon="/emojis/1f30e.png"
166+
type="string"
167+
default="ams3"
168+
mutable=false
163169
option {
164170
name="New York 1"
165171
value="nyc1"
@@ -240,6 +246,41 @@ resource "coder_agent" "main" {
240246
arch="amd64"
241247

242248
login_before_ready=false
249+
250+
metadata {
251+
key="cpu"
252+
display_name="CPU Usage"
253+
interval=5
254+
timeout=5
255+
script=<<-EOT
256+
#!/bin/bash
257+
set -e
258+
top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4 "%"}'
259+
EOT
260+
}
261+
metadata {
262+
key="memory"
263+
display_name="Memory Usage"
264+
interval=5
265+
timeout=5
266+
script=<<-EOT
267+
#!/bin/bash
268+
set -e
269+
free -m | awk 'NR==2{printf "%.2f%%\t", $3*100/$2 }'
270+
EOT
271+
}
272+
metadata {
273+
key="disk"
274+
display_name="Disk Usage"
275+
interval=600# every 10 minutes
276+
timeout=30# df can take a while on large filesystems
277+
script=<<-EOT
278+
#!/bin/bash
279+
set -e
280+
df /home/coder | awk '$NF=="/"{printf "%s", $5}'
281+
EOT
282+
}
283+
243284
}
244285

245286
resource"digitalocean_volume""home_volume" {

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp