mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-02 22:34:56 -04:00
terraform: align infrastructure module attributes (#2703)
* all vars have snail_case * make iam schema consistent * infrastructure schema * terraform: update AWS infrastructure module * fix ci * terraform: update AWS infrastructure module * terraform: update AWS IAM module * terraform: update Azure Infrastructure module inputs Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: update Azure IAM module Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: update GCP infrastructure module Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: update GCP IAM module Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: update OpenStack Infrastructure module Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: update QEMU Infrastructure module Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform-module: fix input name Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: tidy * cli: ignore whitespace in Terraform variable tests * terraform-module: fix AWS output names * terraform-module: fix output references Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> * terraform: rename `api_server_cert_sans` * Update terraform/infrastructure/aws/modules/public_private_subnet/variables.tf Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com> * fix self-managed * terraform: revert AWS modules output file renaming * terraform: remove duplicate varable declaration * terraform: rename Azure location field * ci: adjust output name in self-managed e2e test * e2e: continuously print output in upgrade test * e2e: write to output variables * cli: migrate IAM variable names * cli: make `location` field optional --------- Signed-off-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> Co-authored-by: Moritz Sanft <58110325+msanft@users.noreply.github.com> Co-authored-by: Daniel Weiße <66256922+daniel-weisse@users.noreply.github.com>
This commit is contained in:
parent
6f6f28b8cc
commit
9667dfff58
76 changed files with 745 additions and 767 deletions
|
@ -25,7 +25,7 @@ locals {
|
|||
cidr_vpc_subnet_worker = "10.42.2.0/24"
|
||||
}
|
||||
|
||||
resource "random_password" "initSecret" {
|
||||
resource "random_password" "init_secret" {
|
||||
length = 32
|
||||
special = true
|
||||
override_special = "_%@"
|
||||
|
@ -46,7 +46,7 @@ resource "docker_container" "qemu_metadata" {
|
|||
"--libvirt-uri",
|
||||
"${var.metadata_libvirt_uri}",
|
||||
"--initsecrethash",
|
||||
"${random_password.initSecret.bcrypt_hash}",
|
||||
"${random_password.init_secret.bcrypt_hash}",
|
||||
]
|
||||
mounts {
|
||||
source = abspath(var.libvirt_socket_path)
|
||||
|
@ -55,7 +55,6 @@ resource "docker_container" "qemu_metadata" {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
module "node_group" {
|
||||
source = "./modules/instance_group"
|
||||
base_name = var.name
|
||||
|
@ -71,7 +70,7 @@ module "node_group" {
|
|||
network_id = libvirt_network.constellation.id
|
||||
pool = libvirt_pool.cluster.name
|
||||
boot_mode = var.constellation_boot_mode
|
||||
boot_volume_id = libvirt_volume.constellation_os_image.id
|
||||
boot_volume_id = libvirt_volume.image_id.id
|
||||
kernel_volume_id = local.kernel_volume_id
|
||||
initrd_volume_id = local.initrd_volume_id
|
||||
kernel_cmdline = each.value.role == "control-plane" ? local.kernel_cmdline : var.constellation_cmdline
|
||||
|
@ -85,10 +84,10 @@ resource "libvirt_pool" "cluster" {
|
|||
path = "/var/lib/libvirt/images"
|
||||
}
|
||||
|
||||
resource "libvirt_volume" "constellation_os_image" {
|
||||
resource "libvirt_volume" "image_id" {
|
||||
name = "${var.name}-node-image"
|
||||
pool = libvirt_pool.cluster.name
|
||||
source = var.constellation_os_image
|
||||
source = var.image_id
|
||||
format = var.image_format
|
||||
}
|
||||
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
output "instance_ips" {
|
||||
value = flatten(libvirt_domain.instance_group[*].network_interface[*].addresses[*])
|
||||
value = flatten(libvirt_domain.instance_group[*].network_interface[*].addresses[*])
|
||||
description = "IP addresses of the instances in the instance group."
|
||||
}
|
||||
|
|
|
@ -1,41 +1,51 @@
|
|||
variable "base_name" {
|
||||
type = string
|
||||
description = "Name prefix fort the cluster's VMs."
|
||||
}
|
||||
|
||||
variable "node_group_name" {
|
||||
type = string
|
||||
description = "Constellation name for the node group (used for configuration and CSP-independent naming)."
|
||||
}
|
||||
|
||||
variable "amount" {
|
||||
type = number
|
||||
description = "amount of nodes"
|
||||
description = "Amount of nodes."
|
||||
}
|
||||
|
||||
variable "vcpus" {
|
||||
type = number
|
||||
description = "amount of vcpus per instance"
|
||||
description = "Amount of vCPUs per instance."
|
||||
}
|
||||
|
||||
variable "memory" {
|
||||
type = number
|
||||
description = "amount of memory per instance (MiB)"
|
||||
description = "Amount of memory per instance (MiB)."
|
||||
}
|
||||
|
||||
variable "state_disk_size" {
|
||||
type = number
|
||||
description = "size of state disk (GiB)"
|
||||
description = "Disk size for the state disk of the nodes [GB]."
|
||||
}
|
||||
|
||||
variable "cidr" {
|
||||
type = string
|
||||
description = "subnet to use for dhcp"
|
||||
description = "Subnet to use for DHCP."
|
||||
}
|
||||
|
||||
variable "network_id" {
|
||||
type = string
|
||||
description = "id of the network to use"
|
||||
description = "ID of the Libvirt network to use."
|
||||
}
|
||||
|
||||
variable "pool" {
|
||||
type = string
|
||||
description = "name of the storage pool to use"
|
||||
description = "Name of the Libvirt storage pool to use."
|
||||
}
|
||||
|
||||
variable "boot_mode" {
|
||||
type = string
|
||||
description = "boot mode. Can be 'uefi' or 'direct-linux-boot'"
|
||||
description = "Boot mode. Can be 'uefi' or 'direct-linux-boot'"
|
||||
validation {
|
||||
condition = can(regex("^(uefi|direct-linux-boot)$", var.boot_mode))
|
||||
error_message = "boot_mode must be 'uefi' or 'direct-linux-boot'"
|
||||
|
@ -44,52 +54,43 @@ variable "boot_mode" {
|
|||
|
||||
variable "boot_volume_id" {
|
||||
type = string
|
||||
description = "id of the constellation boot disk"
|
||||
description = "ID of the Constellation boot disk."
|
||||
}
|
||||
|
||||
variable "kernel_volume_id" {
|
||||
type = string
|
||||
description = "id of the constellation kernel volume"
|
||||
description = "ID of the Constellation kernel volume."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "initrd_volume_id" {
|
||||
type = string
|
||||
description = "id of the constellation initrd volume"
|
||||
description = "ID of the constellation initrd volume."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "kernel_cmdline" {
|
||||
type = string
|
||||
description = "kernel cmdline"
|
||||
description = "Kernel cmdline."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "role" {
|
||||
type = string
|
||||
description = "role of the node in the constellation. either 'control-plane' or 'worker'"
|
||||
description = "Role of the node in the Constellation cluster. Can either be'control-plane' or 'worker'."
|
||||
}
|
||||
|
||||
variable "machine" {
|
||||
type = string
|
||||
description = "machine type. use 'q35' for secure boot and 'pc' for non secure boot. See 'qemu-system-x86_64 -machine help'"
|
||||
description = "Machine type. Use 'q35' for secure boot and 'pc' for non secure boot. See 'qemu-system-x86_64 -machine help'."
|
||||
}
|
||||
|
||||
variable "firmware" {
|
||||
type = string
|
||||
description = "path to UEFI firmware file. Ignored for direct-linux-boot."
|
||||
description = "Path to UEFI firmware file. Ignored for direct-linux-boot."
|
||||
}
|
||||
|
||||
variable "nvram" {
|
||||
type = string
|
||||
description = "path to UEFI NVRAM template file. Used for secure boot."
|
||||
}
|
||||
variable "base_name" {
|
||||
type = string
|
||||
description = "name prefix of the cluster VMs"
|
||||
}
|
||||
|
||||
variable "node_group_name" {
|
||||
type = string
|
||||
description = "name of the node group"
|
||||
description = "Path to UEFI NVRAM template file. Used for secure boot."
|
||||
}
|
||||
|
|
|
@ -1,30 +1,50 @@
|
|||
# Outputs common to all CSPs
|
||||
|
||||
output "out_of_cluster_endpoint" {
|
||||
value = module.node_group["control_plane_default"].instance_ips[0]
|
||||
value = module.node_group["control_plane_default"].instance_ips[0]
|
||||
description = "External endpoint for the Kubernetes API server. Only varies from the `in_cluster_endpoint` when using an internal load balancer."
|
||||
}
|
||||
|
||||
output "in_cluster_endpoint" {
|
||||
value = module.node_group["control_plane_default"].instance_ips[0]
|
||||
value = module.node_group["control_plane_default"].instance_ips[0]
|
||||
description = "Internal endpoint for the Kubernetes API server."
|
||||
}
|
||||
|
||||
output "api_server_cert_sans" {
|
||||
value = sort(concat([module.node_group["control_plane_default"].instance_ips[0]], var.custom_endpoint == "" ? [] : [var.custom_endpoint]))
|
||||
value = sort(concat([module.node_group["control_plane_default"].instance_ips[0]], var.custom_endpoint == "" ? [] : [var.custom_endpoint]))
|
||||
description = "List of Subject Alternative Names (SANs) for the API server certificate."
|
||||
}
|
||||
|
||||
output "uid" {
|
||||
value = "qemu" // placeholder
|
||||
value = "qemu" // placeholder
|
||||
description = "Unique Identifier (UID) of the cluster."
|
||||
}
|
||||
|
||||
output "initSecret" {
|
||||
value = random_password.initSecret.result
|
||||
sensitive = true
|
||||
output "init_secret" {
|
||||
value = random_password.init_secret.result
|
||||
sensitive = true
|
||||
description = "Initialization secret to authenticate the bootstrapping node."
|
||||
}
|
||||
|
||||
output "name" {
|
||||
value = "${var.name}-qemu" // placeholder, as per "uid" output
|
||||
description = "Unique name of the Constellation cluster, comprised by name and UID."
|
||||
}
|
||||
|
||||
output "ip_cidr_node" {
|
||||
value = local.cidr_vpc_subnet_nodes
|
||||
description = "CIDR block of the node network."
|
||||
}
|
||||
|
||||
# QEMU-specific outputs
|
||||
|
||||
output "validate_constellation_kernel" {
|
||||
value = null
|
||||
precondition {
|
||||
condition = var.constellation_boot_mode != "direct-linux-boot" || length(var.constellation_kernel) > 0
|
||||
error_message = "constellation_kernel must be set if constellation_boot_mode is 'direct-linux-boot'"
|
||||
}
|
||||
description = "Validation placeholder. Do not consume as output."
|
||||
}
|
||||
|
||||
output "validate_constellation_initrd" {
|
||||
|
@ -33,6 +53,7 @@ output "validate_constellation_initrd" {
|
|||
condition = var.constellation_boot_mode != "direct-linux-boot" || length(var.constellation_initrd) > 0
|
||||
error_message = "constellation_initrd must be set if constellation_boot_mode is 'direct-linux-boot'"
|
||||
}
|
||||
description = "Validation placeholder. Do not consume as output."
|
||||
}
|
||||
|
||||
output "validate_constellation_cmdline" {
|
||||
|
@ -41,12 +62,5 @@ output "validate_constellation_cmdline" {
|
|||
condition = var.constellation_boot_mode != "direct-linux-boot" || length(var.constellation_cmdline) > 0
|
||||
error_message = "constellation_cmdline must be set if constellation_boot_mode is 'direct-linux-boot'"
|
||||
}
|
||||
}
|
||||
|
||||
output "name" {
|
||||
value = "${var.name}-qemu" // placeholder, as per "uid" output
|
||||
}
|
||||
|
||||
output "ip_cidr_nodes" {
|
||||
value = local.cidr_vpc_subnet_nodes
|
||||
description = "Validation placeholder. Do not consume as output."
|
||||
}
|
||||
|
|
|
@ -1,3 +1,11 @@
|
|||
# Variables common to all CSPs
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
default = "constellation"
|
||||
description = "Name of the Constellation cluster."
|
||||
}
|
||||
|
||||
variable "node_groups" {
|
||||
type = map(object({
|
||||
role = string
|
||||
|
@ -14,91 +22,88 @@ variable "node_groups" {
|
|||
description = "A map of node group names to node group configurations."
|
||||
}
|
||||
|
||||
variable "image_id" {
|
||||
type = string
|
||||
description = "Path to the OS image for the cluster's nodes."
|
||||
}
|
||||
|
||||
variable "custom_endpoint" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Custom endpoint to use for the Kubernetes API server. If not set, the default endpoint will be used."
|
||||
}
|
||||
|
||||
# QEMU-specific variables
|
||||
|
||||
variable "machine" {
|
||||
type = string
|
||||
default = "q35"
|
||||
description = "machine type. use 'q35' for secure boot and 'pc' for non secure boot. See 'qemu-system-x86_64 -machine help'"
|
||||
description = "Machine type. Use 'q35' for secure boot and 'pc' for non secure boot. See 'qemu-system-x86_64 -machine help'."
|
||||
}
|
||||
|
||||
variable "libvirt_uri" {
|
||||
type = string
|
||||
description = "libvirt socket uri"
|
||||
description = "URI of the Libvirt socket."
|
||||
}
|
||||
|
||||
variable "constellation_boot_mode" {
|
||||
type = string
|
||||
description = "constellation boot mode. Can be 'uefi' or 'direct-linux-boot'"
|
||||
description = "Constellation boot mode. Can be 'uefi' or 'direct-linux-boot'."
|
||||
validation {
|
||||
condition = anytrue([
|
||||
var.constellation_boot_mode == "uefi",
|
||||
var.constellation_boot_mode == "direct-linux-boot",
|
||||
])
|
||||
error_message = "constellation_boot_mode must be 'uefi' or 'direct-linux-boot'"
|
||||
error_message = "constellation_boot_mode must be 'uefi' or 'direct-linux-boot'."
|
||||
}
|
||||
}
|
||||
|
||||
variable "constellation_os_image" {
|
||||
type = string
|
||||
description = "constellation OS file path"
|
||||
}
|
||||
|
||||
variable "constellation_kernel" {
|
||||
type = string
|
||||
description = "constellation Kernel file path"
|
||||
description = "Constellation Kernel file path."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "constellation_initrd" {
|
||||
type = string
|
||||
description = "constellation initrd file path"
|
||||
description = "Constellation initrd file path."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "constellation_cmdline" {
|
||||
type = string
|
||||
description = "constellation kernel cmdline"
|
||||
description = "Constellation kernel cmdline."
|
||||
default = ""
|
||||
}
|
||||
|
||||
variable "image_format" {
|
||||
type = string
|
||||
default = "qcow2"
|
||||
description = "image format"
|
||||
description = "Image format."
|
||||
}
|
||||
|
||||
variable "firmware" {
|
||||
type = string
|
||||
default = "/usr/share/OVMF/OVMF_CODE.fd"
|
||||
description = "path to UEFI firmware file. Use \"OVMF_CODE_4M.ms.fd\" on Ubuntu and \"OVMF_CODE.fd\" or \"OVMF_CODE.secboot.fd\" on Fedora."
|
||||
description = "Path to UEFI firmware file. Use \"OVMF_CODE_4M.ms.fd\" on Ubuntu and \"OVMF_CODE.fd\" or \"OVMF_CODE.secboot.fd\" on Fedora."
|
||||
}
|
||||
|
||||
variable "nvram" {
|
||||
type = string
|
||||
description = "path to UEFI NVRAM template file. Used for secure boot."
|
||||
description = "Path to UEFI NVRAM template file. Used for secure boot."
|
||||
}
|
||||
|
||||
variable "metadata_api_image" {
|
||||
type = string
|
||||
description = "container image of the QEMU metadata api server"
|
||||
description = "Container image of the QEMU metadata API server."
|
||||
}
|
||||
|
||||
variable "metadata_libvirt_uri" {
|
||||
type = string
|
||||
description = "libvirt uri for the metadata api server"
|
||||
description = "Libvirt URI for the metadata API server."
|
||||
}
|
||||
|
||||
variable "libvirt_socket_path" {
|
||||
type = string
|
||||
description = "path to libvirt socket in case of unix socket"
|
||||
}
|
||||
|
||||
variable "name" {
|
||||
type = string
|
||||
default = "constellation"
|
||||
description = "name prefix of the cluster VMs"
|
||||
}
|
||||
|
||||
variable "custom_endpoint" {
|
||||
type = string
|
||||
default = ""
|
||||
description = "Custom endpoint to use for the Kubernetes apiserver. If not set, the default endpoint will be used."
|
||||
description = "Path to Libvirt socket in case of unix socket."
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue