-
Notifications
You must be signed in to change notification settings - Fork 1
/
cluster.tf
80 lines (67 loc) · 2.44 KB
/
cluster.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
68
69
70
71
72
73
74
75
76
77
78
79
80
#Get RG
data "azurerm_resource_group" "Rg" {
name = "kubRg"
}
resource "random_string" "randomName" {
length = 4
lower = true
number = true
upper = false
special = false
}
#Create network and subnet (required by CNI plugin)
resource "azurerm_virtual_network" "vNetwork" {
name = "core-${random_string.randomName.result}"
address_space = ["10.1.0.0/16"]
dns_servers = ["1.1.1.1", "1.0.0.1"]
resource_group_name = "${data.azurerm_resource_group.Rg.name}"
location = "${data.azurerm_resource_group.Rg.location}"
tags = "${data.azurerm_resource_group.Rg.tags}"
subnet {
name = "kubSubnet-${random_string.randomName.result}"
address_prefix = "10.1.0.0/24"
}
}
#Create a container registry storage account (only for Classic SKU, deprecated)
/*
resource "azurerm_storage_account" "storacc" {
name = "stor${random_string.randomName.result}"
resource_group_name = "${data.azurerm_resource_group.Rg.name}"
location = "${data.azurerm_resource_group.Rg.location}"
account_tier = "Standard"
account_replication_type = "LRS"
tags = "${data.azurerm_resource_group.Rg.tags}"
} */
resource "azurerm_container_registry" "cr" {
name = "cr${random_string.randomName.result}"
resource_group_name = "${data.azurerm_resource_group.Rg.name}"
location = "${data.azurerm_resource_group.Rg.location}"
admin_enabled = true
sku = "Basic"
# storage_account_id = "${azurerm_storage_account.storacc.id}" (only for Classic SKU, deprecated atm)
}
resource "azurerm_kubernetes_cluster" "k8sClu" {
name = "rlk8sclu-${random_string.randomName.result}"
location = "${data.azurerm_resource_group.Rg.location}"
resource_group_name = "${data.azurerm_resource_group.Rg.name}"
dns_prefix = "${var.dnsPrefix}"
agent_pool_profile {
name = "default"
count = 2
vm_size = "Standard_D1_v2"
os_type = "Linux"
os_disk_size_gb = 30
vnet_subnet_id = "${lookup(azurerm_virtual_network.vNetwork.subnet[0], "id")}"
}
service_principal {
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
}
network_profile {
network_plugin = "azure"
}
role_based_access_control {
enabled = true
}
tags = "${data.azurerm_resource_group.Rg.tags}"
}