-
Notifications
You must be signed in to change notification settings - Fork 820
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
docs: added game server state diagram #475
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -59,6 +59,7 @@ GS_TEST_IMAGE ?= gcr.io/agones-images/udp-server:0.5 | |
mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST))) | ||
build_path := $(dir $(mkfile_path)) | ||
agones_path := $(realpath $(build_path)/..) | ||
docs_path := $(agones_path)/docs | ||
|
||
kubeconfig_path := $(dir $(KUBECONFIG)) | ||
kubeconfig_file := $(notdir $(KUBECONFIG)) | ||
|
@@ -296,6 +297,12 @@ gen-crd-client: $(ensure-build-image) | |
docker run --rm $(common_mounts) -w $(mount_path) $(build_tag) /root/gen-crd-client.sh | ||
docker run --rm $(common_mounts) -w $(mount_path)/pkg $(build_tag) goimports -w . | ||
|
||
doc-images: $(docs_path)/gameserver-states.png | ||
|
||
%.png: %.dot | ||
docker run -i --rm $(common_mounts) $(DOCKER_RUN_ARGS) $(build_tag) bash -c \ | ||
'dot -Tpng /dev/stdin' < $< > [email protected] && mv [email protected] $@ | ||
|
||
# Run a bash shell with the developer tools in it. (Creates the image if it doesn't exist) | ||
# Can use DOCKER_RUN_ARGS for extra arguments. | ||
shell: $(ensure-build-image) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
digraph { | ||
graph [fontname = "helvetica"]; | ||
node [fontname = "helvetica"]; | ||
edge [fontname = "helvetica", pad="0.2", penwidth="2"]; | ||
|
||
Created [ label = "game server created" ] | ||
PortAllocation | ||
Creating | ||
Error | ||
Starting | ||
Scheduled | ||
RequestReady | ||
Ready | ||
Allocated | ||
Shutdown | ||
Unhealthy | ||
Allocated | ||
Deleted [ label = "game server deleted" ] | ||
|
||
Created -> PortAllocation [ label ="has any port\nwith dynamic policy", color="red" ] | ||
Created -> Creating [ label="only static ports", color="red" ] | ||
|
||
PortAllocation -> Creating [ label="allocated unused port", color="blue" ] | ||
Creating -> Starting [ label="created pod", color="blue" ] | ||
Starting -> Scheduled [ label="we have a pod, fetch its address", color="blue" ] | ||
Scheduled -> RequestReady [ label="SDK.ready()", color="purple" ] | ||
RequestReady -> Ready [ label="ready to be allocated", color="blue" ] | ||
Ready -> Allocated [ label="allocated for use", color="orange" ] | ||
|
||
Creating -> Error [ label="failed to create pod", color="blue" ] | ||
|
||
Scheduled -> Shutdown [ label="SDK.shutdown()", color="purple" ] | ||
RequestReady -> Shutdown [ color="purple" ] | ||
Ready -> Shutdown [ color="purple" ] | ||
Allocated -> Shutdown [ color="purple" ] | ||
|
||
Scheduled -> Unhealthy [ label="failed to call SDK.healthy()\nin a timely manner" ] | ||
RequestReady -> Unhealthy [ color="purple" ] | ||
Ready -> Unhealthy [ color="purple" ] | ||
Allocated -> Unhealthy [ color="purple" ] | ||
|
||
Unhealthy -> Deleted [ label="delete unhealthy game server", color="blue" ] | ||
Shutdown -> Deleted [ label="delete finished game server", color="blue" ] | ||
|
||
subgraph cluster_01 { | ||
style=invis; | ||
{ | ||
s1 [style="invis"]; | ||
s2 [style="invis"]; | ||
s1 -> s2 [ color="red", label="API user" ] | ||
} | ||
|
||
{ | ||
s3 [style="invis"]; | ||
s4 [style="invis"]; | ||
s3 -> s4 [ color="purple", label="SDK" ] | ||
} | ||
|
||
{ | ||
s5 [style="invis"]; | ||
s6 [style="invis"]; | ||
s5 -> s6 [ color="orange", label="allocation\ncontroller" ] | ||
} | ||
|
||
{ | ||
s7 [style="invis"]; | ||
s8 [style="invis"]; | ||
s7 -> s8 [ color="blue", label="game server\ncontroller" ] | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,3 +46,15 @@ The `spec` field is the actual GameServer specification and it is composed as fo | |
- `protocol` the protocol being used. Defaults to UDP. TCP is the only other option. | ||
- `health` to track the overall healthy state of the GameServer, more information available in the [health check documentation](./health_checking.md). | ||
- `template` the [pod spec template](https://v1-10.docs.kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/#podtemplatespec-v1-core) to run your GameServer containers, [see](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/#pod-templates) for more information. | ||
|
||
## GameServer State Diagram | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I feel like this should be it's own doc - maybe under reference? Or maybe part of the SDK integration? Not sure. Here is feels a bit hidden? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Changed my mind - it's in the reference already, and we can rework it if need be in the new website (and I'll need to merge anyway), so let's get this in. |
||
|
||
The following diagram shows the lifecycle of a `GameServer`. | ||
|
||
Game Servers are created through Kubernetes API (either directly or through a [Fleet](fleet_spec.md)) and their state transitions are orchestrated by: | ||
|
||
- GameServer controller, which allocates ports, launches Pods backing game servers and manages their lifetime | ||
- Allocation controller, which marks game servers as `Allocated` to handle a game session | ||
- SDK, which manages health checking and shutdown of a game server session | ||
|
||
![GameServer State Diagram](gameserver-states.png) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we want to put dot in the build image, so anyone can regenerate the diagram?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dot (graphviz) was already there. Changed makefile to use it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fancy makefile usage! 👍