Skip to content

Commit 11f0168

Browse files
authored
ci: add unified-agent into github runner VM (#8474)
1 parent 05ecf8a commit 11f0168

File tree

6 files changed

+106
-6
lines changed

6 files changed

+106
-6
lines changed

ydb/ci/gh-runner-controller/src/scaler/scripts/install_runner.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,3 +49,6 @@ SVC_NAME=$(cat .service)
4949
systemctl daemon-reload || fail "failed to reload systemd"
5050
systemctl enable $SVC_NAME
5151
systemctl start $SVC_NAME
52+
53+
echo "GH_RUNNER_NAME=${RUNNER_NAME}"> /etc/default/unified_agent
54+
systemctl restart unified-agent.service

ydb/ci/gh-runner-controller/src/scaler/yc.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,9 +107,11 @@ def start_vm(self, zone_id: str, subnet_id: str, instance_name: str, preset_name
107107

108108
request = CreateInstanceRequest(
109109
name=instance_name,
110+
hostname=f'{instance_name}.auto.internal',
110111
folder_id=self.cfg.yc_folder_id,
111112
zone_id=zone_id,
112113
platform_id=preset['platform_id'],
114+
service_account_id=self.cfg.service_account_id,
113115
resources_spec=ResourcesSpec(
114116
cores=int(preset["cpu_cores"]),
115117
memory=int(preset["memory_gb"] * 1024 * 1024 * 1024),
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
storages:
2+
- name: main
3+
plugin: fs
4+
config:
5+
directory: /var/lib/yandex/unified_agent/main
6+
max_partition_size: 100mb
7+
max_segment_size: 10mb
8+
9+
channels:
10+
- name: cloud_monitoring
11+
channel:
12+
pipe:
13+
- storage_ref:
14+
name: main
15+
- filter:
16+
plugin: transform_metric_labels
17+
config:
18+
labels:
19+
- gh_runner_name: "{$env('GH_RUNNER_NAME')}"
20+
output:
21+
plugin: yc_metrics
22+
config:
23+
folder_id: "${FOLDER_ID}"
24+
iam:
25+
cloud_meta: { }
26+
27+
routes:
28+
- input:
29+
plugin: linux_metrics
30+
config:
31+
namespace: sys
32+
channel:
33+
channel_ref:
34+
name: cloud_monitoring
35+
36+
- input:
37+
plugin: agent_metrics
38+
config:
39+
namespace: ua
40+
channel:
41+
pipe:
42+
- filter:
43+
plugin: filter_metrics
44+
config:
45+
match: "{scope=health}"
46+
channel_ref:
47+
name: cloud_monitoring

ydb/ci/gh-runner-image/image.pkr.hcl

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@ source "yandex" "this" {
2020
state_timeout = "10m"
2121

2222
use_ipv4_nat = true
23+
metadata = {
24+
user-data : "#cloud-config\npackage_update: false\npackage_upgrade: false"
25+
serial-port-enable : "1"
26+
}
2327

2428
}
2529

@@ -37,7 +41,7 @@ apt-get -o DPkg::Lock::Timeout=600 -y --no-install-recommends dist-upgrade
3741
apt-get -y install --no-install-recommends \
3842
antlr3 clang-12 clang-14 cmake docker.io git jq libaio-dev libaio1 libicu70 libidn11-dev libkrb5-3 \
3943
liblttng-ust1 lld-14 llvm-14 m4 make ninja-build parallel postgresql-client postgresql-client \
40-
python-is-python3 python3-pip s3cmd s3cmd zlib1g
44+
python-is-python3 python3-pip s3cmd s3cmd zlib1g linux-tools-common linux-tools-generic
4145
4246
apt-get -y purge lxd-agent-loader snapd modemmanager
4347
apt-get -y autoremove
@@ -74,12 +78,34 @@ EOF
7478
destination = "/tmp/install-agent.sh"
7579
}
7680

81+
provisioner "file" {
82+
content = templatefile("conf/unified-agent-linux.yml", {
83+
FOLDER_ID = var.folder_id
84+
})
85+
destination = "/tmp/yc-vm.yml"
86+
}
87+
88+
provisioner "file" {
89+
content = <<EOF
90+
#!/bin/env/sh
91+
set -xe
92+
curl -s -O "https://storage.yandexcloud.net/yc-unified-agent/releases/${var.unified_agent_version}/deb/${var.unified_agent_ubuntu_name}/yandex-unified-agent_${var.unified_agent_version}_amd64.deb"
93+
dpkg -i yandex-unified-agent_${var.unified_agent_version}_amd64.deb
94+
95+
mv /tmp/yc-vm.yml /etc/yandex/unified_agent/conf.d/
96+
chown unified_agent:unified_agent /etc/yandex/unified_agent/conf.d/yc-vm.yml
97+
EOF
98+
destination = "/tmp/install-unified-agent.sh"
99+
}
100+
77101
provisioner "shell" {
78102
inline = [
79103
"sudo bash /tmp/install-packages.sh",
80104
"sudo bash /tmp/install-agent.sh",
81-
"sudo rm /tmp/install-packages.sh /tmp/install-agent.sh",
105+
"sudo bash /tmp/install-unified-agent.sh",
106+
"sudo rm /tmp/install-packages.sh /tmp/install-agent.sh /tmp/install-unified-agent.sh",
82107
"sudo time sync",
83108
]
84109
}
110+
85111
}
Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,29 @@
11
variable "folder_id" {
2-
type = string
2+
type = string
33
default = "b1grf3mpoatgflnlavjd"
44
}
55

66
variable "zone_id" {
7-
type = string
7+
type = string
88
default = "ru-central1-d"
99
}
1010

1111
variable "subnet_id" {
12-
type = string
12+
type = string
1313
default = "fl8gu1e1h8kqnlfj4uqp"
1414
}
1515

1616
variable "github_runner_version" {
17-
type = string
17+
type = string
1818
default = "2.319.1"
1919
}
20+
21+
variable "unified_agent_ubuntu_name" {
22+
type = string
23+
default = "ubuntu-22.04-jammy"
24+
}
25+
26+
variable "unified_agent_version" {
27+
type = string
28+
default = "24.07.02"
29+
}
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
resource "yandex_iam_service_account" "vm-sa" {
2+
name = "gh-runner-vm-sa"
3+
}
4+
5+
6+
resource "yandex_resourcemanager_folder_iam_binding" "vm-sa-monitoring-binding" {
7+
folder_id = var.folder_id
8+
members = [
9+
"serviceAccount:${yandex_iam_service_account.vm-sa.id}"
10+
]
11+
role = "monitoring.editor"
12+
}

0 commit comments

Comments
 (0)