bootstrap fixes

This commit is contained in:
Serge Logvinov
2022-05-26 19:52:31 +03:00
parent f03c07d3b0
commit dd6a88f3fe
12 changed files with 29 additions and 26 deletions

View File

@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "3.6.0" version = "3.7.0"
} }
} }
} }

View File

@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "3.6.0" version = "3.7.0"
} }
} }
} }

View File

@@ -6,7 +6,7 @@ resource "azurerm_availability_set" "controlplane" {
resource_group_name = local.resource_group resource_group_name = local.resource_group
platform_update_domain_count = 1 platform_update_domain_count = 1
platform_fault_domain_count = 1 platform_fault_domain_count = 2
tags = merge(var.tags, { type = "infra" }) tags = merge(var.tags, { type = "infra" })
} }

View File

@@ -51,8 +51,8 @@ resource "azurerm_linux_virtual_machine_scale_set" "worker" {
os_disk { os_disk {
caching = "ReadOnly" caching = "ReadOnly"
storage_account_type = "StandardSSD_LRS" storage_account_type = lookup(try(var.instances[each.key], {}), "worker_os_ephemeral", false) ? "Standard_LRS" : "StandardSSD_LRS"
disk_size_gb = lookup(try(var.instances[each.key], {}), "worker_os_ephemeral", false) ? null : 50 disk_size_gb = lookup(try(var.instances[each.key], {}), "worker_os_ephemeral", false) ? 50 : 50
dynamic "diff_disk_settings" { dynamic "diff_disk_settings" {
for_each = lookup(try(var.instances[each.key], {}), "worker_os_ephemeral", false) ? ["Local"] : [] for_each = lookup(try(var.instances[each.key], {}), "worker_os_ephemeral", false) ? ["Local"] : []
@@ -83,6 +83,6 @@ resource "azurerm_linux_virtual_machine_scale_set" "worker" {
boot_diagnostics {} boot_diagnostics {}
lifecycle { lifecycle {
ignore_changes = [instances, admin_username, admin_ssh_key, os_disk, source_image_id] ignore_changes = [instances, admin_username, admin_ssh_key, source_image_id]
} }
} }

View File

@@ -81,7 +81,6 @@ resource "azurerm_linux_virtual_machine" "controlplane" {
computer_name = "controlplane-${lower(var.region)}-${1 + count.index}" computer_name = "controlplane-${lower(var.region)}-${1 + count.index}"
resource_group_name = var.instance_resource_group resource_group_name = var.instance_resource_group
location = var.region location = var.region
extensions_time_budget = "PT1H30M"
size = var.instance_type size = var.instance_type
allow_extension_operations = false allow_extension_operations = false
provision_vm_agent = false provision_vm_agent = false
@@ -155,7 +154,7 @@ resource "local_file" "controlplane" {
try(azurerm_public_ip.controlplane_v6[count.index].ip_address, ""), try(azurerm_public_ip.controlplane_v6[count.index].ip_address, ""),
]) ])
ipAliases = compact([var.instance_params["lbv4"], var.instance_params["lbv6"]]) ipAliases = compact([var.instance_params["lbv4"], var.instance_params["lbv6"]])
nodeSubnets = [var.network_internal.cidr[0], "!${var.instance_params["lbv4"]}"] nodeSubnets = [cidrsubnet(var.network_internal.cidr[0], 1, 0), "!${var.instance_params["lbv4"]}"]
}) })
) )
filename = "_cfgs/controlplane-${lower(var.region)}-${1 + count.index}.yaml" filename = "_cfgs/controlplane-${lower(var.region)}-${1 + count.index}.yaml"

View File

@@ -7,6 +7,8 @@ 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], [""])[0]} --file _cfgs/controlplane-${lower(var.region)}-1.yaml" : "" value = var.instance_count > 0 ? try([
for n, ip in azurerm_public_ip.controlplane_v4 : "talosctl apply-config --insecure --nodes ${ip.ip_address} --file _cfgs/controlplane-${lower(var.region)}-${n + 1}.yaml" if ip.ip_address != ""
]) : []
depends_on = [azurerm_linux_virtual_machine.controlplane] depends_on = [azurerm_linux_virtual_machine.controlplane]
} }

View File

@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "3.6.0" version = "3.7.0"
} }
} }
} }

View File

@@ -18,6 +18,7 @@ output "network" {
description = "The network" description = "The network"
value = { for zone, net in azurerm_virtual_network.main : zone => { value = { for zone, net in azurerm_virtual_network.main : zone => {
name = net.name name = net.name
nat = try(azurerm_public_ip.nat[zone].ip_address, "")
} } } }
} }

View File

@@ -30,22 +30,22 @@ resource "azurerm_network_security_group" "controlplane" {
protocol = "Tcp" protocol = "Tcp"
source_port_range = "*" source_port_range = "*"
source_address_prefix = security_rule.value source_address_prefix = security_rule.value
destination_port_ranges = ["6443", "50000-50001", "22"] destination_port_ranges = ["6443", "50000-50001"]
destination_address_prefix = "*" destination_address_prefix = "*"
} }
} }
security_rule { # security_rule {
name = "etcd" # name = "etcd"
priority = 1550 # priority = 1550
direction = "Inbound" # direction = "Inbound"
access = "Allow" # access = "Allow"
protocol = "Tcp" # protocol = "Tcp"
source_port_range = "*" # source_port_range = "*"
source_address_prefix = "*" # source_address_prefix = "*"
destination_port_range = "2379-2380" # destination_port_range = "2379-2380"
destination_address_prefix = "*" # destination_address_prefix = "*"
} # }
tags = merge(var.tags, { type = "infra" }) tags = merge(var.tags, { type = "infra" })
} }

View File

@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "3.6.0" version = "3.7.0"
} }
} }
} }

View File

@@ -51,7 +51,8 @@ cluster:
node-cidr-mask-size-ipv4: 24 node-cidr-mask-size-ipv4: 24
node-cidr-mask-size-ipv6: 112 node-cidr-mask-size-ipv6: 112
scheduler: {} scheduler: {}
etcd: {} etcd:
subnet: ${nodeSubnets[0]}
inlineManifests: inlineManifests:
- name: azure-cloud-controller-config - name: azure-cloud-controller-config
contents: |- contents: |-

View File

@@ -3,7 +3,7 @@ terraform {
required_providers { required_providers {
azurerm = { azurerm = {
source = "hashicorp/azurerm" source = "hashicorp/azurerm"
version = "3.6.0" version = "3.7.0"
} }
} }
} }