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

adding new portsToExpose #214

Merged
merged 2 commits into from
Apr 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .versions
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
#!/bin/bash
export IMAGE_TAG=0.3.1
export IMAGE_TAG=0.3.2
5 changes: 1 addition & 4 deletions cmd/nodeagent/nodeagentmanager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,10 +287,7 @@ func createUnstructuredTestGameServer(name, namespace string) *unstructured.Unst
"titleID": "testTitleID",
"buildID": "testBuildID",
"portsToExpose": []interface{}{
map[string]interface{}{
"containerName": "containerName",
"portName": "portName",
},
"80",
},
},
"status": map[string]interface{}{
Expand Down
3 changes: 1 addition & 2 deletions docs/FAQ.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ spec:
standingBy: 2 # required
max: 4 # required
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80 # one of the ports mentioned below
template:
metadata:
annotations:
Expand Down
2 changes: 1 addition & 1 deletion docs/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ Thundernetes requires a Kubernetes cluster with Public IP per Node. We've tested

Moreover, Thundernetes requires ports in the range 10000-12000 to be open in the cluster for external connections (i.e. in the case of Azure Kubernetes Service, this port range must allow incoming traffic in the corresponding Network Security Group). This port range is configurable, check [here](howtos/configureportrange.md) for details.

Each GameServerBuild contains the *portsToExpose* field, which contains information about the port(s) that each GameServer listens to for incoming client connections. When the GameServer Pod is created, each port in the *portsToExpose* field will be assigned a port in the (default) range 10000-12000 (let's call it an external port) via a PortRegistry mechanism in the Thundernetes controller. Game clients can send traffic to this external port and this will be forwarded to the game server container port. Once the GameServer session ends, the port is returned back to the pool of available ports and may be re-used in the future.
Each GameServerBuild contains the *portsToExpose* field, which contains the port(s) that each GameServer listens to for incoming client connections. When the GameServer Pod is created, each port in the *portsToExpose* field will be assigned a port in the (default) range 10000-12000 (let's call it an external port) via a PortRegistry mechanism in the Thundernetes controller. Game clients can send traffic to this external port and this will be forwarded to the game server container port. Once the GameServer session ends, the port is returned back to the pool of available ports and may be re-used in the future.

> _**NOTE**_: Each port that is allocated by the PortRegistry is assigned to HostPort field of the Pod's definition. The fact that Nodes in the cluster have a Public IP makes this port accessible outside the cluster.
> _**NOTE**_: Thundernetes supports `hostNetwork` networking for the GameServer Pods, if requested in the GameServerBuild Pod definition.
Expand Down
15 changes: 8 additions & 7 deletions docs/gameserverbuild.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,8 @@ spec:
value: "buildMetadataValue1"
- key: "buildMetadataKey2"
value: "buildMetadataValue2"
portsToExpose: # port names that you need to expose for your game server, read more below
- containerName: gameserver-sample # name of the container that you want its port exposed. Must be the same as containers.containerName
portName: gameport # name of the port that you want to expose. Must be the same as containers.ports.name
portsToExpose:
- 7777
template:
spec:
containers:
Expand All @@ -45,11 +44,13 @@ The template.spec contains the definition for a [Kubernetes Pod](https://kuberne

## PortsToExpose

This is a list of containerName/portName tuples: These are the ports that you want to be exposed in the [Worker Node/VM](https://kubernetes.io/docs/concepts/architecture/nodes/) when the Pod is created. The way this works is that each Pod you create will have >=1 number of containers. There, each container will have its own *Ports* definition. If a port in this definition is included in the *portsToExpose* array, this port will be publicly exposed in the Node/VM. This is accomplished by the setting of a **hostPort** value for each of the container ports you want to expose.
This is a list of ports that you want to be exposed in the [Worker Node/VM](https://kubernetes.io/docs/concepts/architecture/nodes/) when the Pod is created. The way this works is that each Pod you create will have >=1 number of containers. There, each container will have its own *Ports* definition. If a port number in this definition is included in the *portsToExpose* array, this port will be publicly exposed in the Node/VM. This is accomplished by the setting of a **hostPort** value for each of the container ports you want to expose.

The reasons we need this functionality are:
i) you may want to use some ports on your Pod containers for other purposes rather than players connecting to it
ii) a portName must be unique within a container. Ports assigned are in the port range 10000-12000 by default. This port range is configurable, check [here](howtos/configureportrange.md) for details.
The reason we need this functionality is that you may want to use some ports on your Pod containers for other purposes rather than players connecting to it.

Ports that are to be exposed are assigned a number in the port range 10000-12000 by default. This port range is configurable, check [here](howtos/configureportrange.md) for details.

**IMPORTANT**: Port names must be specified for all the ports that are in the *portsToExpose* array. Reason is that these ports are accessible via the GSDK, using their name. This way, the game server can discover them on runtime.

## CrashesToMarkUnhealthy

Expand Down
3 changes: 1 addition & 2 deletions docs/yourgameserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@ spec:
standingBy: 2 # required
max: 4 # required
portsToExpose:
- containerName: thundernetes-sample # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/fileshare/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ spec:
max: 4 # required
crashesToMarkUnhealthy: 5 # optional, default is 5. It is the number of crashes needed to mark the build unhealthy
portsToExpose:
- containerName: mpswrapper # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/netcore/sample-hostnetwork.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
hostNetwork: true # this sample uses host networking
Expand Down
3 changes: 1 addition & 2 deletions samples/netcore/sample-nodeaffinity.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/netcore/sample-requestslimits.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/netcore/sample-secondnodepool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/netcore/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 80
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/openarena/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ spec:
standingBy: 2 # required
max: 4 # required
portsToExpose:
- containerName: thundernetes-sample-openarena # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 27960
template:
spec:
containers:
Expand Down
3 changes: 1 addition & 2 deletions samples/unity/sample.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ spec:
- key: "buildMetadataKey1"
value: "buildMetadataValue1"
portsToExpose:
- containerName: thundernetes-sample-netcore # must be the same as the container name described below
portName: gameport # must be the same as the port name described below
- 7777
template:
spec:
containers:
Expand Down