mirror of
https://github.com/puppetmaster/typhoon.git
synced 2024-12-27 08:49:33 +01:00
0120b9f38d
* Drop support for `cluster_domain_suffix` customization and always use `cluster.local`. Many components in the Kubernetes ecosystem assume this default suffix and its very rare to be setting a special value here these days * Cleanup a few variables that are seldom used
114 lines
3.3 KiB
HCL
114 lines
3.3 KiB
HCL
locals {
|
|
# flatcar-stable -> Flatcar Linux Stable
|
|
channel = split("-", var.os_image)[1]
|
|
offer_suffix = var.arch == "arm64" ? "corevm" : "free"
|
|
urn = var.arch == "arm64" ? local.channel : "${local.channel}-gen2"
|
|
|
|
azure_authorized_key = var.azure_authorized_key == "" ? var.ssh_authorized_key : var.azure_authorized_key
|
|
}
|
|
|
|
# Workers scale set
|
|
resource "azurerm_orchestrated_virtual_machine_scale_set" "workers" {
|
|
name = "${var.name}-worker"
|
|
resource_group_name = var.resource_group_name
|
|
location = var.location
|
|
platform_fault_domain_count = 1
|
|
sku_name = var.vm_type
|
|
instances = var.worker_count
|
|
|
|
# storage
|
|
encryption_at_host_enabled = true
|
|
os_disk {
|
|
storage_account_type = var.disk_type
|
|
disk_size_gb = var.disk_size
|
|
caching = "ReadOnly"
|
|
# Optionally, use the ephemeral disk of the instance type (support varies)
|
|
dynamic "diff_disk_settings" {
|
|
for_each = var.ephemeral_disk ? [1] : []
|
|
content {
|
|
option = "Local"
|
|
placement = "ResourceDisk"
|
|
}
|
|
}
|
|
}
|
|
|
|
# Flatcar Container Linux
|
|
source_image_reference {
|
|
publisher = "kinvolk"
|
|
offer = "flatcar-container-linux-${local.offer_suffix}"
|
|
sku = local.urn
|
|
version = "latest"
|
|
}
|
|
|
|
dynamic "plan" {
|
|
for_each = var.arch == "arm64" ? [] : [1]
|
|
content {
|
|
publisher = "kinvolk"
|
|
product = "flatcar-container-linux-${local.offer_suffix}"
|
|
name = local.urn
|
|
}
|
|
}
|
|
|
|
# network
|
|
network_interface {
|
|
name = "nic0"
|
|
primary = true
|
|
network_security_group_id = var.security_group_id
|
|
|
|
ip_configuration {
|
|
name = "ipv4"
|
|
version = "IPv4"
|
|
primary = true
|
|
subnet_id = var.subnet_id
|
|
# backend address pool to which the NIC should be added
|
|
load_balancer_backend_address_pool_ids = var.backend_address_pool_ids.ipv4
|
|
}
|
|
ip_configuration {
|
|
name = "ipv6"
|
|
version = "IPv6"
|
|
subnet_id = var.subnet_id
|
|
# backend address pool to which the NIC should be added
|
|
load_balancer_backend_address_pool_ids = var.backend_address_pool_ids.ipv6
|
|
}
|
|
}
|
|
|
|
# boot
|
|
user_data_base64 = base64encode(data.ct_config.worker.rendered)
|
|
boot_diagnostics {
|
|
# defaults to a managed storage account
|
|
}
|
|
|
|
# Azure requires an RSA admin_ssh_key
|
|
os_profile {
|
|
linux_configuration {
|
|
admin_username = "core"
|
|
admin_ssh_key {
|
|
username = "core"
|
|
public_key = local.azure_authorized_key
|
|
}
|
|
computer_name_prefix = "${var.name}-worker"
|
|
}
|
|
}
|
|
|
|
# lifecycle
|
|
# eviction policy may only be set when priority is Spot
|
|
priority = var.priority
|
|
eviction_policy = var.priority == "Spot" ? "Delete" : null
|
|
termination_notification {
|
|
enabled = true
|
|
}
|
|
}
|
|
|
|
# Flatcar Linux worker
|
|
data "ct_config" "worker" {
|
|
content = templatefile("${path.module}/butane/worker.yaml", {
|
|
kubeconfig = indent(10, var.kubeconfig)
|
|
ssh_authorized_key = var.ssh_authorized_key
|
|
cluster_dns_service_ip = cidrhost(var.service_cidr, 10)
|
|
node_labels = join(",", var.node_labels)
|
|
node_taints = join(",", var.node_taints)
|
|
})
|
|
strict = true
|
|
snippets = var.snippets
|
|
}
|