cli: use pre-uploaded image on OpenStack

Before, the terraform infrastructure code would upload an image on the fly.
Now, we upload images in advance and specify the image ID instead.
This commit is contained in:
Malte Poll 2024-02-19 13:33:47 +01:00
parent 3b2da12781
commit 6f9020d527
8 changed files with 22 additions and 56 deletions

View File

@ -258,8 +258,7 @@ func openStackTerraformVars(conf *config.Config, imageRef string) (*terraform.Op
Name: conf.Name,
Cloud: toPtr(conf.Provider.OpenStack.Cloud),
FloatingIPPoolID: conf.Provider.OpenStack.FloatingIPPoolID,
ImageURL: imageRef,
DirectDownload: *conf.Provider.OpenStack.DirectDownload,
ImageID: imageRef,
OpenstackUserDomainName: conf.Provider.OpenStack.UserDomainName,
OpenstackUsername: conf.Provider.OpenStack.Username,
OpenstackPassword: conf.Provider.OpenStack.Password,

View File

@ -282,10 +282,8 @@ type OpenStackClusterVariables struct {
Cloud *string `hcl:"cloud" cty:"cloud"`
// FloatingIPPoolID is the ID of the OpenStack floating IP pool to use for public IPs.
FloatingIPPoolID string `hcl:"floating_ip_pool_id" cty:"floating_ip_pool_id"`
// ImageURL is the URL of the OpenStack image to use.
ImageURL string `hcl:"image_id" cty:"image_id"`
// DirectDownload decides whether to download the image directly from the URL to OpenStack or to upload it from the local machine.
DirectDownload bool `hcl:"direct_download" cty:"direct_download"`
// ImageID is the ID of the OpenStack image to use.
ImageID string `hcl:"image_id" cty:"image_id"`
// OpenstackUserDomainName is the OpenStack user domain name to use.
OpenstackUserDomainName string `hcl:"openstack_user_domain_name" cty:"openstack_user_domain_name"`
// OpenstackUsername is the OpenStack user name to use.

View File

@ -255,8 +255,7 @@ func TestOpenStackClusterVariables(t *testing.T) {
Name: "cluster-name",
Cloud: toPtr("my-cloud"),
FloatingIPPoolID: "fip-pool-0123456789abcdef",
ImageURL: "https://example.com/image.raw",
DirectDownload: true,
ImageID: "8e10b92d-8f7a-458c-91c6-59b42f82ef81",
OpenstackUserDomainName: "my-user-domain",
OpenstackUsername: "my-username",
OpenstackPassword: "my-password",
@ -288,8 +287,7 @@ node_groups = {
}
cloud = "my-cloud"
floating_ip_pool_id = "fip-pool-0123456789abcdef"
image_id = "https://example.com/image.raw"
direct_download = true
image_id = "8e10b92d-8f7a-458c-91c6-59b42f82ef81"
openstack_user_domain_name = "my-user-domain"
openstack_username = "my-username"
openstack_password = "my-password"

View File

@ -228,9 +228,6 @@ type OpenStackConfig struct {
// Password to use inside the cluster. You can instead use the environment variable "CONSTELL_OS_PASSWORD".
Password string `yaml:"password"`
// description: |
// If enabled, downloads OS image directly from source URL to OpenStack. Otherwise, downloads image to local machine and uploads to OpenStack.
DirectDownload *bool `yaml:"directDownload" validate:"required"`
// description: |
// Deploy Yawol loadbalancer. For details see: https://github.com/stackitcloud/yawol
DeployYawolLoadBalancer *bool `yaml:"deployYawolLoadBalancer" validate:"required"`
// description: |
@ -363,7 +360,6 @@ func Default() *Config {
UseMarketplaceImage: toPtr(false),
},
OpenStack: &OpenStackConfig{
DirectDownload: toPtr(true),
DeployYawolLoadBalancer: toPtr(true),
DeployCSIDriver: toPtr(true),
},
@ -912,7 +908,6 @@ func (c *Config) WithOpenStackProviderDefaults(openStackProvider string) *Config
c.Provider.OpenStack.YawolImageID = "bcd6c13e-75d1-4c3f-bf0f-8f83580cc1be"
c.Provider.OpenStack.YawolFlavorID = "3b11b27e-6c73-470d-b595-1d85b95a8cdf"
c.Provider.OpenStack.DeployCSIDriver = toPtr(true)
c.Provider.OpenStack.DirectDownload = toPtr(true)
for groupName, group := range c.NodeGroups {
group.InstanceType = "2715eabe-3ffc-4c36-b02a-efa8c141a96a"
group.StateDiskType = "storage_premium_perf6"

View File

@ -276,7 +276,7 @@ func init() {
FieldName: "openstack",
},
}
OpenStackConfigDoc.Fields = make([]encoder.Doc, 16)
OpenStackConfigDoc.Fields = make([]encoder.Doc, 15)
OpenStackConfigDoc.Fields[0].Name = "cloud"
OpenStackConfigDoc.Fields[0].Type = "string"
OpenStackConfigDoc.Fields[0].Note = ""
@ -332,31 +332,26 @@ func init() {
OpenStackConfigDoc.Fields[10].Note = ""
OpenStackConfigDoc.Fields[10].Description = "Password to use inside the cluster. You can instead use the environment variable \"CONSTELL_OS_PASSWORD\"."
OpenStackConfigDoc.Fields[10].Comments[encoder.LineComment] = "Password to use inside the cluster. You can instead use the environment variable \"CONSTELL_OS_PASSWORD\"."
OpenStackConfigDoc.Fields[11].Name = "directDownload"
OpenStackConfigDoc.Fields[11].Name = "deployYawolLoadBalancer"
OpenStackConfigDoc.Fields[11].Type = "bool"
OpenStackConfigDoc.Fields[11].Note = ""
OpenStackConfigDoc.Fields[11].Description = "If enabled, downloads OS image directly from source URL to OpenStack. Otherwise, downloads image to local machine and uploads to OpenStack."
OpenStackConfigDoc.Fields[11].Comments[encoder.LineComment] = "If enabled, downloads OS image directly from source URL to OpenStack. Otherwise, downloads image to local machine and uploads to OpenStack."
OpenStackConfigDoc.Fields[12].Name = "deployYawolLoadBalancer"
OpenStackConfigDoc.Fields[12].Type = "bool"
OpenStackConfigDoc.Fields[11].Description = "Deploy Yawol loadbalancer. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[11].Comments[encoder.LineComment] = "Deploy Yawol loadbalancer. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[12].Name = "yawolImageID"
OpenStackConfigDoc.Fields[12].Type = "string"
OpenStackConfigDoc.Fields[12].Note = ""
OpenStackConfigDoc.Fields[12].Description = "Deploy Yawol loadbalancer. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[12].Comments[encoder.LineComment] = "Deploy Yawol loadbalancer. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[13].Name = "yawolImageID"
OpenStackConfigDoc.Fields[12].Description = "OpenStack OS image used by the yawollet. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[12].Comments[encoder.LineComment] = "OpenStack OS image used by the yawollet. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[13].Name = "yawolFlavorID"
OpenStackConfigDoc.Fields[13].Type = "string"
OpenStackConfigDoc.Fields[13].Note = ""
OpenStackConfigDoc.Fields[13].Description = "OpenStack OS image used by the yawollet. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[13].Comments[encoder.LineComment] = "OpenStack OS image used by the yawollet. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[14].Name = "yawolFlavorID"
OpenStackConfigDoc.Fields[14].Type = "string"
OpenStackConfigDoc.Fields[13].Description = "OpenStack flavor id used for yawollets. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[13].Comments[encoder.LineComment] = "OpenStack flavor id used for yawollets. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[14].Name = "deployCSIDriver"
OpenStackConfigDoc.Fields[14].Type = "bool"
OpenStackConfigDoc.Fields[14].Note = ""
OpenStackConfigDoc.Fields[14].Description = "OpenStack flavor id used for yawollets. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[14].Comments[encoder.LineComment] = "OpenStack flavor id used for yawollets. For details see: https://github.com/stackitcloud/yawol"
OpenStackConfigDoc.Fields[15].Name = "deployCSIDriver"
OpenStackConfigDoc.Fields[15].Type = "bool"
OpenStackConfigDoc.Fields[15].Note = ""
OpenStackConfigDoc.Fields[15].Description = "Deploy Cinder CSI driver with on-node encryption. For details see: https://docs.edgeless.systems/constellation/architecture/encrypted-storage"
OpenStackConfigDoc.Fields[15].Comments[encoder.LineComment] = "Deploy Cinder CSI driver with on-node encryption. For details see: https://docs.edgeless.systems/constellation/architecture/encrypted-storage"
OpenStackConfigDoc.Fields[14].Description = "Deploy Cinder CSI driver with on-node encryption. For details see: https://docs.edgeless.systems/constellation/architecture/encrypted-storage"
OpenStackConfigDoc.Fields[14].Comments[encoder.LineComment] = "Deploy Cinder CSI driver with on-node encryption. For details see: https://docs.edgeless.systems/constellation/architecture/encrypted-storage"
QEMUConfigDoc.Type = "QEMUConfig"
QEMUConfigDoc.Comments[encoder.LineComment] = "QEMUConfig holds config information for QEMU based Constellation deployments."

View File

@ -389,7 +389,6 @@ func V3ToV4(path string, fileHandler file.Handler) error {
RegionName: cfgV3.Provider.OpenStack.RegionName,
Username: cfgV3.Provider.OpenStack.Username,
Password: cfgV3.Provider.OpenStack.Password,
DirectDownload: cfgV3.Provider.OpenStack.DirectDownload,
DeployYawolLoadBalancer: cfgV3.Provider.OpenStack.DeployYawolLoadBalancer,
YawolImageID: cfgV3.Provider.OpenStack.YawolImageID,
YawolFlavorID: cfgV3.Provider.OpenStack.YawolFlavorID,

View File

@ -55,19 +55,6 @@ resource "random_password" "init_secret" {
override_special = "_%@"
}
resource "openstack_images_image_v2" "image_id" {
name = local.name
image_source_url = var.image_id
web_download = var.direct_download
container_format = "bare"
disk_format = "raw"
visibility = "private"
properties = {
hw_firmware_type = "uefi"
os_type = "linux"
}
}
data "openstack_networking_network_v2" "floating_ip_pool" {
network_id = var.floating_ip_pool_id
}
@ -216,7 +203,7 @@ module "instance_group" {
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.image_id.image_id
image_id = var.image_id
flavor_id = each.value.flavor_id
security_groups = [openstack_networking_secgroup_v2.vpc_secgroup.id]
tags = local.tags

View File

@ -25,7 +25,7 @@ variable "node_groups" {
variable "image_id" {
type = string
description = "OS image URL for the cluster's nodes."
description = "OS image ID for the cluster's nodes."
}
variable "debug" {
@ -48,11 +48,6 @@ variable "cloud" {
description = "Cloud to use within the OpenStack \"clouds.yaml\" file. Optional. If not set, environment variables are used."
}
variable "direct_download" {
type = bool
description = "Download OS image directly from source URL to OpenStack. Otherwise, the image is downloaded to the local machine and uploads to OpenStack."
}
variable "floating_ip_pool_id" {
type = string
description = "Pool (network name) to use for floating IPs."