Add Availability Set support
This commit is contained in:
bgriddaluru 2024-03-19 16:28:48 -07:00 коммит произвёл GitHub
Родитель a7e3e3392b
Коммит c64322464b
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: B5690EEEBB952194
7 изменённых файлов: 523 добавлений и 101 удалений

Просмотреть файл

@ -59,6 +59,9 @@ type AzureStackHCIMachineSpec struct {
// +optional
NetworkInterfaces NetworkInterfaces `json:"networkInterfaces,omitempty"`
// +optional
AvailabilitySetName string `json:"availabilitySetName,omitempty"`
}
// AzureStackHCIMachineStatus defines the observed state of AzureStackHCIMachine

Просмотреть файл

@ -55,6 +55,9 @@ type AzureStackHCIVirtualMachineSpec struct {
// +optional
NetworkInterfaces NetworkInterfaces `json:"networkInterfaces,omitempty"`
// +optional
AvailabilitySetName string `json:"availabilitySetName,omitempty"`
}
// AzureStackHCIVirtualMachineStatus defines the observed state of AzureStackHCIVirtualMachine

Просмотреть файл

@ -44,16 +44,17 @@ const (
// Spec input specification for Get/CreateOrUpdate/Delete calls
type Spec struct {
Name string
NICName string
SSHKeyData []string
Size string
Zone string
Image infrav1.Image
OSDisk infrav1.OSDisk
CustomData string
VMType compute.VMType
StorageContainer string
Name string
NICName string
SSHKeyData []string
Size string
Zone string
Image infrav1.Image
OSDisk infrav1.OSDisk
CustomData string
VMType compute.VMType
StorageContainer string
AvailabilitySetName string
}
// Get provides information about a virtual machine.
@ -106,6 +107,7 @@ func (s *Service) Reconcile(ctx context.Context, spec interface{}) error {
"Image", vmSpec.Image,
"OSDisk", vmSpec.OSDisk,
"VMType", vmSpec.VMType,
"AvailabilitySetName", vmSpec.AvailabilitySetName,
)
sshKeyData := vmSpec.SSHKeyData
@ -180,6 +182,12 @@ func (s *Service) Reconcile(ctx context.Context, spec interface{}) error {
},
}
}
if vmSpec.AvailabilitySetName != "" {
virtualMachine.VirtualMachineProperties.AvailabilitySetProfile = &compute.AvailabilitySetReference{
Name: to.StringPtr(vmSpec.AvailabilitySetName),
GroupName: to.StringPtr(s.Scope.GetResourceGroup()),
}
}
_, err = s.Client.CreateOrUpdate(
ctx,

Просмотреть файл

@ -322,6 +322,7 @@ func (r *AzureStackHCIMachineReconciler) reconcileVirtualMachineNormal(machineSc
vm.Spec.BootstrapData = &bootstrapData
vm.Spec.AdditionalSSHKeys = machineScope.AzureStackHCIMachine.Spec.AdditionalSSHKeys
vm.Spec.StorageContainer = machineScope.AzureStackHCIMachine.Spec.StorageContainer
vm.Spec.AvailabilitySetName = machineScope.AzureStackHCIMachine.Spec.AvailabilitySetName
machineScope.AzureStackHCIMachine.Spec.NetworkInterfaces.DeepCopyInto(&vm.Spec.NetworkInterfaces)

Просмотреть файл

@ -229,16 +229,17 @@ func (s *azureStackHCIVirtualMachineService) createVirtualMachine(nicName string
s.vmScope.Info("VM type is:", "vmType", vmType)
vmSpec = &virtualmachines.Spec{
Name: s.vmScope.Name(),
NICName: nicName,
SSHKeyData: decodedKeys,
Size: s.vmScope.AzureStackHCIVirtualMachine.Spec.VMSize,
OSDisk: s.vmScope.AzureStackHCIVirtualMachine.Spec.OSDisk,
Image: s.vmScope.AzureStackHCIVirtualMachine.Spec.Image,
CustomData: *s.vmScope.AzureStackHCIVirtualMachine.Spec.BootstrapData,
Zone: vmZone,
VMType: vmType,
StorageContainer: s.vmScope.StorageContainer(),
Name: s.vmScope.Name(),
NICName: nicName,
SSHKeyData: decodedKeys,
Size: s.vmScope.AzureStackHCIVirtualMachine.Spec.VMSize,
OSDisk: s.vmScope.AzureStackHCIVirtualMachine.Spec.OSDisk,
Image: s.vmScope.AzureStackHCIVirtualMachine.Spec.Image,
CustomData: *s.vmScope.AzureStackHCIVirtualMachine.Spec.BootstrapData,
Zone: vmZone,
VMType: vmType,
StorageContainer: s.vmScope.StorageContainer(),
AvailabilitySetName: s.vmScope.AzureStackHCIVirtualMachine.Spec.AvailabilitySetName,
}
err = s.virtualMachinesSvc.Reconcile(s.vmScope.Context, vmSpec)

34
go.mod
Просмотреть файл

@ -7,8 +7,8 @@ require (
github.com/blang/semver v3.5.1+incompatible
github.com/go-logr/logr v1.2.4
github.com/golang/mock v1.6.0
github.com/microsoft/moc v0.11.0-alpha.37
github.com/microsoft/moc-sdk-for-go v0.11.1-alpha.14
github.com/microsoft/moc v0.16.0
github.com/microsoft/moc-sdk-for-go v0.16.0
github.com/onsi/ginkgo/v2 v2.11.0
github.com/onsi/gomega v1.27.8
github.com/pkg/errors v0.9.1
@ -26,7 +26,7 @@ require (
require (
github.com/Azure/go-autorest v14.2.0+incompatible // indirect
github.com/Azure/go-autorest/autorest v0.11.18 // indirect
github.com/Azure/go-autorest/autorest v0.11.29 // indirect
github.com/Azure/go-autorest/autorest/adal v0.9.23 // indirect
github.com/Azure/go-autorest/autorest/date v0.3.0 // indirect
github.com/Azure/go-autorest/logger v0.2.1 // indirect
@ -37,7 +37,7 @@ require (
github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect
github.com/emicklei/go-restful/v3 v3.9.0 // indirect
github.com/evanphx/json-patch/v5 v5.6.0 // indirect
github.com/fsnotify/fsnotify v1.6.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
github.com/go-logr/zapr v1.2.4 // indirect
github.com/go-openapi/jsonpointer v0.19.6 // indirect
github.com/go-openapi/jsonreference v0.20.1 // indirect
@ -49,14 +49,14 @@ require (
github.com/golang/groupcache v0.0.0-20210331224755-41bb18bfe9da // indirect
github.com/golang/protobuf v1.5.3 // indirect
github.com/google/gnostic v0.6.9 // indirect
github.com/google/go-cmp v0.5.9 // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/gofuzz v1.2.0 // indirect
github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 // indirect
github.com/google/uuid v1.3.1 // indirect
github.com/google/uuid v1.4.0 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hectane/go-acl v0.0.0-20190604041725-da78bae5fc95 // indirect
github.com/hectane/go-acl v0.0.0-20230122075934-ca0b05cb1adb // indirect
github.com/imdario/mergo v0.3.13 // indirect
github.com/jmespath/go-jmespath v0.3.0 // indirect
github.com/jmespath/go-jmespath v0.4.0 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/json-iterator/go v1.1.12 // indirect
github.com/magiconair/properties v1.8.7 // indirect
@ -71,29 +71,29 @@ require (
github.com/prometheus/client_model v0.4.0 // indirect
github.com/prometheus/common v0.42.0 // indirect
github.com/prometheus/procfs v0.10.1 // indirect
github.com/sagikazarmark/locafero v0.3.0 // indirect
github.com/sagikazarmark/locafero v0.4.0 // indirect
github.com/sagikazarmark/slog-shim v0.1.0 // indirect
github.com/sourcegraph/conc v0.3.0 // indirect
github.com/spf13/afero v1.10.0 // indirect
github.com/spf13/cast v1.5.1 // indirect
github.com/spf13/viper v1.17.0 // indirect
github.com/spf13/afero v1.11.0 // indirect
github.com/spf13/cast v1.6.0 // indirect
github.com/spf13/viper v1.18.2 // indirect
github.com/subosito/gotenv v1.6.0 // indirect
go.uber.org/atomic v1.9.0 // indirect
go.uber.org/multierr v1.9.0 // indirect
go.uber.org/zap v1.24.0 // indirect
golang.org/x/exp v0.0.0-20230905200255-921286631fa9 // indirect
golang.org/x/net v0.17.0 // indirect
golang.org/x/oauth2 v0.12.0 // indirect
golang.org/x/net v0.22.0 // indirect
golang.org/x/oauth2 v0.15.0 // indirect
golang.org/x/sys v0.15.0 // indirect
golang.org/x/term v0.15.0 // indirect
golang.org/x/text v0.14.0 // indirect
golang.org/x/time v0.3.0 // indirect
golang.org/x/time v0.5.0 // indirect
golang.org/x/tools v0.13.0 // indirect
gomodules.xyz/jsonpatch/v2 v2.3.0 // indirect
google.golang.org/appengine v1.6.7 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20231127180814-3a041ad873d4 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20231120223509-83a465c0220f // indirect
google.golang.org/protobuf v1.31.0 // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240304212257-790db918fca8 // indirect
google.golang.org/protobuf v1.32.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/ini.v1 v1.67.0 // indirect
gopkg.in/yaml.v2 v2.4.0 // indirect

534
go.sum

Разница между файлами не показана из-за своего большого размера Загрузить разницу