In Kubernetes, Priority determines the importance of a Pod to other Pods and Preemption is the logic which tries to find a Node to remove one or more low priority Pods to schedule a high priority Pod.
The goal of this project is to clarify those concepts through code
examples. This project deploys an All-in-One Kubernetes Cluster with
the NonPreemptingPriority
feature gate enabled with the
installer bash script which is consumed by the
Vagrantfile.
This project uses Vagrant tool for provisioning Virtual Machines automatically. It's highly recommended to use the setup.sh script of the bootstrap-vagrant project for installing Vagrant dependencies and plugins required for its project. The script supports two Virtualization providers (Libvirt and VirtualBox).
$ curl -fsSL http://bit.ly/initVagrant | PROVIDER=libvirt bash
Once Vagrant is installed, it's possible to deploy the demo with the following instruction:
$ vagrant up
After the All-in-One Kubernetes Cluster is deployed the
installer creates two kubernetes cron jobs with
different PriorityClass
on their pods. The trivial-job
executes a counter job every minute and the urgent-job
every three
minutes. They are using preemptionPolicy: Never
to avoid any
preemption process.
As you can see, the jobs of the urgent-job
have preference in the
queue during the execution of the jobs without any preempt action over
the existing Pods of trivial-job
.