mirror of
https://github.com/edgelesssys/constellation.git
synced 2025-05-06 08:15:48 -04:00
Remove azure single instance support (#402)
This commit is contained in:
parent
9e43701d3c
commit
708c6e057e
11 changed files with 5 additions and 509 deletions
|
@ -104,95 +104,6 @@ type CreateInstancesInput struct {
|
|||
ConfidentialVM bool
|
||||
}
|
||||
|
||||
// CreateInstancesVMs creates instances based on standalone VMs.
|
||||
// TODO: deprecate as soon as scale sets are available.
|
||||
func (c *Client) CreateInstancesVMs(ctx context.Context, input CreateInstancesInput) error {
|
||||
pw, err := azure.GeneratePassword()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
for i := 0; i < input.CountControlPlanes; i++ {
|
||||
vm := azure.VMInstance{
|
||||
Name: c.name + "-control-plane-" + c.uid + "-" + strconv.Itoa(i),
|
||||
Username: "constell",
|
||||
Password: pw,
|
||||
Location: c.location,
|
||||
InstanceType: input.InstanceType,
|
||||
Image: input.Image,
|
||||
}
|
||||
instance, err := c.createInstanceVM(ctx, vm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.controlPlanes[strconv.Itoa(i)] = instance
|
||||
}
|
||||
|
||||
for i := 0; i < input.CountWorkers; i++ {
|
||||
vm := azure.VMInstance{
|
||||
Name: c.name + "-worker-" + c.uid + "-" + strconv.Itoa(i),
|
||||
Username: "constell",
|
||||
Password: pw,
|
||||
Location: c.location,
|
||||
InstanceType: input.InstanceType,
|
||||
Image: input.Image,
|
||||
}
|
||||
instance, err := c.createInstanceVM(ctx, vm)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
c.workers[strconv.Itoa(i)] = instance
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
// createInstanceVM creates a single VM with a public IP address
|
||||
// and a network interface.
|
||||
// TODO: deprecate as soon as scale sets are available.
|
||||
func (c *Client) createInstanceVM(ctx context.Context, input azure.VMInstance) (cloudtypes.Instance, error) {
|
||||
pubIPName := input.Name + "-pubIP"
|
||||
pubIP, err := c.createPublicIPAddress(ctx, pubIPName)
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
nicName := input.Name + "-NIC"
|
||||
privIP, nicID, err := c.createNIC(ctx, nicName, *pubIP.ID)
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
input.NIC = nicID
|
||||
|
||||
poller, err := c.virtualMachinesAPI.BeginCreateOrUpdate(ctx, c.resourceGroup, input.Name, input.Azure(), nil)
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
vm, err := poller.PollUntilDone(ctx, &runtime.PollUntilDoneOptions{
|
||||
Frequency: c.pollFrequency,
|
||||
})
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
if vm.Identity == nil || vm.Identity.PrincipalID == nil {
|
||||
return cloudtypes.Instance{}, errors.New("virtual machine was created without system managed identity")
|
||||
}
|
||||
|
||||
if err := c.assignResourceGroupRole(ctx, *vm.Identity.PrincipalID, virtualMachineContributorRoleDefinitionID); err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
res, err := c.publicIPAddressesAPI.Get(ctx, c.resourceGroup, pubIPName, nil)
|
||||
if err != nil {
|
||||
return cloudtypes.Instance{}, err
|
||||
}
|
||||
|
||||
return cloudtypes.Instance{PublicIP: *res.PublicIPAddress.Properties.IPAddress, PrivateIP: privIP}, nil
|
||||
}
|
||||
|
||||
func (c *Client) createScaleSet(ctx context.Context, input CreateScaleSetInput) error {
|
||||
// TODO: Generating a random password to be able
|
||||
// to create the scale set. This is a temporary fix.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue