Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamic Port Allocation on Game Servers #14

Closed
1 task done
markmandel opened this issue Dec 8, 2017 · 0 comments
Closed
1 task done

Dynamic Port Allocation on Game Servers #14

markmandel opened this issue Dec 8, 2017 · 0 comments
Assignees
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/design Proposal discussing new features / fixes and how they should be implemented kind/feature New features for Agones
Milestone

Comments

@markmandel
Copy link
Member

markmandel commented Dec 8, 2017

When portPolicy is set to dynamic then the controller should select the hostPort for the GameServer container when the GameServer is created.

My current theory is to have a PortSelector as part of gameservers/controller (so they can share cache/informers) that:

  • is passed the range of ports it can create ports in
  • creates a []PortSelections, where PortSelection is a map[int32]bool where the first value is the port number and bool is whether it is taken or not, with one entry for each node. We don't actually care about tracking the nodes, as the K8s scheduler will reroute pods that already have a hostPort taken.
  • Check any active GameServers in each node, and turn off their ports for any that have a hostPort.
  • With appropriate locking, loop through the node array, and find the first port that's open, lock it, and return it.
  • When the GameServer Pod gets deleted, find the node where the port was set to true and then set it to true (With appropriate locking). Question will be where to track the Pod deletion.
  • If a Node gets added, just add a new blank entry into the []PortSelections (again with locking)
  • If a Node gets deleted/set to being unscheduled, then we will need to reset the entire state. Make sure the Pod cache is synced before doing this. (it will be the same logic as when first started)

Extras:

  • Update examples to use the dynamic portPolicy
@markmandel markmandel added area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/design Proposal discussing new features / fixes and how they should be implemented kind/feature New features for Agones labels Dec 8, 2017
@markmandel markmandel self-assigned this Dec 17, 2017
@markmandel markmandel added this to the 0.1 milestone Dec 21, 2017
markmandel added a commit that referenced this issue Dec 30, 2017
Because we allocate a port to a GameSever, we cannot
delete the GameServer until that port is free again.

This means that a GameServer must not be hard deleted until
the backing Pod is successfully Terminated - and the port is
now free again.

This implements a finalizer and backing controller code to manage
this.

This is work that need to occur for #14 (Dynamic Port Allocation)
to be completed.
markmandel added a commit that referenced this issue Jan 2, 2018
Implementation of a PortAllocator that ties into the
GameServer controller that will allocate a port on
GameServer creations (if "dynamic" portPolicy is set)
and then also release the port when a GameServer has been
deleted.

This also includes experimental support for node adding,
removal and unscheduling within the cluster.

Closes #14
markmandel added a commit that referenced this issue Jan 2, 2018
Implementation of a PortAllocator that ties into the
GameServer controller that will allocate a port on
GameServer creations (if "dynamic" portPolicy is set)
and then also release the port when a GameServer has been
deleted.

This also includes experimental support for node adding,
removal and unscheduling within the cluster.

Closes #14
markmandel added a commit that referenced this issue Jan 3, 2018
Implementation of a PortAllocator that ties into the
GameServer controller that will allocate a port on
GameServer creations (if "dynamic" portPolicy is set)
and then also release the port when a GameServer has been
deleted.

This also includes experimental support for node adding,
removal and unscheduling within the cluster.

Closes #14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/user-experience Pertaining to developers trying to use Agones, e.g. SDK, installation, etc kind/design Proposal discussing new features / fixes and how they should be implemented kind/feature New features for Agones
Projects
None yet
Development

No branches or pull requests

1 participant