mirror of
https://github.com/edgelesssys/constellation.git
synced 2024-12-23 14:39:40 -05:00
terraform: instance_count => initial_count (#1989)
Normalize naming for the "instance_count" / "initial_count" int terraform to always use "initial_count". This is required, since there is a naming confusion on AWS. "initial_count" is more precise, since it reflects the fact that this value is ignored when applying the terraform template after the scaling groups already exist.
This commit is contained in:
parent
00ee11084e
commit
5f8ea1348a
@ -227,20 +227,20 @@ func (c *Creator) createAzure(ctx context.Context, cl terraformClient, opts Crea
|
||||
Name: opts.Config.Name,
|
||||
NodeGroups: map[string]terraform.AzureNodeGroup{
|
||||
"control_plane_default": {
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InstanceCount: toPtr(opts.ControlPlaneCount),
|
||||
InstanceType: opts.InsType,
|
||||
DiskSizeGB: opts.Config.StateDiskSizeGB,
|
||||
DiskType: opts.Config.Provider.Azure.StateDiskType,
|
||||
Zones: nil, // TODO(elchead): support zones AB#3225
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InitialCount: toPtr(opts.ControlPlaneCount),
|
||||
InstanceType: opts.InsType,
|
||||
DiskSizeGB: opts.Config.StateDiskSizeGB,
|
||||
DiskType: opts.Config.Provider.Azure.StateDiskType,
|
||||
Zones: nil, // TODO(elchead): support zones AB#3225
|
||||
},
|
||||
"worker_default": {
|
||||
Role: role.Worker.TFString(),
|
||||
InstanceCount: toPtr(opts.WorkerCount),
|
||||
InstanceType: opts.InsType,
|
||||
DiskSizeGB: opts.Config.StateDiskSizeGB,
|
||||
DiskType: opts.Config.Provider.Azure.StateDiskType,
|
||||
Zones: nil,
|
||||
Role: role.Worker.TFString(),
|
||||
InitialCount: toPtr(opts.WorkerCount),
|
||||
InstanceType: opts.InsType,
|
||||
DiskSizeGB: opts.Config.StateDiskSizeGB,
|
||||
DiskType: opts.Config.Provider.Azure.StateDiskType,
|
||||
Zones: nil,
|
||||
},
|
||||
},
|
||||
Location: opts.Config.Provider.Azure.Location,
|
||||
@ -427,18 +427,18 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, lv libvirt
|
||||
ImageFormat: opts.Config.Provider.QEMU.ImageFormat,
|
||||
NodeGroups: map[string]terraform.QEMUNodeGroup{
|
||||
"control_plane_default": {
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InstanceCount: opts.ControlPlaneCount,
|
||||
DiskSize: opts.Config.StateDiskSizeGB,
|
||||
CPUCount: opts.Config.Provider.QEMU.VCPUs,
|
||||
MemorySize: opts.Config.Provider.QEMU.Memory,
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InitialCount: opts.ControlPlaneCount,
|
||||
DiskSize: opts.Config.StateDiskSizeGB,
|
||||
CPUCount: opts.Config.Provider.QEMU.VCPUs,
|
||||
MemorySize: opts.Config.Provider.QEMU.Memory,
|
||||
},
|
||||
"worker_default": {
|
||||
Role: role.Worker.TFString(),
|
||||
InstanceCount: opts.WorkerCount,
|
||||
DiskSize: opts.Config.StateDiskSizeGB,
|
||||
CPUCount: opts.Config.Provider.QEMU.VCPUs,
|
||||
MemorySize: opts.Config.Provider.QEMU.Memory,
|
||||
Role: role.Worker.TFString(),
|
||||
InitialCount: opts.WorkerCount,
|
||||
DiskSize: opts.Config.StateDiskSizeGB,
|
||||
CPUCount: opts.Config.Provider.QEMU.VCPUs,
|
||||
MemorySize: opts.Config.Provider.QEMU.Memory,
|
||||
},
|
||||
},
|
||||
Machine: "q35", // TODO(elchead): make configurable AB#3225
|
||||
|
@ -254,7 +254,7 @@ module "instance_group" {
|
||||
zone = each.value.zone
|
||||
uid = local.uid
|
||||
instance_type = each.value.instance_type
|
||||
instance_count = each.value.instance_count
|
||||
initial_count = each.value.initial_count
|
||||
image_id = var.ami
|
||||
state_disk_type = each.value.disk_type
|
||||
state_disk_size = each.value.disk_size
|
||||
|
@ -71,7 +71,7 @@ resource "aws_autoscaling_group" "autoscaling_group" {
|
||||
}
|
||||
min_size = 1
|
||||
max_size = 10
|
||||
desired_capacity = var.instance_count
|
||||
desired_capacity = var.initial_count
|
||||
vpc_zone_identifier = [var.subnetwork]
|
||||
target_group_arns = var.target_group_arns
|
||||
|
||||
|
@ -27,7 +27,7 @@ variable "instance_type" {
|
||||
description = "Instance type for the nodes."
|
||||
}
|
||||
|
||||
variable "instance_count" {
|
||||
variable "initial_count" {
|
||||
type = number
|
||||
description = "Number of instances in the instance group."
|
||||
}
|
||||
|
@ -9,12 +9,12 @@ variable "name" {
|
||||
|
||||
variable "node_groups" {
|
||||
type = map(object({
|
||||
role = string
|
||||
instance_count = optional(number)
|
||||
instance_type = string
|
||||
disk_size = number
|
||||
disk_type = string
|
||||
zone = string
|
||||
role = string
|
||||
initial_count = optional(number)
|
||||
instance_type = string
|
||||
disk_size = number
|
||||
disk_type = string
|
||||
zone = string
|
||||
}))
|
||||
description = "A map of node group names to node group configurations."
|
||||
validation {
|
||||
|
@ -234,7 +234,7 @@ module "scale_set_group" {
|
||||
{ constellation-maa-url = var.create_maa ? azurerm_attestation_provider.attestation_provider[0].attestation_uri : "" },
|
||||
)
|
||||
|
||||
instance_count = each.value.instance_count
|
||||
initial_count = each.value.initial_count
|
||||
state_disk_size = each.value.disk_size
|
||||
state_disk_type = each.value.disk_type
|
||||
location = var.location
|
||||
|
@ -37,7 +37,7 @@ resource "azurerm_linux_virtual_machine_scale_set" "scale_set" {
|
||||
resource_group_name = var.resource_group
|
||||
location = var.location
|
||||
sku = var.instance_type
|
||||
instances = var.instance_count
|
||||
instances = var.initial_count
|
||||
admin_username = "adminuser"
|
||||
admin_password = random_password.password.result
|
||||
overprovision = false
|
||||
|
@ -28,7 +28,7 @@ variable "zones" {
|
||||
default = null
|
||||
}
|
||||
|
||||
variable "instance_count" {
|
||||
variable "initial_count" {
|
||||
type = number
|
||||
description = "The number of instances in this scale set."
|
||||
}
|
||||
|
@ -5,12 +5,12 @@ variable "name" {
|
||||
|
||||
variable "node_groups" {
|
||||
type = map(object({
|
||||
role = string
|
||||
instance_count = optional(number)
|
||||
instance_type = string
|
||||
disk_size = number
|
||||
disk_type = string
|
||||
zones = optional(list(string))
|
||||
role = string
|
||||
initial_count = optional(number)
|
||||
instance_type = string
|
||||
disk_size = number
|
||||
disk_type = string
|
||||
zones = optional(list(string))
|
||||
}))
|
||||
description = "A map of node group names to node group configurations."
|
||||
validation {
|
||||
|
@ -158,7 +158,7 @@ module "instance_group" {
|
||||
zone = each.value.zone
|
||||
uid = local.uid
|
||||
instance_type = each.value.instance_type
|
||||
instance_count = each.value.initial_count
|
||||
initial_count = each.value.initial_count
|
||||
image_id = var.image_id
|
||||
disk_size = each.value.disk_size
|
||||
disk_type = each.value.disk_type
|
||||
|
@ -112,7 +112,7 @@ resource "google_compute_instance_group_manager" "instance_group_manager" {
|
||||
description = "Instance group manager for Constellation"
|
||||
base_instance_name = local.name
|
||||
zone = var.zone
|
||||
target_size = var.instance_count
|
||||
target_size = var.initial_count
|
||||
|
||||
dynamic "stateful_disk" {
|
||||
for_each = var.role == "control-plane" ? [1] : []
|
||||
|
@ -33,7 +33,7 @@ variable "instance_type" {
|
||||
description = "Instance type for the nodes."
|
||||
}
|
||||
|
||||
variable "instance_count" {
|
||||
variable "initial_count" {
|
||||
type = number
|
||||
description = "Number of instances in the instance group."
|
||||
}
|
||||
|
@ -162,7 +162,7 @@ module "instance_group_control_plane" {
|
||||
source = "./modules/instance_group"
|
||||
name = local.name
|
||||
role = "control-plane"
|
||||
instance_count = var.control_plane_count
|
||||
initial_count = var.control_plane_count
|
||||
image_id = openstack_images_image_v2.constellation_os_image.image_id
|
||||
flavor_id = var.flavor_id
|
||||
security_groups = [openstack_compute_secgroup_v2.vpc_secgroup.id]
|
||||
@ -183,7 +183,7 @@ module "instance_group_worker" {
|
||||
source = "./modules/instance_group"
|
||||
name = local.name
|
||||
role = "worker"
|
||||
instance_count = var.worker_count
|
||||
initial_count = var.worker_count
|
||||
image_id = openstack_images_image_v2.constellation_os_image.image_id
|
||||
flavor_id = var.flavor_id
|
||||
tags = local.tags
|
||||
|
@ -20,7 +20,7 @@ locals {
|
||||
|
||||
resource "openstack_compute_instance_v2" "instance_group_member" {
|
||||
name = "${local.name}-${count.index}"
|
||||
count = var.instance_count
|
||||
count = var.initial_count
|
||||
image_id = var.image_id
|
||||
flavor_id = var.flavor_id
|
||||
security_groups = var.security_groups
|
||||
|
@ -17,7 +17,7 @@ variable "role" {
|
||||
}
|
||||
}
|
||||
|
||||
variable "instance_count" {
|
||||
variable "initial_count" {
|
||||
type = number
|
||||
description = "Number of instances in the instance group."
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ module "node_group" {
|
||||
for_each = var.node_groups
|
||||
node_group_name = each.key
|
||||
role = each.value.role
|
||||
amount = each.value.instance_count
|
||||
amount = each.value.initial_count
|
||||
state_disk_size = each.value.disk_size
|
||||
vcpus = each.value.vcpus
|
||||
memory = each.value.memory
|
||||
|
@ -1,10 +1,10 @@
|
||||
variable "node_groups" {
|
||||
type = map(object({
|
||||
role = string
|
||||
instance_count = number // number of instances in the node group
|
||||
disk_size = number // size of state disk (GiB)
|
||||
vcpus = number
|
||||
memory = number // amount of memory per instance (MiB)
|
||||
role = string
|
||||
initial_count = number // number of instances in the node group
|
||||
disk_size = number // size of state disk (GiB)
|
||||
vcpus = number
|
||||
memory = number // amount of memory per instance (MiB)
|
||||
}))
|
||||
validation {
|
||||
condition = can([for group in var.node_groups : group.role == "control-plane" || group.role == "worker"])
|
||||
|
@ -199,12 +199,12 @@ func (v *AzureClusterVariables) String() string {
|
||||
type AzureNodeGroup struct {
|
||||
// Role is the role of the node group.
|
||||
Role string `hcl:"role" cty:"role"`
|
||||
// InstanceCount is optional for upgrades.
|
||||
InstanceCount *int `hcl:"instance_count" cty:"instance_count"`
|
||||
InstanceType string `hcl:"instance_type" cty:"instance_type"`
|
||||
DiskSizeGB int `hcl:"disk_size" cty:"disk_size"`
|
||||
DiskType string `hcl:"disk_type" cty:"disk_type"`
|
||||
Zones *[]string `hcl:"zones" cty:"zones"`
|
||||
// InitialCount is optional for upgrades.
|
||||
InitialCount *int `hcl:"initial_count" cty:"initial_count"`
|
||||
InstanceType string `hcl:"instance_type" cty:"instance_type"`
|
||||
DiskSizeGB int `hcl:"disk_size" cty:"disk_size"`
|
||||
DiskType string `hcl:"disk_type" cty:"disk_type"`
|
||||
Zones *[]string `hcl:"zones" cty:"zones"`
|
||||
}
|
||||
|
||||
// AzureIAMVariables is user configuration for creating the IAM configuration with Terraform on Microsoft Azure.
|
||||
@ -335,8 +335,8 @@ func (v *QEMUVariables) String() string {
|
||||
type QEMUNodeGroup struct {
|
||||
// Role is the role of the node group.
|
||||
Role string `hcl:"role" cty:"role"`
|
||||
// InstanceCount is the number of instances to create.
|
||||
InstanceCount int `hcl:"instance_count" cty:"instance_count"`
|
||||
// InitialCount is the number of instances to create.
|
||||
InitialCount int `hcl:"initial_count" cty:"initial_count"`
|
||||
// DiskSize is the size of the disk to allocate to each node, in GiB.
|
||||
DiskSize int `hcl:"disk_size" cty:"disk_size"`
|
||||
// CPUCount is the number of CPUs to allocate to each node.
|
||||
|
@ -171,11 +171,11 @@ func TestAzureClusterVariables(t *testing.T) {
|
||||
Name: "cluster-name",
|
||||
NodeGroups: map[string]AzureNodeGroup{
|
||||
"control_plane_default": {
|
||||
Role: "ControlPlane",
|
||||
InstanceCount: to.Ptr(1),
|
||||
InstanceType: "Standard_D2s_v3",
|
||||
DiskType: "StandardSSD_LRS",
|
||||
DiskSizeGB: 100,
|
||||
Role: "ControlPlane",
|
||||
InitialCount: to.Ptr(1),
|
||||
InstanceType: "Standard_D2s_v3",
|
||||
DiskType: "StandardSSD_LRS",
|
||||
DiskSizeGB: 100,
|
||||
},
|
||||
},
|
||||
ConfidentialVM: to.Ptr(true),
|
||||
@ -198,12 +198,12 @@ user_assigned_identity = "my-user-assigned-identity"
|
||||
confidential_vm = true
|
||||
node_groups = {
|
||||
control_plane_default = {
|
||||
disk_size = 100
|
||||
disk_type = "StandardSSD_LRS"
|
||||
instance_count = 1
|
||||
instance_type = "Standard_D2s_v3"
|
||||
role = "ControlPlane"
|
||||
zones = null
|
||||
disk_size = 100
|
||||
disk_type = "StandardSSD_LRS"
|
||||
initial_count = 1
|
||||
instance_type = "Standard_D2s_v3"
|
||||
role = "ControlPlane"
|
||||
zones = null
|
||||
}
|
||||
}
|
||||
`
|
||||
@ -274,11 +274,11 @@ func TestQEMUClusterVariables(t *testing.T) {
|
||||
Name: "cluster-name",
|
||||
NodeGroups: map[string]QEMUNodeGroup{
|
||||
"control-plane": {
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InstanceCount: 1,
|
||||
DiskSize: 30,
|
||||
CPUCount: 4,
|
||||
MemorySize: 8192,
|
||||
Role: role.ControlPlane.TFString(),
|
||||
InitialCount: 1,
|
||||
DiskSize: 30,
|
||||
CPUCount: 4,
|
||||
MemorySize: 8192,
|
||||
},
|
||||
},
|
||||
Machine: "q35",
|
||||
@ -298,11 +298,11 @@ func TestQEMUClusterVariables(t *testing.T) {
|
||||
want := `name = "cluster-name"
|
||||
node_groups = {
|
||||
control-plane = {
|
||||
disk_size = 30
|
||||
instance_count = 1
|
||||
memory = 8192
|
||||
role = "control-plane"
|
||||
vcpus = 4
|
||||
disk_size = 30
|
||||
initial_count = 1
|
||||
memory = 8192
|
||||
role = "control-plane"
|
||||
vcpus = 4
|
||||
}
|
||||
}
|
||||
machine = "q35"
|
||||
|
Loading…
Reference in New Issue
Block a user