Skip to content

Commit

Permalink
Consistency: Portpolicy static=>Static & dynamic=>Dynamic
Browse files Browse the repository at this point in the history
This has been bothering me for a while. Finally fixed it.
  • Loading branch information
markmandel committed Feb 22, 2019
1 parent 861771b commit fa22b3c
Show file tree
Hide file tree
Showing 19 changed files with 121 additions and 28 deletions.
2 changes: 1 addition & 1 deletion examples/cpp-simple/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ spec:
spec:
ports:
- name: default
portPolicy: "dynamic"
portPolicy: Dynamic
containerPort: 7654
template:
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/cpp-simple/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ metadata:
spec:
ports:
- name: default
portPolicy: "dynamic"
portPolicy: Dynamic
containerPort: 7654
template:
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ spec:
spec:
ports:
- name: default
portPolicy: "dynamic"
portPolicy: Dynamic
containerPort: 26000
health:
initialDelaySeconds: 30
Expand Down
8 changes: 4 additions & 4 deletions examples/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ spec:
# name is a descriptive name for the port
- name: default
# portPolicy has two options:
# - "dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
# - "static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
# - "Dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
# - "Static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
# port is available. When static is the policy specified, `hostPort` is required to be populated
portPolicy: "static"
portPolicy: Dynamic
# the port that is being opened on the game server process
containerPort: 7654
# the port exposed on the host, only required when `portPolicy` is "static". Overwritten when portPolicy is "dynamic".
# the port exposed on the host, only required when `portPolicy` is "Static". Overwritten when portPolicy is "Dynamic".
hostPort: 7777
# protocol being used. Defaults to UDP. TCP is the only other option
protocol: UDP
Expand Down
1 change: 0 additions & 1 deletion examples/rust-simple/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ metadata:
spec:
ports:
- name: default
portPolicy: "dynamic"
containerPort: 7654
template:
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/dev-gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ metadata:
spec:
ports:
- name: default
portPolicy: "static"
portPolicy: Static
hostPort: 17654
containerPort: 17654
# The following is ignored but required due to validation.
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ metadata:
spec:
ports:
- name: default
portPolicy: "dynamic"
portPolicy: Dynamic
containerPort: 7654
template:
spec:
Expand Down
2 changes: 1 addition & 1 deletion examples/simple-udp/gameserverset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ spec:
spec:
ports:
- name: default
portPolicy: "dynamic"
portPolicy: Dynamic
containerPort: 7654
template:
spec:
Expand Down
1 change: 0 additions & 1 deletion examples/xonotic/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ spec:
spec:
ports:
- name: default
portPolicy: "dynamic"
containerPort: 26000
health:
initialDelaySeconds: 30
Expand Down
1 change: 0 additions & 1 deletion examples/xonotic/gameserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ metadata:
spec:
ports:
- name: default
portPolicy: "dynamic"
containerPort: 26000
template:
spec:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ properties:
title: the port policy that will be applied to the game server
description: |
portPolicy has two options:
- "dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
- "static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
- "Dynamic" (default) the system allocates a free hostPort for the gameserver, for game clients to connect to
- "Static", user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the
port is available. When static is the policy specified, `hostPort` is required to be populated
type: string
enum:
- dynamic
- static
- Dynamic
- Static
protocol:
title: Protocol being used. Defaults to UDP. TCP is the only other option
type: string
Expand All @@ -87,7 +87,7 @@ properties:
maximum: 65535
hostPort:
title: The port exposed on the host
description: Only required when `portPolicy` is "static". Overwritten when portPolicy is "dynamic".
description: Only required when `portPolicy` is "Static". Overwritten when portPolicy is "dynamic".
type: integer
minimum: 1
maximum: 65535
Expand Down
4 changes: 2 additions & 2 deletions pkg/apis/stable/v1alpha1/gameserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,10 @@ const (

// Static PortPolicy means that the user defines the hostPort to be used
// in the configuration.
Static PortPolicy = "static"
Static PortPolicy = "Static"
// Dynamic PortPolicy means that the system will choose an open
// port for the GameServer in question
Dynamic PortPolicy = "dynamic"
Dynamic PortPolicy = "Dynamic"

// RoleLabel is the label in which the Agones role is specified.
// Pods from a GameServer will have the value "gameserver"
Expand Down
1 change: 0 additions & 1 deletion site/content/en/docs/Advanced/limiting-resources.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ metadata:
spec:
ports:
- name: default
portPolicy: "dynamic"
containerPort: 7654
template:
spec:
Expand Down
4 changes: 2 additions & 2 deletions site/content/en/docs/Getting Started/create-fleet.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ Spec:
Ports:
Container Port: 7654
Name: default
Port Policy: dynamic
Port Policy: Dynamic
Template:
Metadata:
Creation Timestamp: <nil>
Expand Down Expand Up @@ -305,7 +305,7 @@ status:
- containerPort: 7654
hostPort: 7604
name: default
portPolicy: dynamic
portPolicy: Dynamic
protocol: UDP
template:
metadata:
Expand Down
2 changes: 1 addition & 1 deletion site/content/en/docs/Getting Started/create-gameserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Spec:
Container Port: 7654
Host Port: 7614
Name: default
Port Policy: dynamic
Port Policy: Dynamic
Protocol: UDP
Template:
Metadata:
Expand Down
4 changes: 2 additions & 2 deletions site/content/en/docs/Guides/access-api.md
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ $ curl http://localhost:8001/apis/stable.agones.dev/v1alpha1/namespaces/default/
"uid": "692beea6-1e62-11e8-beb2-080027637781"
},
"spec": {
"PortPolicy": "static",
"PortPolicy": "Static",
"container": "simple-udp",
"containerPort": 7654,
"health": {
Expand Down Expand Up @@ -305,7 +305,7 @@ $ curl -d '{"apiVersion":"stable.agones.dev/v1alpha1","kind":"FleetAllocation","
"containerPort": 7654,
"hostPort": 7968,
"name": "default",
"portPolicy": "dynamic",
"portPolicy": "Dynamic",
"protocol": "UDP"
}
],
Expand Down
28 changes: 27 additions & 1 deletion site/content/en/docs/Guides/local-game-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ You can register a local game server with Agones. This means you can run an expe

To register your local game server you'll need to know the IP address of the machine running it and the port. With that you'll create a game server config like the one below.

{{% feature expiryVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: GameServer
Expand All @@ -34,12 +35,37 @@ spec:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.5
```
{{% /feature %}}
{{% feature publishVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: GameServer
metadata:
name: my-local-server
annotations:
# Causes Agones to register your local game server at 192.1.1.2, replace with your server's IP address.
stable.agones.dev/dev-address: "192.1.1.2"
spec:
ports:
- name: default
portPolicy: Static
hostPort: 17654
containerPort: 17654
# The following is ignored but required due to validation.
template:
spec:
containers:
- name: simple-udp
image: gcr.io/agones-images/udp-server:0.5
```
{{% /feature %}}
Once you save this to a file make sure you have `kubectl` configured to point to your Agones cluster and then run `kubectl apply -f dev-gameserver.yaml`. This will register your server with Agones.

Local Game Servers has a few limitations:

* PortPolicy must be static.
* PortPolicy must be {{% feature expiryVersion="0.9.0" %}}`static`{{% /feature %}}{{% feature publishVersion="0.9.0" %}}`Static`{{% /feature %}}.
* The game server is not managed by Agones. Features like autoscaling, replication, etc are not available.

When you are finished working with your server, you can remove the registration with `kubectl delete -f dev-gameserver.yaml`
38 changes: 38 additions & 0 deletions site/content/en/docs/Reference/fleet.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ Like any other Kubernetes resource you describe a `Fleet`'s desired state via a

A full `Fleet` specification is available below and in the {{< ghlink href="examples/fleet.yaml" >}}example folder{{< /ghlink >}} for reference :


{{% feature expiryVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: Fleet
Expand Down Expand Up @@ -43,6 +45,42 @@ spec:
- name: example-server
image: gcr.io/agones/test-server:0.1
```
{{% /feature %}}
{{% feature publishVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: Fleet
metadata:
name: fleet-example
spec:
replicas: 2
scheduling: Packed
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
template:
metadata:
labels:
foo: bar
spec:
ports:
- name: default
portPolicy: Dynamic
containerPort: 26000
health:
initialDelaySeconds: 30
periodSeconds: 60
template:
spec:
containers:
- name: example-server
image: gcr.io/agones/test-server:0.1
```
{{% /feature %}}
Since Agones defines a new
[Custom Resources Definition (CRD)](https://kubernetes.io/docs/concepts/api-extension/custom-resources/)
Expand Down
35 changes: 34 additions & 1 deletion site/content/en/docs/Reference/gameserver.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ description: >

A full GameServer specification is available below and in the {{< ghlink href="examples/gameserver.yaml" >}}example folder{{< /ghlink >}} for reference :

{{% feature expiryVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: GameServer
Expand Down Expand Up @@ -36,6 +37,37 @@ spec:
image: gcr.io/agones/test-server:0.1
imagePullPolicy: Always
```
{{% /feature %}}
{{% feature publishVersion="0.9.0" %}}
```yaml
apiVersion: "stable.agones.dev/v1alpha1"
kind: GameServer
metadata:
name: "gds-example"
spec:
ports:
- name: default
portPolicy: Static
containerPort: 7654
hostPort: 7777
protocol: UDP
health:
disabled: false
initialDelaySeconds: 5
periodSeconds: 5
failureThreshold: 3
template:
metadata:
labels:
myspeciallabel: myspecialvalue
spec:
containers:
- name: example-server
image: gcr.io/agones/test-server:0.1
imagePullPolicy: Always
```
{{% /feature %}}
Since Agones defines a new [Custom Resources Definition (CRD)](https://kubernetes.io/docs/concepts/api-extension/custom-resources/) we can define a new resource using the kind `GameServer` with the custom group `stable.agones.dev` and API version `v1alpha1`.

Expand All @@ -47,7 +79,8 @@ The `spec` field is the actual GameServer specification and it is composed as fo
- `container` is the name of container running the GameServer in case you have more than one container defined in the [pod](https://kubernetes.io/docs/concepts/workloads/pods/pod-overview/). If you do, this is a mandatory field. For instance this is useful if you want to run a sidecar to ship logs.
- `ports` are an array of ports that can be exposed as direct connections to the game server container
- `name` is an optional descriptive name for a port
- `portPolicy` has two options `dynamic` (default) the system allocates a free hostPort for the gameserver, for game clients to connect to. And `static`, user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the port is available. When static is the policy specified, `hostPort` is required to be populated.
- `portPolicy` has two options {{% feature expiryVersion="0.9.0" %}}`dynamic`{{% /feature %}}{{% feature publishVersion="0.9.0" %}}`Dynamic`{{% /feature %}} (default) the system allocates a free hostPort for the gameserver, for game clients to connect to.
And {{% feature expiryVersion="0.9.0" %}}`static`{{% /feature %}}{{% feature publishVersion="0.9.0" %}}`Static`{{% /feature %}}, user defines the hostPort that the game client will connect to. Then onus is on the user to ensure that the port is available. When static is the policy specified, `hostPort` is required to be populated.
- `containerPort` the port that is being opened on the game server process, this is a required field.
- `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]({{< relref "../Guides/health-checking.md" >}}).
Expand Down

0 comments on commit fa22b3c

Please sign in to comment.