-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathazure_k8s.tf
76 lines (62 loc) · 1.73 KB
/
azure_k8s.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
provider "azurerm" {
features {}
}
locals {
cluster_name = "your-cluster-name"
}
resource "azurerm_resource_group" "this" {
name = local.cluster_name
location = var.location
}
resource "azurerm_virtual_network" "this" {
name = "${local.cluster_name}-vnet"
address_space = [var.vnet_address_space]
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
}
resource "azurerm_subnet" "this" {
name = "${local.cluster_name}-subnet"
resource_group_name = azurerm_resource_group.this.name
virtual_network_name = azurerm_virtual_network.this.name
address_prefixes = [var.subnet_address_prefix]
}
resource "azurerm_kubernetes_cluster" "this" {
name = local.cluster_name
location = azurerm_resource_group.this.location
resource_group_name = azurerm_resource_group.this.name
dns_prefix = local.cluster_name
default_node_pool {
name = "default"
node_count = var.node_pool_node_count
vm_size = var.node_pool_vm_size
vnet_subnet_id = azurerm_subnet.this.id
node_labels = {
your_label_key = "your_label_value"
}
}
identity {
type = "SystemAssigned"
}
network_profile {
network_plugin = "azure"
}
}
output "kubeconfig" {
value = azurerm_kubernetes_cluster.this.kube_config_raw
}
# Replace the values in the variables with your specific parameters
variable "location" {
default = "East US"
}
variable "vnet_address_space" {
default = "10.0.0.0/16"
}
variable "subnet_address_prefix" {
default = "10.0.1.0/24"
}
variable "node_pool_node_count" {
default = 3
}
variable "node_pool_vm_size" {
default = "Standard_D2_v2"
}