Remove exposure of qemu ip_range_start value

This commit is contained in:
katexochen 2022-09-27 10:47:45 +02:00 committed by Paul Meyer
parent ed78c48ed4
commit ccbc3d9123
9 changed files with 17 additions and 42 deletions

View File

@ -169,7 +169,6 @@ func (c *Creator) createQEMU(ctx context.Context, cl terraformClient, name strin
ImageFormat: config.Provider.QEMU.ImageFormat, ImageFormat: config.Provider.QEMU.ImageFormat,
CPUCount: config.Provider.QEMU.VCPUs, CPUCount: config.Provider.QEMU.VCPUs,
MemorySizeMiB: config.Provider.QEMU.Memory, MemorySizeMiB: config.Provider.QEMU.Memory,
IPRangeStart: config.Provider.QEMU.IPRangeStart,
MetadataAPIImage: config.Provider.QEMU.MetadataAPIImage, MetadataAPIImage: config.Provider.QEMU.MetadataAPIImage,
} }

View File

@ -25,7 +25,7 @@ provider "docker" {
} }
resource "docker_image" "qemu-metadata" { resource "docker_image" "qemu-metadata" {
name = "${var.metadata_api_image}" name = var.metadata_api_image
keep_locally = true keep_locally = true
} }
@ -34,7 +34,7 @@ resource "docker_container" "qemu-metadata" {
image = docker_image.qemu-metadata.latest image = docker_image.qemu-metadata.latest
network_mode = "host" network_mode = "host"
rm = true rm = true
command = [ command = [
"--network", "--network",
"${var.name}-network", "${var.name}-network",
] ]
@ -52,7 +52,6 @@ module "control_plane" {
vcpus = var.vcpus vcpus = var.vcpus
memory = var.memory memory = var.memory
state_disk_size = var.state_disk_size state_disk_size = var.state_disk_size
ip_range_start = var.ip_range_start
cidr = "10.42.1.0/24" cidr = "10.42.1.0/24"
network_id = libvirt_network.constellation.id network_id = libvirt_network.constellation.id
pool = libvirt_pool.cluster.name pool = libvirt_pool.cluster.name
@ -68,7 +67,6 @@ module "worker" {
vcpus = var.vcpus vcpus = var.vcpus
memory = var.memory memory = var.memory
state_disk_size = var.state_disk_size state_disk_size = var.state_disk_size
ip_range_start = var.ip_range_start
cidr = "10.42.2.0/24" cidr = "10.42.2.0/24"
network_id = libvirt_network.constellation.id network_id = libvirt_network.constellation.id
pool = libvirt_pool.cluster.name pool = libvirt_pool.cluster.name

View File

@ -9,6 +9,7 @@ terraform {
locals { locals {
state_disk_size_byte = 1073741824 * var.state_disk_size state_disk_size_byte = 1073741824 * var.state_disk_size
ip_range_start = 100
} }
resource "libvirt_domain" "instance_group" { resource "libvirt_domain" "instance_group" {
@ -44,7 +45,7 @@ resource "libvirt_domain" "instance_group" {
network_interface { network_interface {
network_id = var.network_id network_id = var.network_id
hostname = "${var.role}-${count.index}" hostname = "${var.role}-${count.index}"
addresses = [cidrhost(var.cidr, var.ip_range_start + count.index)] addresses = [cidrhost(var.cidr, local.ip_range_start + count.index)]
wait_for_lease = true wait_for_lease = true
} }
console { console {

View File

@ -18,11 +18,6 @@ variable "state_disk_size" {
description = "size of state disk (GiB)" description = "size of state disk (GiB)"
} }
variable "ip_range_start" {
type = number
description = "first ip address to use within subnet"
}
variable "cidr" { variable "cidr" {
type = string type = string
description = "subnet to use for dhcp" description = "subnet to use for dhcp"

View File

@ -34,11 +34,6 @@ variable "state_disk_size" {
description = "size of state disk (GiB)" description = "size of state disk (GiB)"
} }
variable "ip_range_start" {
type = number
description = "first ip address to use within subnet"
}
variable "machine" { variable "machine" {
type = string type = string
default = "q35" default = "q35"

View File

@ -45,7 +45,6 @@ func TestCreateCluster(t *testing.T) {
}, },
CPUCount: 1, CPUCount: 1,
MemorySizeMiB: 1024, MemorySizeMiB: 1024,
IPRangeStart: 100,
ImagePath: "path", ImagePath: "path",
ImageFormat: "format", ImageFormat: "format",
MetadataAPIImage: "api", MetadataAPIImage: "api",

View File

@ -88,8 +88,6 @@ type QEMUVariables struct {
// MemorySizeMiB is the amount of memory to allocate to each node, in MiB. // MemorySizeMiB is the amount of memory to allocate to each node, in MiB.
MemorySizeMiB int MemorySizeMiB int
// IPRangeStart is the first IP address in the IP range to allocate to the cluster. // IPRangeStart is the first IP address in the IP range to allocate to the cluster.
IPRangeStart int
// ImagePath is the path to the image to use for the nodes.
ImagePath string ImagePath string
// ImageFormat is the format of the image from ImagePath. // ImageFormat is the format of the image from ImagePath.
ImageFormat string ImageFormat string
@ -105,7 +103,6 @@ func (v *QEMUVariables) String() string {
writeLinef(b, "image_format = %q", v.ImageFormat) writeLinef(b, "image_format = %q", v.ImageFormat)
writeLinef(b, "vcpus = %d", v.CPUCount) writeLinef(b, "vcpus = %d", v.CPUCount)
writeLinef(b, "memory = %d", v.MemorySizeMiB) writeLinef(b, "memory = %d", v.MemorySizeMiB)
writeLinef(b, "ip_range_start = %d", v.IPRangeStart)
writeLinef(b, "metadata_api_image = %q", v.MetadataAPIImage) writeLinef(b, "metadata_api_image = %q", v.MetadataAPIImage)
return b.String() return b.String()

View File

@ -189,9 +189,6 @@ type QEMUConfig struct {
// Amount of memory per instance (MiB). // Amount of memory per instance (MiB).
Memory int `yaml:"memory" validate:"required"` Memory int `yaml:"memory" validate:"required"`
// description: | // description: |
// First IP address to use within a node group's subnet.
IPRangeStart int `yaml:"ipRangeStart" validate:"required"`
// description: |
// Container image to use for the QEMU metadata server. // Container image to use for the QEMU metadata server.
MetadataAPIImage string `yaml:"metadataAPIServer" validate:"required"` MetadataAPIImage string `yaml:"metadataAPIServer" validate:"required"`
// description: | // description: |
@ -239,7 +236,6 @@ func Default() *Config {
ImageFormat: "qcow2", ImageFormat: "qcow2",
VCPUs: 2, VCPUs: 2,
Memory: 2048, Memory: 2048,
IPRangeStart: 100,
Measurements: copyPCRMap(qemuPCRs), Measurements: copyPCRMap(qemuPCRs),
MetadataAPIImage: "ghcr.io/edgelesssys/constellation/qemu-metadata-api:v2.1.0-pre.0.20220922072347-abb78344bc2a", MetadataAPIImage: "ghcr.io/edgelesssys/constellation/qemu-metadata-api:v2.1.0-pre.0.20220922072347-abb78344bc2a",
EnforcedMeasurements: []uint32{11, 12}, EnforcedMeasurements: []uint32{11, 12},

View File

@ -288,7 +288,7 @@ func init() {
FieldName: "qemu", FieldName: "qemu",
}, },
} }
QEMUConfigDoc.Fields = make([]encoder.Doc, 8) QEMUConfigDoc.Fields = make([]encoder.Doc, 7)
QEMUConfigDoc.Fields[0].Name = "image" QEMUConfigDoc.Fields[0].Name = "image"
QEMUConfigDoc.Fields[0].Type = "string" QEMUConfigDoc.Fields[0].Type = "string"
QEMUConfigDoc.Fields[0].Note = "" QEMUConfigDoc.Fields[0].Note = ""
@ -309,26 +309,21 @@ func init() {
QEMUConfigDoc.Fields[3].Note = "" QEMUConfigDoc.Fields[3].Note = ""
QEMUConfigDoc.Fields[3].Description = "Amount of memory per instance (MiB)." QEMUConfigDoc.Fields[3].Description = "Amount of memory per instance (MiB)."
QEMUConfigDoc.Fields[3].Comments[encoder.LineComment] = "Amount of memory per instance (MiB)." QEMUConfigDoc.Fields[3].Comments[encoder.LineComment] = "Amount of memory per instance (MiB)."
QEMUConfigDoc.Fields[4].Name = "ipRangeStart" QEMUConfigDoc.Fields[4].Name = "metadataAPIServer"
QEMUConfigDoc.Fields[4].Type = "int" QEMUConfigDoc.Fields[4].Type = "string"
QEMUConfigDoc.Fields[4].Note = "" QEMUConfigDoc.Fields[4].Note = ""
QEMUConfigDoc.Fields[4].Description = "First IP address to use within a node group's subnet." QEMUConfigDoc.Fields[4].Description = "Container image to use for the QEMU metadata server."
QEMUConfigDoc.Fields[4].Comments[encoder.LineComment] = "First IP address to use within a node group's subnet." QEMUConfigDoc.Fields[4].Comments[encoder.LineComment] = "Container image to use for the QEMU metadata server."
QEMUConfigDoc.Fields[5].Name = "metadataAPIServer" QEMUConfigDoc.Fields[5].Name = "measurements"
QEMUConfigDoc.Fields[5].Type = "string" QEMUConfigDoc.Fields[5].Type = "Measurements"
QEMUConfigDoc.Fields[5].Note = "" QEMUConfigDoc.Fields[5].Note = ""
QEMUConfigDoc.Fields[5].Description = "Container image to use for the QEMU metadata server." QEMUConfigDoc.Fields[5].Description = "Measurement used to enable measured boot."
QEMUConfigDoc.Fields[5].Comments[encoder.LineComment] = "Container image to use for the QEMU metadata server." QEMUConfigDoc.Fields[5].Comments[encoder.LineComment] = "Measurement used to enable measured boot."
QEMUConfigDoc.Fields[6].Name = "measurements" QEMUConfigDoc.Fields[6].Name = "enforcedMeasurements"
QEMUConfigDoc.Fields[6].Type = "Measurements" QEMUConfigDoc.Fields[6].Type = "[]uint32"
QEMUConfigDoc.Fields[6].Note = "" QEMUConfigDoc.Fields[6].Note = ""
QEMUConfigDoc.Fields[6].Description = "Measurement used to enable measured boot." QEMUConfigDoc.Fields[6].Description = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning."
QEMUConfigDoc.Fields[6].Comments[encoder.LineComment] = "Measurement used to enable measured boot." QEMUConfigDoc.Fields[6].Comments[encoder.LineComment] = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning."
QEMUConfigDoc.Fields[7].Name = "enforcedMeasurements"
QEMUConfigDoc.Fields[7].Type = "[]uint32"
QEMUConfigDoc.Fields[7].Note = ""
QEMUConfigDoc.Fields[7].Description = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning."
QEMUConfigDoc.Fields[7].Comments[encoder.LineComment] = "List of values that should be enforced to be equal to the ones from the measurement list. Any non-equal values not in this list will only result in a warning."
} }
func (_ Config) Doc() *encoder.Doc { func (_ Config) Doc() *encoder.Doc {