Skip to content

Commit

Permalink
Parameterize worker metadata and add outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
yamaszone committed May 14, 2019
1 parent 80d8afe commit f673228
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 9 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@

# Store service principal during development
.secrets.env

# Generated file
backend.tf
14 changes: 13 additions & 1 deletion io.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ variable "client_secret" {

variable "location" {
description = "The Azure Region in which all resources should be provisioned"
default = "westus"
default = "westus2"
}

variable "prefix" {
Expand All @@ -20,10 +20,22 @@ variable "public_ssh_key_path" {
default = "~/.ssh/id_rsa.pub"
}

output "rg_name" {
value = "${module.aks.rg_name}"
}

output "network_plugin" {
value = "${module.aks.network_plugin}"
}

output "vnet_name" {
value = "${module.aks.vnet_name}"
}

output "subnet_id" {
value = "${module.aks.subnet_id}"
}

output "service_cidr" {
value = "${module.aks.service_cidr}"
}
Expand Down
4 changes: 4 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,8 @@ module "aks" {
location = "${var.location}"
prefix = "${var.prefix}"
public_ssh_key_path = "${var.public_ssh_key_path}"
admin_username = "adminuser"
worker_count = "4"
worker_vm_type = "Standard_DS2_v2"
worker_vm_disk_size = "50"
}
30 changes: 22 additions & 8 deletions modules/aks/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ variable "client_secret" {}

variable "public_ssh_key_path" {}

variable "admin_username" {}

variable "worker_count" {}

variable "worker_vm_type" {}

variable "worker_vm_disk_size" {}

resource "azurerm_resource_group" "rg" {
name = "${var.prefix}-rg"
location = "${var.location}"
Expand Down Expand Up @@ -56,21 +64,19 @@ resource "azurerm_kubernetes_cluster" "k8s" {
resource_group_name = "${azurerm_resource_group.rg.name}"

linux_profile {
admin_username = "adminuser"
admin_username = "${var.admin_username}"

ssh_key {
key_data = "${file(var.public_ssh_key_path)}"
}
}

# TODO: parameterize pool metadata
agent_pool_profile {
#name = "${var.prefix}agentpool"
name = "agentpool"
count = "2"
vm_size = "Standard_DS2_v2"
name = "${var.prefix}agentpool"
count = "${var.worker_count}"
vm_size = "${var.worker_vm_type}"
os_type = "Linux"
os_disk_size_gb = 30
os_disk_size_gb = "${var.worker_vm_disk_size}"

# Required for advanced networking
vnet_subnet_id = "${azurerm_subnet.subnet.id}"
Expand All @@ -86,8 +92,16 @@ resource "azurerm_kubernetes_cluster" "k8s" {
}
}

output "rg_name" {
value = "${azurerm_resource_group.rg.name}"
}

output "vnet_name" {
value = "${azurerm_virtual_network.vnet.name}"
}

output "subnet_id" {
value = "${azurerm_kubernetes_cluster.k8s.agent_pool_profile.0.vnet_subnet_id}"
value = "${azurerm_subnet.subnet.id}"
}

output "network_plugin" {
Expand Down

0 comments on commit f673228

Please sign in to comment.