mirror of
https://github.com/Dannecron/netology-devops-gw-infra.git
synced 2025-12-25 23:32:35 +03:00
[stage-2] add cluster terraform-configuration
This commit is contained in:
38
terraform/cluster.tf
Normal file
38
terraform/cluster.tf
Normal file
@@ -0,0 +1,38 @@
|
||||
resource "random_shuffle" "netology-gw-subnet-random" {
|
||||
input = [yandex_vpc_subnet.netology-gw-subnet-a.id, yandex_vpc_subnet.netology-gw-subnet-b.id]
|
||||
result_count = 1
|
||||
}
|
||||
|
||||
resource "yandex_compute_instance" "k8s-cluster" {
|
||||
for_each = toset(["control", "node01", "node2"])
|
||||
|
||||
name = each.key
|
||||
|
||||
resources {
|
||||
cores = 2
|
||||
memory = 2
|
||||
}
|
||||
|
||||
boot_disk {
|
||||
initialize_params {
|
||||
image_id = "fd8kdq6d0p8sij7h5qe3" # ubuntu-20-04-lts-v20220822
|
||||
size = "20"
|
||||
}
|
||||
}
|
||||
|
||||
network_interface {
|
||||
subnet_id = random_shuffle.netology-gw-subnet-random.result
|
||||
nat = true
|
||||
}
|
||||
|
||||
metadata = {
|
||||
ssh-keys = "ubuntu:${file("~/.ssh/id_rsa.pub")}"
|
||||
}
|
||||
}
|
||||
|
||||
output "cluster_ips" {
|
||||
value = {
|
||||
internal = values(yandex_compute_instance.k8s-cluster)[*].network_interface.0.ip_address
|
||||
external = values(yandex_compute_instance.k8s-cluster)[*].network_interface.0.nat_ip_address
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user