Skip to content

Commit

Permalink
tpu-provisioner: Add support for Spot Node Pools (#588)
Browse files Browse the repository at this point in the history
  • Loading branch information
nstogner committed Apr 16, 2024
1 parent 53b6d79 commit 179dbad
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions tpu-provisioner/internal/cloud/gke.go
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,19 @@ func (g *GKE) nodePoolForPod(name string, p *corev1.Pod) (*containerv1beta1.Node
}
}

var taints []*containerv1beta1.NodeTaint

spot := p.Spec.NodeSelector["cloud.google.com/gke-spot"] == "true"
if spot {
// Add the taint that NAP would add.
// https://cloud.google.com/kubernetes-engine/docs/concepts/spot-vms#spotvms-nap
taints = append(taints, &containerv1beta1.NodeTaint{
Key: "cloud.google.com/gke-spot",
Value: "true",
Effect: "NO_SCHEDULE",
})
}

var secondaryDisks []containerv1beta1.SecondaryBootDisk
if g.ClusterContext.NodeSecondaryDisk != "" {
secondaryDisks = []containerv1beta1.SecondaryBootDisk{
Expand All @@ -288,6 +301,8 @@ func (g *GKE) nodePoolForPod(name string, p *corev1.Pod) (*containerv1beta1.Node
MachineType: machineType,
ReservationAffinity: reservation,
Labels: labels,
Spot: spot,
Taints: taints,
},
InitialNodeCount: int64(nodeCount),
Locations: []string{g.ClusterContext.NodeZone},
Expand Down

0 comments on commit 179dbad

Please sign in to comment.