mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-09-21 21:44:39 -04:00
terraform: azure node groups (#1955)
* init * migration working * make tf variables with default value optional in go through ptr type * fix CI build * pr feedback * add azure targets tf * skip migration for empty targets * make instance_count optional * change role naming to dashed + add validation * make node_group.zones optional * Update cli/internal/terraform/terraform/azure/main.tf Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com> * malte feedback --------- Co-authored-by: Malte Poll <1780588+malt3@users.noreply.github.com>
This commit is contained in:
parent
224c74f883
commit
487fa1e397
11 changed files with 240 additions and 179 deletions
|
@ -156,6 +156,10 @@ func (u *upgradeApplyCmd) migrateTerraform(cmd *cobra.Command, file file.Handler
|
|||
if err != nil {
|
||||
return fmt.Errorf("parsing upgrade variables: %w", err)
|
||||
}
|
||||
if len(targets) == 0 {
|
||||
u.log.Debugf("No targets specified. Skipping Terraform migration")
|
||||
return nil
|
||||
}
|
||||
u.log.Debugf("Using migration targets:\n%v", targets)
|
||||
u.log.Debugf("Using Terraform variables:\n%v", vars)
|
||||
|
||||
|
@ -240,7 +244,7 @@ func parseTerraformUpgradeVars(cmd *cobra.Command, conf *config.Config, fetcher
|
|||
}
|
||||
return targets, vars, nil
|
||||
case cloudprovider.Azure:
|
||||
targets := []string{"azurerm_attestation_provider.attestation_provider"}
|
||||
targets := []string{"azurerm_attestation_provider.attestation_provider", "module.scale_set_group", "module.scale_set_control_plane", "module.scale_set_worker"}
|
||||
|
||||
// Azure Terraform provider is very strict about it's casing
|
||||
imageRef = strings.Replace(imageRef, "CommunityGalleries", "communityGalleries", 1)
|
||||
|
@ -248,16 +252,28 @@ func parseTerraformUpgradeVars(cmd *cobra.Command, conf *config.Config, fetcher
|
|||
imageRef = strings.Replace(imageRef, "Versions", "versions", 1)
|
||||
|
||||
vars := &terraform.AzureClusterVariables{
|
||||
CommonVariables: commonVariables,
|
||||
Location: conf.Provider.Azure.Location,
|
||||
Name: conf.Name,
|
||||
ResourceGroup: conf.Provider.Azure.ResourceGroup,
|
||||
UserAssignedIdentity: conf.Provider.Azure.UserAssignedIdentity,
|
||||
InstanceType: conf.Provider.Azure.InstanceType,
|
||||
StateDiskType: conf.Provider.Azure.StateDiskType,
|
||||
ImageID: imageRef,
|
||||
SecureBoot: *conf.Provider.Azure.SecureBoot,
|
||||
CreateMAA: conf.GetAttestationConfig().GetVariant().Equal(variant.AzureSEVSNP{}),
|
||||
Debug: conf.IsDebugCluster(),
|
||||
NodeGroups: map[string]terraform.AzureNodeGroup{
|
||||
"control_plane_default": {
|
||||
Role: "control-plane",
|
||||
InstanceType: conf.Provider.Azure.InstanceType,
|
||||
DiskSizeGB: conf.StateDiskSizeGB,
|
||||
DiskType: conf.Provider.Azure.StateDiskType,
|
||||
},
|
||||
"worker_default": {
|
||||
Role: "worker",
|
||||
InstanceType: conf.Provider.Azure.InstanceType,
|
||||
DiskSizeGB: conf.StateDiskSizeGB,
|
||||
DiskType: conf.Provider.Azure.StateDiskType,
|
||||
},
|
||||
},
|
||||
Location: conf.Provider.Azure.Location,
|
||||
SecureBoot: conf.Provider.Azure.SecureBoot,
|
||||
CreateMAA: toPtr(conf.GetAttestationConfig().GetVariant().Equal(variant.AzureSEVSNP{})),
|
||||
Debug: toPtr(conf.IsDebugCluster()),
|
||||
}
|
||||
return targets, vars, nil
|
||||
case cloudprovider.GCP:
|
||||
|
@ -427,3 +443,7 @@ type cloudUpgrader interface {
|
|||
CheckTerraformMigrations(fileHandler file.Handler) error
|
||||
CleanUpTerraformMigrations(fileHandler file.Handler) error
|
||||
}
|
||||
|
||||
func toPtr[T any](v T) *T {
|
||||
return &v
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue