Gallery fixes

This commit is contained in:
Serge Logvinov
2022-05-24 09:19:57 +03:00
parent a255c28c16
commit 69d128a1ea
6 changed files with 101 additions and 88 deletions

View File

@@ -4,3 +4,10 @@
# name = "talos-amd64-${each.key}" # name = "talos-amd64-${each.key}"
# resource_group_name = local.resource_group # resource_group_name = local.resource_group
# } # }
data "azurerm_shared_image_version" "talos" {
name = "latest"
image_name = "talos"
gallery_name = "293f5f4eea925204"
resource_group_name = local.resource_group
}

View File

@@ -68,6 +68,9 @@ resource "azurerm_storage_blob" "talos" {
storage_container_name = azurerm_storage_container.images.name storage_container_name = azurerm_storage_container.images.name
type = "Page" type = "Page"
source = "${path.module}/disk.vhd" source = "${path.module}/disk.vhd"
metadata = {
md5 = filemd5("${path.module}/disk.vhd")
}
} }
resource "azurerm_image" "talos" { resource "azurerm_image" "talos" {
@@ -88,16 +91,20 @@ resource "azurerm_image" "talos" {
} }
resource "azurerm_shared_image_version" "talos" { resource "azurerm_shared_image_version" "talos" {
name = "0.0.2" name = "0.0.3"
location = var.regions[0] location = var.regions[0]
resource_group_name = data.azurerm_resource_group.kubernetes.name resource_group_name = data.azurerm_resource_group.kubernetes.name
gallery_name = azurerm_shared_image.talos.gallery_name gallery_name = azurerm_shared_image.talos.gallery_name
image_name = azurerm_shared_image.talos.name image_name = azurerm_shared_image.talos.name
managed_image_id = azurerm_image.talos.id managed_image_id = azurerm_image.talos.id
target_region { dynamic "target_region" {
name = var.regions[0] for_each = var.regions
regional_replica_count = 1
storage_account_type = "Standard_LRS" content {
name = target_region.value
regional_replica_count = 1
storage_account_type = "Standard_LRS"
}
} }
} }

View File

@@ -21,9 +21,9 @@ module "controlplane" {
instance_count = lookup(try(var.controlplane[each.key], {}), "count", 0) instance_count = lookup(try(var.controlplane[each.key], {}), "count", 0)
instance_resource_group = local.resource_group instance_resource_group = local.resource_group
instance_type = lookup(try(var.controlplane[each.key], {}), "instance_type", "Standard_B2s") instance_type = lookup(try(var.controlplane[each.key], {}), "instance_type", "Standard_B2s")
# instance_image = data.azurerm_image.talos[each.key].id instance_image = data.azurerm_shared_image_version.talos.id
instance_tags = merge(var.tags, { type = "infra" }) instance_tags = merge(var.tags, { type = "infra" })
instance_secgroup = local.network_secgroup[each.key].controlplane instance_secgroup = local.network_secgroup[each.key].controlplane
instance_params = merge(var.kubernetes, { instance_params = merge(var.kubernetes, {
lbv4 = local.network_public[each.key].controlplane_lb[0] lbv4 = local.network_public[each.key].controlplane_lb[0]
lbv6 = try(local.network_public[each.key].controlplane_lb[1], "") lbv6 = try(local.network_public[each.key].controlplane_lb[1], "")

View File

@@ -55,13 +55,13 @@ resource "azurerm_linux_virtual_machine_scale_set" "web" {
disk_size_gb = 50 disk_size_gb = 50
} }
# source_image_id = data.azurerm_image.talos[each.key].id source_image_id = data.azurerm_shared_image_version.talos.id
source_image_reference { # source_image_reference {
publisher = "talos" # publisher = "talos"
offer = "Talos" # offer = "Talos"
sku = "1.0-dev" # sku = "1.0-dev"
version = "latest" # version = "latest"
} # }
tags = merge(var.tags, { type = "web" }) tags = merge(var.tags, { type = "web" })

View File

@@ -1,84 +1,83 @@
# locals { locals {
# worker_labels = "topology.kubernetes.io/zone=azure,project.io/node-pool=worker" worker_labels = "topology.kubernetes.io/zone=azure,project.io/node-pool=worker"
# } }
# resource "azurerm_linux_virtual_machine_scale_set" "worker" { resource "azurerm_linux_virtual_machine_scale_set" "worker" {
# for_each = { for idx, name in local.regions : name => idx } for_each = { for idx, name in local.regions : name => idx }
# location = each.key location = each.key
# instances = lookup(try(var.instances[each.key], {}), "worker_count", 0) instances = lookup(try(var.instances[each.key], {}), "worker_count", 0)
# name = "worker-${lower(each.key)}" name = "worker-${lower(each.key)}"
# computer_name_prefix = "worker-${lower(each.key)}-" computer_name_prefix = "worker-${lower(each.key)}-"
# resource_group_name = local.resource_group resource_group_name = local.resource_group
# sku = lookup(try(var.instances[each.key], {}), "worker_instance_type", "Standard_B2s") sku = lookup(try(var.instances[each.key], {}), "worker_instance_type", "Standard_B2s")
# extensions_time_budget = "PT30M" provision_vm_agent = false
# provision_vm_agent = false overprovision = false
# # availability_set_id = var.instance_availability_set
# network_interface { # availability_set_id = var.instance_availability_set
# name = "worker-${lower(each.key)}"
# primary = true
# ip_configuration {
# name = "worker-${lower(each.key)}-v4"
# primary = true
# version = "IPv4"
# subnet_id = local.network_private[each.key].network_id
# }
# ip_configuration {
# name = "worker-${lower(each.key)}-v6"
# version = "IPv6"
# subnet_id = local.network_private[each.key].network_id
# }
# }
# custom_data = base64encode(templatefile("${path.module}/templates/worker.yaml.tpl", network_interface {
# merge(var.kubernetes, { name = "worker-${lower(each.key)}"
# lbv4 = local.network_public[each.key].controlplane_lb[0] primary = true
# labels = "topology.kubernetes.io/region=${each.key},${local.worker_labels}" ip_configuration {
# nodeSubnets = [local.network_private[each.key].cidr[0]] name = "worker-${lower(each.key)}-v4"
# }) primary = true
# )) version = "IPv4"
subnet_id = local.network_private[each.key].network_id
}
ip_configuration {
name = "worker-${lower(each.key)}-v6"
version = "IPv6"
subnet_id = local.network_private[each.key].network_id
}
}
# os_disk { custom_data = base64encode(templatefile("${path.module}/templates/worker.yaml.tpl",
# caching = "ReadOnly" merge(var.kubernetes, {
# storage_account_type = "StandardSSD_LRS" lbv4 = local.network_public[each.key].controlplane_lb[0]
# disk_size_gb = 50 labels = "topology.kubernetes.io/region=${each.key},${local.worker_labels}"
nodeSubnets = [local.network_private[each.key].cidr[0]]
})
))
# dynamic "diff_disk_settings" { admin_username = "talos"
# for_each = var.vm_os_ephemeral ? ["Local"] : [] admin_ssh_key {
# content { username = "talos"
# option = diff_disk_settings.value public_key = file("~/.ssh/terraform.pub")
# placement = "ResourceDisk" }
# }
# }
# }
# disable_password_authentication = false os_disk {
# admin_password = "talos4PWD" caching = "ReadOnly"
# admin_username = "talos" storage_account_type = "StandardSSD_LRS"
# admin_ssh_key { disk_size_gb = 50
# username = "talos"
# public_key = file("~/.ssh/terraform.pub")
# }
# source_image_id = data.azurerm_image.talos[each.key].id # dynamic "diff_disk_settings" {
# # source_image_reference { # for_each = lookup(try(var.instances[each.key], {}), "worker_instance_type", "Standard_B2s") var.vm_os_ephemeral ? ["Local"] : []
# # publisher = "Debian" # content {
# # offer = "debian-11" # option = diff_disk_settings.value
# # sku = "11-gen2" # placement = "ResourceDisk"
# # version = "latest" # }
# # } # }
}
# tags = merge(var.tags, { type = "worker" }) source_image_id = data.azurerm_shared_image_version.talos.id
# source_image_reference {
# publisher = "talos"
# offer = "Talos"
# sku = "1.0-dev"
# version = "latest"
# }
# automatic_instance_repair { tags = merge(var.tags, { type = "worker" })
# ~ enabled = true
# ~ grace_period = "PT30M"
# }
# boot_diagnostics {} # automatic_instance_repair {
# lifecycle { # enabled = true
# ignore_changes = [admin_username, admin_ssh_key, os_disk, source_image_id, tags] # grace_period = "PT30M"
# } # }
# }
boot_diagnostics {}
lifecycle {
ignore_changes = [admin_username, admin_ssh_key, os_disk, source_image_id, tags]
}
}

View File

@@ -7,6 +7,6 @@ output "controlplane_endpoints" {
output "controlplane_bootstrap" { output "controlplane_bootstrap" {
description = "Kubernetes controlplane bootstrap command" description = "Kubernetes controlplane bootstrap command"
value = var.instance_count > 0 ? "talosctl apply-config --insecure --nodes ${try([for ip in azurerm_public_ip.controlplane_v4 : ip.ip_address if ip.ip_address != ""], [])[0]} --file _cfgs/controlplane-${lower(var.region)}-1.yaml" : "" value = var.instance_count > 0 ? "talosctl apply-config --insecure --nodes ${try([for ip in azurerm_public_ip.controlplane_v4 : ip.ip_address], [""])[0]} --file _cfgs/controlplane-${lower(var.region)}-1.yaml" : ""
depends_on = [azurerm_linux_virtual_machine.controlplane] depends_on = [azurerm_linux_virtual_machine.controlplane]
} }