blob: 2572c12a6999c54c35a5b63515bab322ae613ee4 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
|
variable "project" { default = "group-gtly-bench" }
variable "benchmark_region" { default = "us-central1" }
variable "benchmark_zone" { default = "us-central1-a" }
variable "gitaly_benchmarking_instance_name" { }
variable "ssh_pubkey" { }
variable "os_image" { default = "ubuntu-os-cloud/ubuntu-2204-lts" }
variable "startup_script" {
default = <<EOF
set -e
if [ -d /src/gitaly ] ; then exit; fi
EOF
}
variable "gitaly_machine_type" { default = "t2d-standard-4" }
variable "client_machine_type" { default = "n1-standard-1" }
variable "boot_disk_size" { default = "20" }
provider "google" {
project = var.project
region = var.benchmark_region
zone = var.benchmark_zone
}
resource "google_compute_firewall" "default" {
name = "gitaly-firewall"
network = "default"
allow {
protocol = "icmp"
}
allow {
protocol = "tcp"
ports = ["8075"]
}
source_ranges = ["10.0.0.0/24"]
target_tags = ["gitaly"]
}
resource "google_compute_network" "default" {
name = "test-network"
}
data "google_compute_disk" "repository-disk" {
name = "git-repos"
project = "wchandler-a1c8fd64"
}
resource "google_compute_disk" "repository-disk" {
name = format("%s-repository-disk", var.gitaly_benchmarking_instance_name)
type = "pd-balanced"
image = format("projects/%s/global/images/git-repositories", var.project)
}
resource "google_compute_instance" "gitaly" {
name = format("%s-gitaly", var.gitaly_benchmarking_instance_name)
machine_type = var.gitaly_machine_type
boot_disk {
initialize_params {
image = var.os_image
size = var.boot_disk_size
}
}
attached_disk {
source = google_compute_disk.repository-disk.name
device_name = "repository-disk"
}
network_interface {
network = "default"
subnetwork = "default"
access_config {}
}
metadata = {
ssh-keys = format("git:%s", var.ssh_pubkey)
startup-script = <<EOF
${var.startup_script}
echo hello
EOF
}
tags = ["gitaly"]
lifecycle {
ignore_changes = [attached_disk]
}
}
resource "google_compute_instance" "client" {
name = format("%s-client", var.gitaly_benchmarking_instance_name)
machine_type = var.client_machine_type
boot_disk {
initialize_params {
image = var.os_image
size = var.boot_disk_size
}
}
network_interface {
subnetwork = "default"
access_config {}
}
metadata = {
ssh-keys = format("git:%s", var.ssh_pubkey)
startup-script = <<EOF
echo hello
EOF
}
}
output "gitaly_internal_ip" {
value = google_compute_instance.gitaly.network_interface[0].network_ip
}
output "gitaly_ssh_ip" {
value = google_compute_instance.gitaly.network_interface[0].access_config[0].nat_ip
}
output "client_internal_ip" {
value = google_compute_instance.client.network_interface[0].network_ip
}
output "client_ssh_ip" {
value = google_compute_instance.client.network_interface[0].access_config[0].nat_ip
}
|