mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-15 04:32:15 -04:00
terraform: openstack node groups (#1966)
* openstack * rename to base_name * fix openstack boot vtpm * add docs for accessing bootstrapper logs * rename to initial count
This commit is contained in:
parent
d43242a55f
commit
c39df2f7da
9 changed files with 141 additions and 125 deletions
|
@ -158,40 +158,22 @@ resource "openstack_compute_secgroup_v2" "vpc_secgroup" {
|
|||
}
|
||||
}
|
||||
|
||||
module "instance_group_control_plane" {
|
||||
source = "./modules/instance_group"
|
||||
name = local.name
|
||||
role = "control-plane"
|
||||
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]
|
||||
tags = local.tags
|
||||
uid = local.uid
|
||||
disk_size = var.state_disk_size
|
||||
state_disk_type = var.state_disk_type
|
||||
availability_zone = var.availability_zone
|
||||
network_id = openstack_networking_network_v2.vpc_network.id
|
||||
init_secret_hash = local.initSecretHash
|
||||
identity_internal_url = local.identity_internal_url
|
||||
openstack_username = var.openstack_username
|
||||
openstack_password = var.openstack_password
|
||||
openstack_user_domain_name = var.openstack_user_domain_name
|
||||
}
|
||||
module "instance_group" {
|
||||
|
||||
module "instance_group_worker" {
|
||||
source = "./modules/instance_group"
|
||||
name = local.name
|
||||
role = "worker"
|
||||
initial_count = var.worker_count
|
||||
for_each = var.node_groups
|
||||
base_name = local.name
|
||||
node_group_name = each.key
|
||||
role = each.value.role
|
||||
initial_count = each.value.initial_count
|
||||
disk_size = each.value.state_disk_size
|
||||
state_disk_type = each.value.state_disk_type
|
||||
availability_zone = each.value.zone
|
||||
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]
|
||||
tags = local.tags
|
||||
uid = local.uid
|
||||
security_groups = [openstack_compute_secgroup_v2.vpc_secgroup.id]
|
||||
disk_size = var.state_disk_size
|
||||
state_disk_type = var.state_disk_type
|
||||
availability_zone = var.availability_zone
|
||||
network_id = openstack_networking_network_v2.vpc_network.id
|
||||
init_secret_hash = local.initSecretHash
|
||||
identity_internal_url = local.identity_internal_url
|
||||
|
@ -209,15 +191,24 @@ resource "openstack_networking_floatingip_v2" "public_ip" {
|
|||
|
||||
resource "openstack_compute_floatingip_associate_v2" "public_ip_associate" {
|
||||
floating_ip = openstack_networking_floatingip_v2.public_ip.address
|
||||
instance_id = module.instance_group_control_plane.instance_ids.0
|
||||
instance_id = module.instance_group["control_plane_default"].instance_ids.0
|
||||
depends_on = [
|
||||
openstack_networking_router_v2.vpc_router,
|
||||
openstack_networking_router_interface_v2.vpc_router_interface,
|
||||
]
|
||||
}
|
||||
|
||||
# TODO(malt3): get LoadBalancer API enabled in the test environment
|
||||
moved {
|
||||
from = module.instance_group_control_plane
|
||||
to = module.instance_group["control_plane_default"]
|
||||
}
|
||||
|
||||
moved {
|
||||
from = module.instance_group_worker
|
||||
to = module.instance_group["worker_default"]
|
||||
}
|
||||
|
||||
# TODO(malt3): get LoadBalancer API enabled in the test environment
|
||||
# resource "openstack_lb_loadbalancer_v2" "loadbalancer" {
|
||||
# name = local.name
|
||||
# description = "Constellation load balancer"
|
||||
|
|
|
@ -8,8 +8,14 @@ terraform {
|
|||
}
|
||||
|
||||
locals {
|
||||
name = "${var.name}-${var.role}"
|
||||
tags = distinct(sort(concat(var.tags, ["constellation-role-${var.role}"])))
|
||||
tags = distinct(sort(concat(var.tags, ["constellation-role-${var.role}"], ["constellation-node-group-${var.node_group_name}"])))
|
||||
group_uid = random_id.uid.hex
|
||||
#name = "${var.base_name}-${var.role}" // TODO keep old naming ?
|
||||
name = "${var.base_name}-${var.role}-${local.group_uid}"
|
||||
}
|
||||
|
||||
resource "random_id" "uid" {
|
||||
byte_length = 4
|
||||
}
|
||||
|
||||
# TODO(malt3): get this API enabled in the test environment
|
||||
|
|
|
@ -1,4 +1,9 @@
|
|||
variable "name" {
|
||||
variable "node_group_name" {
|
||||
type = string
|
||||
description = "Constellation name for the node group (used for configuration and CSP-independent naming)."
|
||||
}
|
||||
|
||||
variable "base_name" {
|
||||
type = string
|
||||
description = "Base name of the instance group."
|
||||
}
|
||||
|
|
|
@ -1,3 +1,20 @@
|
|||
variable "node_groups" {
|
||||
type = map(object({
|
||||
role = string
|
||||
initial_count = number // number of instances in the node group
|
||||
state_disk_size = number // size of state disk (GiB)
|
||||
state_disk_type = string // type of state disk. Can be 'standard' or 'premium'
|
||||
zone = string // availability zone
|
||||
}))
|
||||
|
||||
validation {
|
||||
condition = can([for group in var.node_groups : group.role == "control-plane" || group.role == "worker"])
|
||||
error_message = "The role has to be 'control-plane' or 'worker'."
|
||||
}
|
||||
|
||||
description = "A map of node group names to node group configurations."
|
||||
}
|
||||
|
||||
variable "cloud" {
|
||||
type = string
|
||||
default = null
|
||||
|
@ -10,32 +27,6 @@ variable "name" {
|
|||
description = "Base name of the cluster."
|
||||
}
|
||||
|
||||
variable "control_plane_count" {
|
||||
type = number
|
||||
description = "The number of control plane nodes to deploy."
|
||||
}
|
||||
|
||||
variable "worker_count" {
|
||||
type = number
|
||||
description = "The number of worker nodes to deploy."
|
||||
}
|
||||
|
||||
variable "state_disk_size" {
|
||||
type = number
|
||||
default = 30
|
||||
description = "The size of the state disk in GB."
|
||||
}
|
||||
|
||||
variable "state_disk_type" {
|
||||
type = string
|
||||
description = "Disk/volume type to be used."
|
||||
}
|
||||
|
||||
variable "availability_zone" {
|
||||
type = string
|
||||
description = "The availability zone to deploy the nodes in."
|
||||
}
|
||||
|
||||
variable "image_url" {
|
||||
type = string
|
||||
description = "The image to use for cluster nodes."
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue