chore(terraform): refactored configuration

This commit is contained in:
ITQ
2025-10-31 15:12:35 +03:00
parent 8351a2c667
commit 804444ab74
18 changed files with 143 additions and 171 deletions
+9 -79
View File
@@ -1,10 +1,10 @@
resource "yandex_compute_instance" "master" {
name = "master"
hostname = "master"
resource "yandex_compute_instance" "k8s_main_master" {
name = "k8s-master"
hostname = local.k8s_main_master_fqdn
description = "Salt, ansible and kubernetes master, provisions other nodes"
platform_id = "standard-v3"
zone = "ru-central1-d"
service_account_id = yandex_iam_service_account.master_vm_sa.id
service_account_id = yandex_iam_service_account.k8s_main_master_vm_sa.id
allow_recreate = true
allow_stopping_for_update = true
@@ -24,7 +24,7 @@ resource "yandex_compute_instance" "master" {
boot_disk {
initialize_params {
image_id = data.yandex_compute_image.ubuntu_2404.id
description = "Boot disk for master"
description = "Boot disk for K8S main master"
block_size = 4096
size = 10
type = "network-hdd"
@@ -34,7 +34,7 @@ resource "yandex_compute_instance" "master" {
}
secondary_disk {
disk_id = yandex_compute_disk.master_disk.id
disk_id = yandex_compute_disk.k8s_main_master_disk.id
device_name = "data"
mode = "READ_WRITE"
auto_delete = false
@@ -42,11 +42,11 @@ resource "yandex_compute_instance" "master" {
network_interface {
subnet_id = yandex_vpc_subnet.default_ru_central1_d.id
ip_address = local.master_ip
ip_address = local.k8s_main_master_ip
ipv4 = true
nat = true
dns_record {
fqdn = local.master_fqdn
fqdn = "${local.k8s_main_master_fqdn}."
ptr = true
ttl = 10
}
@@ -57,7 +57,7 @@ resource "yandex_compute_instance" "master" {
enable-oslogin = true
serial-port-enable = 1
install-unified-agent = 0
user-data = data.template_file.main_master_cloud_init.rendered
user-data = data.template_file.k8s_main_master_cloud_init.rendered
}
metadata_options {
@@ -71,73 +71,3 @@ resource "yandex_compute_instance" "master" {
placement_group_partition = 0
}
}
resource "yandex_compute_instance" "worker-minecraft" {
name = "worker-minecraft"
hostname = "worker-minecraft.internal"
description = "Worker node for Kubernetes cluster"
labels = {
"kubernetes" = "worker"
"role" = "worker"
"salt" = "minion"
}
service_account_id = yandex_iam_service_account.instance_group_vm_sa.id
platform_id = "standard-v3"
zone = "ru-central1-d"
resources {
core_fraction = 100
cores = 2
gpus = 0
memory = 8
}
boot_disk {
initialize_params {
image_id = data.yandex_compute_image.ubuntu_2404.id
description = "Boot disk"
size = 10
type = "network-hdd"
}
mode = "READ_WRITE"
}
secondary_disk {
disk_id = yandex_compute_disk.worker_minecraft_disk.id
device_name = "data"
mode = "READ_WRITE"
auto_delete = false
}
network_interface {
subnet_id = yandex_vpc_subnet.default_ru_central1_d.id
ipv4 = true
nat = false
}
network_acceleration_type = "standard"
metadata = {
enable-oslogin = true
serial-port-enable = 1
install-unified-agent = 0
user-data = data.template_file.worker_cloud_init.rendered
}
metadata_options {
aws_v1_http_endpoint = 1
aws_v1_http_token = 2
gce_http_endpoint = 1
gce_http_token = 1
}
placement_policy {
host_affinity_rules = []
placement_group_partition = 0
}
depends_on = [
yandex_compute_instance.master,
yandex_iam_service_account.instance_group_vm_sa
]
}