-
Notifications
You must be signed in to change notification settings - Fork 8
/
manager.tf
67 lines (58 loc) · 2.88 KB
/
manager.tf
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
resource "azurerm_network_interface" "manager" {
count = var.add_managers == "yes" ? var.manager_count : "0"
name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
location = data.azurerm_resource_group.main.location
resource_group_name = data.azurerm_resource_group.main.name
network_security_group_id = var.manager_network_security_group_id
ip_configuration {
name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
subnet_id = data.azurerm_subnet.subnet.id
private_ip_address_allocation = "dynamic"
}
}
resource "azurerm_network_interface_backend_address_pool_association" "manager" {
count = var.add_manager_lb == "yes" ? var.manager_count : "0"
network_interface_id = element(azurerm_network_interface.manager.*.id, count.index)
ip_configuration_name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
backend_address_pool_id = var.manager_lb_address_pool_id
}
resource "azurerm_virtual_machine" "manager" {
count = var.add_managers == "yes" ? var.manager_count : "0"
name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
location = data.azurerm_resource_group.main.location
availability_set_id = azurerm_availability_set.managers.id
resource_group_name = data.azurerm_resource_group.main.name
network_interface_ids = [element(azurerm_network_interface.manager.*.id, count.index)]
vm_size = var.manager_vm_size
delete_os_disk_on_termination = true
delete_data_disks_on_termination = true
storage_image_reference {
id = data.azurerm_image.k8s.id
}
storage_os_disk {
name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
caching = "ReadWrite"
create_option = "FromImage"
managed_disk_type = "Standard_LRS"
}
os_profile {
computer_name = "${var.cluster_name}-${var.environment}-${var.name_suffix}-${format("manager%d", count.index + 1)}"
admin_username = "ubuntu"
admin_password = "ef208a6b-a6b0-47f0-be8f-2d2bd2e640ba"
}
os_profile_linux_config {
disable_password_authentication = true
ssh_keys {
path = "/home/ubuntu/.ssh/authorized_keys"
key_data = var.ssh_public_key
}
}
tags = merge(
var.default_tags,
{
"environmentinfo" = "T:Prod; N:${var.cluster_name}-${var.environment}-${var.name_suffix}"
"cluster" = "${var.cluster_name}-${var.environment}-${var.name_suffix}"
"role" = "manager"
},
)
}