Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add custom VM sizes for aks-iot deployments #150

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ ETCD=$(TOOLS_BIN_DIR)/etcd
# Version
MAJOR_VER ?= 0
MINOR_VER ?= 3
PATCH_VER ?= 9-alpha
PATCH_VER ?= 10-alpha

# Define Docker related variables. Releases should modify and double check these vars.
REGISTRY ?= mocimages.azurecr.io
Expand Down
1 change: 1 addition & 0 deletions api/v1alpha3/azurestackhcimachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type AzureStackHCIMachineSpec struct {
ProviderID *string `json:"providerID,omitempty"`

VMSize string `json:"vmSize"`
CustomSize VirtualMachineCustomSize `json:"customSize,omitempty"`

AvailabilityZone AvailabilityZone `json:"availabilityZone,omitempty"`

Expand Down
17 changes: 9 additions & 8 deletions api/v1alpha3/azurestackhcivirtualmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,15 @@ const (

// AzureStackHCIVirtualMachineSpec defines the desired state of AzureStackHCIVirtualMachine
type AzureStackHCIVirtualMachineSpec struct {
VMSize string `json:"vmSize"`
AvailabilityZone AvailabilityZone `json:"availabilityZone,omitempty"`
Image Image `json:"image"`
OSDisk OSDisk `json:"osDisk,omitempty"`
BootstrapData *string `json:"bootstrapData,omitempty"`
Identity VMIdentity `json:"identity,omitempty"`
Location string `json:"location"` // does location belong here?
SSHPublicKey string `json:"sshPublicKey"`
VMSize string `json:"vmSize"`
CustomSize VirtualMachineCustomSize `json:"customSize,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont have any plans to expose custom size

AvailabilityZone AvailabilityZone `json:"availabilityZone,omitempty"`
Image Image `json:"image"`
OSDisk OSDisk `json:"osDisk,omitempty"`
BootstrapData *string `json:"bootstrapData,omitempty"`
Identity VMIdentity `json:"identity,omitempty"`
Location string `json:"location"` // does location belong here?
SSHPublicKey string `json:"sshPublicKey"`

// come from the cluster scope for machine and lb controller creation path
ResourceGroup string `json:"resourceGroup"`
Expand Down
6 changes: 6 additions & 0 deletions api/v1alpha3/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,11 @@ var (
VMStateUpdating = VMState("Updating")
)

type VirtualMachineCustomSize struct {
CpuCount int32 `json:"cpuCount,omitempty"`
MemoryMB int32 `json:"memoryMB,omitempty"`
}

// VM describes an Azure virtual machine.
type VM struct {
ID string `json:"id,omitempty"`
Expand All @@ -138,6 +143,7 @@ type VM struct {

// Hardware profile
VMSize string `json:"vmSize,omitempty"`
CustomSize VirtualMachineCustomSize `json:"customSize,omitempty"`

// Storage profile
Image Image `json:"image,omitempty"`
Expand Down
10 changes: 8 additions & 2 deletions cloud/services/virtualmachines/virtualmachines.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,9 @@ type Spec struct {
Name string
NICName string
SSHKeyData []string
Size string
VMSize string
CpuCount int32
MemoryMB int32
Zone string
Image infrav1.Image
OSDisk infrav1.OSDisk
Expand Down Expand Up @@ -154,7 +156,11 @@ func (s *Service) Reconcile(ctx context.Context, spec interface{}) error {
},
VmType: vmSpec.VMType,
HardwareProfile: &compute.HardwareProfile{
VMSize: compute.VirtualMachineSizeTypes(vmSpec.Size),
VMSize: compute.VirtualMachineSizeTypes(vmSpec.VMSize),
CustomSize: &compute.VirtualMachineCustomSize{
CpuCount: &vmSpec.CpuCount,
MemoryMB: &vmSpec.MemoryMB,
},
},
},
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,15 @@ spec:
vmSize:
description: Hardware profile
type: string
customSize:
properties:
cpuCount:
format: int32
type: integer
memoryMB:
format: int32
type: integer
type: object
vmState:
description: State - The provisioning state, which only appears
in the response.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,15 @@ spec:
type: string
vmSize:
type: string
customSize:
properties:
cpuCount:
format: int32
type: integer
memoryMB:
format: int32
type: integer
type: object
required:
- location
- sshPublicKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ spec:
type: string
vmSize:
type: string
customSize:
properties:
cpuCount:
format: int32
type: integer
memoryMB:
format: int32
type: integer
type: object
required:
- location
- sshPublicKey
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,15 @@ spec:
type: string
vmSize:
type: string
customSize:
properties:
cpuCount:
format: int32
type: integer
memoryMB:
format: int32
type: integer
type: object
vnetName:
type: string
required:
Expand Down
2 changes: 1 addition & 1 deletion config/manager/manager_image_patch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ spec:
template:
spec:
containers:
- image: mocimages.azurecr.io/caphcontroller:0.3.9-alpha
- image: mocimages.azurecr.io/caphcontroller:0.3.10-alpha
name: manager
2 changes: 2 additions & 0 deletions controllers/azurestackhcimachine_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ func (r *AzureStackHCIMachineReconciler) reconcileVirtualMachineNormal(machineSc
image.DeepCopyInto(&vm.Spec.Image)

vm.Spec.VMSize = machineScope.AzureStackHCIMachine.Spec.VMSize
vm.Spec.CustomSize.CpuCount = machineScope.AzureStackHCIMachine.Spec.CustomSize.CpuCount
vm.Spec.CustomSize.MemoryMB = machineScope.AzureStackHCIMachine.Spec.CustomSize.MemoryMB
machineScope.AzureStackHCIMachine.Spec.AvailabilityZone.DeepCopyInto(&vm.Spec.AvailabilityZone)
machineScope.AzureStackHCIMachine.Spec.OSDisk.DeepCopyInto(&vm.Spec.OSDisk)
vm.Spec.Location = machineScope.AzureStackHCIMachine.Spec.Location
Expand Down
4 changes: 3 additions & 1 deletion controllers/azurestackhcivirtualmachine_reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,9 @@ func (s *azureStackHCIVirtualMachineService) createVirtualMachine(nicName string
Name: s.vmScope.Name(),
NICName: nicName,
SSHKeyData: decodedKeys,
Size: s.vmScope.AzureStackHCIVirtualMachine.Spec.VMSize,
VMSize: s.vmScope.AzureStackHCIVirtualMachine.Spec.VMSize,
CpuCount: s.vmScope.AzureStackHCIVirtualMachine.Spec.CustomSize.CpuCount,
MemoryMB: s.vmScope.AzureStackHCIVirtualMachine.Spec.CustomSize.MemoryMB,
OSDisk: s.vmScope.AzureStackHCIVirtualMachine.Spec.OSDisk,
Image: s.vmScope.AzureStackHCIVirtualMachine.Spec.Image,
CustomData: *s.vmScope.AzureStackHCIVirtualMachine.Spec.BootstrapData,
Expand Down
3 changes: 3 additions & 0 deletions templates/flavors/base/cluster-template.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ spec:
osType: "Linux"
location: "westus"
vmSize: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE}
customSize:
cpuCount: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE_CPU_COUNT}
memoryMB: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE_MEMORY_MB}
sshPublicKey: ${AZURESTACKHCI_SSH_PUBLIC_KEY:=""}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
Expand Down
5 changes: 4 additions & 1 deletion templates/flavors/mgmt/mgmt-machine.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ spec:
providerID: moc://${CLUSTER_NAME}-control-plane-0
sshPublicKey: ${AZURESTACKHCI_SSH_PUBLIC_KEY:=""}
vmSize: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE}
customSize:
cpuCount: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE_CPU_COUNT}
memoryMB: ${AZURESTACKHCI_CONTROL_PLANE_MACHINE_TYPE_MEMORY_MB}
---
apiVersion: bootstrap.cluster.x-k8s.io/v1alpha3
kind: KubeadmConfig
Expand Down Expand Up @@ -70,4 +73,4 @@ spec:
cloud-provider: external
name: '{{ ds.meta_data["local_hostname"] }}'
useExperimentalRetryJoin: true
---
---