Tolerations and Affinity

Adding Tolerations

Our next task is to add tolerations and affinities to the application.

In the previous section we created two nodegroups that were tainted with spotInstance: "true:PreferNoSchedule". PreferNoSchedule is used to indicate we prefer pods not to be scheduled on Spot Instances. NoSchedule can also be used to enforce a hard discrimination as a taint. To overcome the spotInstance: "true:PreferNoSchedule" taint, we need to create a toleration in the deployment. Read about how tolerations are applied and modify the monte-carlo-pi-service.yml file accordingly.

Show me a hint for implementing this.

Adding Affinities

Our final task before deploying is to add affinities to the configuration.

In the previous section we created nodegroups with the label intent and values control-apps and apps. We also created nodegroups with the label lifecycle and values OnDemand and Ec2Spot. For us to adhere to the criteria above we will need to add two affinity properties:

  • a requiredDuringSchedulingIgnoredDuringExecution affinity: also known as “hard” affinity that will limit our deployment to nodes label with intent: apps
  • a preferredDuringSchedulingIgnoredDuringExecution affinity: also known as “soft” affinity that express our preference for nodes of a specific type. In this case Spot instances labeled with lifecycle: Ec2Spot.

Read about how affinities can be used to assign pods to nodes and modify the monte-carlo-pi-service.yml file accordingly.

Show me a hint for implementing this.