mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-08-20 12:38:08 -04:00
AB#2439 Containerized libvirt (#191)
Signed-off-by: Daniel Weiße <dw@edgeless.systems>
This commit is contained in:
parent
abe40de3e5
commit
2ea695896f
20 changed files with 746 additions and 50 deletions
|
@ -12,7 +12,7 @@ terraform {
|
|||
}
|
||||
|
||||
provider "libvirt" {
|
||||
uri = "qemu:///session"
|
||||
uri = var.libvirt_uri
|
||||
}
|
||||
|
||||
provider "docker" {
|
||||
|
@ -24,22 +24,24 @@ provider "docker" {
|
|||
}
|
||||
}
|
||||
|
||||
resource "docker_image" "qemu-metadata" {
|
||||
resource "docker_image" "qemu_metadata" {
|
||||
name = var.metadata_api_image
|
||||
keep_locally = true
|
||||
}
|
||||
|
||||
resource "docker_container" "qemu-metadata" {
|
||||
resource "docker_container" "qemu_metadata" {
|
||||
name = "${var.name}-qemu-metadata"
|
||||
image = docker_image.qemu-metadata.latest
|
||||
image = docker_image.qemu_metadata.latest
|
||||
network_mode = "host"
|
||||
rm = true
|
||||
command = [
|
||||
"--network",
|
||||
"${var.name}-network",
|
||||
"--libvirt-uri",
|
||||
"${var.metadata_libvirt_uri}",
|
||||
]
|
||||
mounts {
|
||||
source = "/var/run/libvirt/libvirt-sock"
|
||||
source = abspath(var.libvirt_socket_path)
|
||||
target = "/var/run/libvirt/libvirt-sock"
|
||||
type = "bind"
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
variable "libvirt_uri" {
|
||||
type = string
|
||||
description = "libvirt socket uri"
|
||||
}
|
||||
|
||||
variable "constellation_coreos_image" {
|
||||
type = string
|
||||
description = "constellation OS file path"
|
||||
|
@ -45,6 +50,16 @@ variable "metadata_api_image" {
|
|||
description = "container image of the QEMU metadata api server"
|
||||
}
|
||||
|
||||
variable "metadata_libvirt_uri" {
|
||||
type = string
|
||||
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"
|
||||
|
|
|
@ -83,6 +83,10 @@ type QEMUVariables struct {
|
|||
// CommonVariables contains common variables.
|
||||
CommonVariables
|
||||
|
||||
// LibvirtURI is the libvirt connection URI.
|
||||
LibvirtURI string
|
||||
// LibvirtSocketPath is the path to the libvirt socket in case of unix socket.
|
||||
LibvirtSocketPath string
|
||||
// CPUCount is the number of CPUs to allocate to each node.
|
||||
CPUCount int
|
||||
// MemorySizeMiB is the amount of memory to allocate to each node, in MiB.
|
||||
|
@ -93,17 +97,24 @@ type QEMUVariables struct {
|
|||
ImageFormat string
|
||||
// MetadataAPIImage is the container image to use for the metadata API.
|
||||
MetadataAPIImage string
|
||||
// MetadataLibvirtURI is the libvirt connection URI used by the metadata container.
|
||||
// In case of unix socket, this should be "qemu:///system".
|
||||
// Other wise it should be the same as LibvirtURI.
|
||||
MetadataLibvirtURI string
|
||||
}
|
||||
|
||||
// String returns a string representation of the variables, formatted as Terraform variables.
|
||||
func (v *QEMUVariables) String() string {
|
||||
b := &strings.Builder{}
|
||||
b.WriteString(v.CommonVariables.String())
|
||||
writeLinef(b, "libvirt_uri = %q", v.LibvirtURI)
|
||||
writeLinef(b, "libvirt_socket_path = %q", v.LibvirtSocketPath)
|
||||
writeLinef(b, "constellation_coreos_image = %q", v.ImagePath)
|
||||
writeLinef(b, "image_format = %q", v.ImageFormat)
|
||||
writeLinef(b, "vcpus = %d", v.CPUCount)
|
||||
writeLinef(b, "memory = %d", v.MemorySizeMiB)
|
||||
writeLinef(b, "metadata_api_image = %q", v.MetadataAPIImage)
|
||||
writeLinef(b, "metadata_libvirt_uri = %q", v.MetadataLibvirtURI)
|
||||
|
||||
return b.String()
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue