-
Notifications
You must be signed in to change notification settings - Fork 14
/
aks.tf
81 lines (65 loc) · 2.16 KB
/
aks.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
81
resource "azurerm_resource_group" "aks" {
name = "${var.resource_group_name}"
location = "${var.location}"
}
resource "azurerm_virtual_network" "vnet" {
name = "aks-vnet"
location = "${azurerm_resource_group.aks.location}"
resource_group_name = "${azurerm_resource_group.aks.name}"
address_space = ["10.1.0.0/16"]
}
resource "azurerm_subnet" "subnet" {
name = "aksnodes"
resource_group_name = "${azurerm_resource_group.aks.name}"
address_prefix = "10.1.0.0/24"
virtual_network_name = "${azurerm_virtual_network.vnet.name}"
}
resource "azurerm_kubernetes_cluster" "aks" {
name = "${var.cluster_name}"
location = "${azurerm_resource_group.aks.location}"
resource_group_name = "${azurerm_resource_group.aks.name}"
dns_prefix = "${var.dns_prefix}"
kubernetes_version = "${var.kubernetes_version}"
linux_profile {
admin_username = "azureuser"
ssh_key {
key_data = "${file("${var.ssh_public_key}")}"
}
}
agent_pool_profile {
name = "agentpool"
count = "${var.agent_count}"
vm_size = "Standard_DS2_v2"
os_type = "Linux"
os_disk_size_gb = 30
vnet_subnet_id = "${azurerm_subnet.subnet.id}"
}
service_principal {
client_id = "${var.client_id}"
client_secret = "${var.client_secret}"
}
network_profile {
network_plugin = "${var.network_plugin}"
}
role_based_access_control {
enabled = true
}
tags {
Environment = "Development"
}
provisioner "local-exec" {
command = "./helm-install.sh"
environment {
AKS_NAME = "${var.cluster_name}"
AKS_RG = "${var.resource_group_name}"
}
}
}
data "azuread_service_principal" "akssp" {
application_id = "${var.client_id}"
}
resource "azurerm_role_assignment" "netcontribrole" {
scope = "${azurerm_subnet.subnet.id}"
role_definition_name = "Network Contributor"
principal_id = "${data.azuread_service_principal.akssp.object_id}"
}