diff --git a/api/v1alpha3/gcpmachine_types.go b/api/v1alpha3/gcpmachine_types.go index 5c9194b2c..f7f52ef51 100644 --- a/api/v1alpha3/gcpmachine_types.go +++ b/api/v1alpha3/gcpmachine_types.go @@ -81,6 +81,10 @@ type GCPMachineSpec struct { // Defaults to: email: "default", scope: []{compute.CloudPlatformScope} // +optional ServiceAccount *ServiceAccount `json:"serviceAccounts,omitempty"` + + // Preemptible defines if instance is preemptible + // +optional + Preemptible bool `json:"preemptible,omitempty"` } // GCPMachineStatus defines the observed state of GCPMachine diff --git a/cloud/services/compute/instances.go b/cloud/services/compute/instances.go index ff3e1af4a..0f309b091 100644 --- a/cloud/services/compute/instances.go +++ b/cloud/services/compute/instances.go @@ -103,6 +103,9 @@ func (s *Service) CreateInstance(scope *scope.MachineScope) (*compute.Instance, }, }, }, + Scheduling: &compute.Scheduling{ + Preemptible: scope.GCPMachine.Spec.Preemptible, + }, } if scope.GCPMachine.Spec.ServiceAccount != nil { diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml index 8b9b7079e..d92de128b 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachines.yaml @@ -87,6 +87,9 @@ spec: description: 'InstanceType is the type of instance to create. Example: n1.standard-2' type: string + preemptible: + description: Preemptible defines if instance is preemptible + type: boolean providerID: description: ProviderID is the unique identifier as specified by the cloud provider. diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml index 53bd0c1c0..965c78af1 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_gcpmachinetemplates.yaml @@ -76,6 +76,9 @@ spec: description: 'InstanceType is the type of instance to create. Example: n1.standard-2' type: string + preemptible: + description: Preemptible defines if instance is preemptible + type: boolean providerID: description: ProviderID is the unique identifier as specified by the cloud provider.