Skip to content

Instantly share code, notes, and snippets.

@zhiguangwang
Last active May 7, 2022 06:16
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save zhiguangwang/3656fd39146521b44fc0e7df65395527 to your computer and use it in GitHub Desktop.
Save zhiguangwang/3656fd39146521b44fc0e7df65395527 to your computer and use it in GitHub Desktop.
Use Nomad "spread" Scheduler

Read Scheduler Config

curl -sS --header "X-Nomad-Token: $NOMAD_TOKEN" "$NOMAD_ADDR/v1/operator/scheduler/configuration" | jq .

Sample Output

{
  "SchedulerConfig": {
    "SchedulerAlgorithm": "binpack",
    "PreemptionConfig": {
      "SystemSchedulerEnabled": true,
      "BatchSchedulerEnabled": false,
      "ServiceSchedulerEnabled": false
    },
    "MemoryOversubscriptionEnabled": false,
    "CreateIndex": 5,
    "ModifyIndex": 5
  },
  "Index": 5,
  "LastContact": 0,
  "KnownLeader": true
}

Update Scheduler Config

Note: This also enables Memory Oversubscription.

curl -X POST --header "X-Nomad-Token: $NOMAD_TOKEN" "$NOMAD_ADDR/v1/operator/scheduler/configuration" --data \
'{
  "SchedulerAlgorithm": "spread",
  "MemoryOversubscriptionEnabled": true,
  "PreemptionConfig": {
    "SystemSchedulerEnabled": true,
    "BatchSchedulerEnabled": false,
    "ServiceSchedulerEnabled": false
  }
}'

Sample Output

{
  "SchedulerConfig": {
    "SchedulerAlgorithm": "spread",
    "PreemptionConfig": {
      "SystemSchedulerEnabled": true,
      "BatchSchedulerEnabled": false,
      "ServiceSchedulerEnabled": false
    },
    "MemoryOversubscriptionEnabled": true,
    "CreateIndex": 5,
    "ModifyIndex": 12335
  },
  "Index": 12335,
  "LastContact": 0,
  "KnownLeader": true
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment