dgkanatsios/azuregameserversscalingkubernetes

Work with Scheduled Events for Azure Linux VMs

Opened this issue · 0 comments

Azure provides an API to see if a VM will reboot for maintenance. Details for this API are listed here. You can try it this way:

kubectl run busybox --image=busybox --rm --restart=Never -it -- /bin/sh
wget -O- --header=Metadata:true http://169.254.169.254/metadata/scheduledevents?api-version=2017-08-01 # first call takes some time, it will probably return 200 and empty body
# go to the portal, manually click “reboot” on a VM
# after a while …
wget -O- --header=Metadata:true http://169.254.169.254/metadata/scheduledevents?api-version=2017-08-01
Connecting to 169.254.169.254 (169.254.169.254:80)
{"DocumentIncarnation":1,"Events":[{"EventId":"8A506C35-679A-4F78-9D76-C16DBE65EE6F","EventStatus":"Scheduled","EventType":"Reboot","ResourceType":"VirtualMachine","Resources":["aks-nodepool1-34166363-1"],"NotBefore":"Mon, 26 Nov 2018 10:52:34 GMT"}]}

Proposed design:

  • Create a DaemonSet with an app that calls this API and runs every X minutes
  • If there is a reboot scheduled event
  • Do a cleanup on the Pods on this Node (e.g. if it’s a game server, don’t schedule any more players/games here)
  • Cordon the Node so it’s unschedulable
  • When the reboot finishes (we should keep state in a ConfigMap?), uncordon the Node