File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -17,6 +17,7 @@ limitations under the License.
1717package v1beta1
1818
1919import (
20+ "cloud.google.com/go/compute/apiv1/computepb"
2021 corev1 "k8s.io/api/core/v1"
2122 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2223)
@@ -386,6 +387,10 @@ type GCPMachineSpec struct {
386387 // attached to the instance.
387388 // +optional
388389 GuestAccelerators []Accelerator `json:"guestAccelerators,omitempty"`
390+
391+ // ReservationAffinity indicates the reservation that this instance has affinity for.
392+ // +optional
393+ ReservationAffinity * computepb.ReservationAffinity `json:"reservationAffinity,omitempty"`
389394}
390395
391396// Accelerator is a specification of the type and number of accelerator
Original file line number Diff line number Diff line change @@ -504,6 +504,18 @@ func (m *MachineScope) InstanceSpec(log logr.Logger) *compute.Instance {
504504 instance .Scheduling .OnHostMaintenance = "TERMINATE"
505505 }
506506
507+ if m .GCPMachine .Spec .ReservationAffinity != nil {
508+ instance .ReservationAffinity = & compute.ReservationAffinity {
509+ ConsumeReservationType : string (m .GCPMachine .Spec .ReservationAffinity .GetConsumeReservationType ()),
510+ }
511+ if m .GCPMachine .Spec .ReservationAffinity .Key != nil {
512+ instance .ReservationAffinity .Key = m .GCPMachine .Spec .ReservationAffinity .GetKey ()
513+ }
514+ if len (m .GCPMachine .Spec .ReservationAffinity .Values ) > 0 {
515+ instance .ReservationAffinity .Values = m .GCPMachine .Spec .ReservationAffinity .GetValues ()
516+ }
517+ }
518+
507519 return instance
508520}
509521
You can’t perform that action at this time.
0 commit comments