Skip to content
Permalink
Browse files

Added ability to select AZ

  • Loading branch information...
soggiest committed Jul 24, 2019
1 parent 0b35ca0 commit 49a3a47b56d22dd6b2dbaf9c33465a1d8761dc95
@@ -19,6 +19,7 @@ items:
roles:
- Master
location: ${LOCATION}
availabilityZone: ${AVAILABILITY_ZONE}
vmSize: ${CONTROL_PLANE_MACHINE_TYPE}
image:
publisher: "Canonical"
@@ -25,6 +25,7 @@ spec:
roles:
- Node
location: ${LOCATION}
availabilityZone: ${AVAILABILITY_ZONE}
vmSize: ${NODE_MACHINE_TYPE}
image:
publisher: "Canonical"
@@ -19,6 +19,7 @@ items:
roles:
- Master
location: ${LOCATION}
availabilityZone: ${AVAILABILITY_ZONE}
vmSize: ${CONTROL_PLANE_MACHINE_TYPE}
image:
publisher: "Canonical"
@@ -48,6 +49,7 @@ items:
roles:
- Node
location: ${LOCATION}
availabilityZone: ${AVAILABILITY_ZONE}
vmSize: ${NODE_MACHINE_TYPE}
image:
publisher: "Canonical"
@@ -21,6 +21,8 @@ spec:
type: string
bastion:
properties:
availabilityZone:
type: string
id:
type: string
identity:
@@ -19,6 +19,8 @@ spec:
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/api-conventions.md#resources'
type: string
availabilityZone:
type: string
image:
properties:
offer:
@@ -349,6 +351,7 @@ spec:
type: string
required:
- location
- availabilityZone
- vmSize
- image
- osDisk
@@ -34,11 +34,12 @@ type AzureMachineProviderSpec struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Location string `json:"location"`
VMSize string `json:"vmSize"`
Image Image `json:"image"`
OSDisk OSDisk `json:"osDisk"`
SSHPublicKey string `json:"sshPublicKey"`
Location string `json:"location"`
AvailabilityZone string `json:"availabilityZone"`
VMSize string `json:"vmSize"`
Image Image `json:"image"`
OSDisk OSDisk `json:"osDisk"`
SSHPublicKey string `json:"sshPublicKey"`

// KubeadmConfiguration holds the kubeadm configuration options
// TODO: Backfill logic
@@ -339,6 +339,8 @@ type VM struct {
ID string `json:"id,omitempty"`
Name string `json:"name,omitempty"`

AvailabilityZone string `json:"availabilityZone,omitempty"`

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

@@ -491,9 +491,17 @@ func (r *Reconciler) createVirtualMachine(ctx context.Context, nicName string) e

vmInterface, err := r.virtualMachinesSvc.Get(ctx, vmSpec)
if err != nil && vmInterface == nil {
vmZone, zoneErr := r.getVirtualMachineZone(ctx)
if zoneErr != nil {
return errors.Wrap(zoneErr, "failed to get availability zone")
var vmZone string
var zoneErr error

vmZone = r.scope.MachineConfig.AvailabilityZone

if r.scope.MachineConfig.AvailabilityZone == "" {
vmZone, zoneErr = r.getVirtualMachineZone(ctx)
if zoneErr != nil {
return errors.Wrap(zoneErr, "failed to get availability zone")
}
klog.Info("No availability zone set, selecting random availability zone:", vmZone)
}

vmSpec = &virtualmachines.Spec{
@@ -150,6 +150,8 @@ func (s *Service) Reconcile(ctx context.Context, spec v1alpha1.ResourceSpec) err
},
}

klog.V(2).Infof("Setting zone %s ", vmSpec.Zone)

if vmSpec.Zone != "" {
zones := []string{vmSpec.Zone}
virtualMachine.Zones = &zones

0 comments on commit 49a3a47

Please sign in to comment.
You can’t perform that action at this time.