From 210f18eaa9d04d15875521c97eee312faf7c544e Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Fri, 22 Feb 2019 15:04:30 +1100 Subject: [PATCH] Consistency: Portpolicy static=>Static & dynamic=>Dynamic This has been bothering me for a while. Finally fixed it. --- examples/cpp-simple/fleet.yaml | 2 +- examples/cpp-simple/gameserver.yaml | 2 +- examples/fleet.yaml | 2 +- examples/gameserver.yaml | 8 ++-- examples/rust-simple/gameserver.yaml | 1 - examples/simple-udp/dev-gameserver.yaml | 2 +- examples/simple-udp/gameserver.yaml | 2 +- examples/simple-udp/gameserverset.yaml | 2 +- examples/xonotic/fleet.yaml | 1 - examples/xonotic/gameserver.yaml | 1 - .../crds/_gameserverspecvalidation.yaml | 10 ++--- install/yaml/install.yaml | 30 +++++++-------- pkg/apis/stable/v1alpha1/gameserver.go | 4 +- .../en/docs/Advanced/limiting-resources.md | 1 - .../en/docs/Getting Started/create-fleet.md | 4 +- .../docs/Getting Started/create-gameserver.md | 2 +- site/content/en/docs/Guides/access-api.md | 4 +- .../en/docs/Guides/local-game-server.md | 28 +++++++++++++- site/content/en/docs/Reference/fleet.md | 38 +++++++++++++++++++ site/content/en/docs/Reference/gameserver.md | 35 ++++++++++++++++- 20 files changed, 136 insertions(+), 43 deletions(-) diff --git a/examples/cpp-simple/fleet.yaml b/examples/cpp-simple/fleet.yaml index d60138b883..59b02ca767 100644 --- a/examples/cpp-simple/fleet.yaml +++ b/examples/cpp-simple/fleet.yaml @@ -24,7 +24,7 @@ spec: spec: ports: - name: default - portPolicy: "dynamic" + portPolicy: Dynamic containerPort: 7654 template: spec: diff --git a/examples/cpp-simple/gameserver.yaml b/examples/cpp-simple/gameserver.yaml index 04793f6190..996d436979 100644 --- a/examples/cpp-simple/gameserver.yaml +++ b/examples/cpp-simple/gameserver.yaml @@ -21,7 +21,7 @@ metadata: spec: ports: - name: default - portPolicy: "dynamic" + portPolicy: Dynamic containerPort: 7654 template: spec: diff --git a/examples/fleet.yaml b/examples/fleet.yaml index 9e0e03622a..184b8ab749 100644 --- a/examples/fleet.yaml +++ b/examples/fleet.yaml @@ -57,7 +57,7 @@ spec: spec: ports: - name: default - portPolicy: "dynamic" + portPolicy: Dynamic containerPort: 26000 health: initialDelaySeconds: 30 diff --git a/examples/gameserver.yaml b/examples/gameserver.yaml index 33cdba38eb..1b4c1aecc3 100644 --- a/examples/gameserver.yaml +++ b/examples/gameserver.yaml @@ -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 diff --git a/examples/rust-simple/gameserver.yaml b/examples/rust-simple/gameserver.yaml index 33fecec394..637aa60f38 100644 --- a/examples/rust-simple/gameserver.yaml +++ b/examples/rust-simple/gameserver.yaml @@ -21,7 +21,6 @@ metadata: spec: ports: - name: default - portPolicy: "dynamic" containerPort: 7654 template: spec: diff --git a/examples/simple-udp/dev-gameserver.yaml b/examples/simple-udp/dev-gameserver.yaml index 97d22d83b5..179af70300 100644 --- a/examples/simple-udp/dev-gameserver.yaml +++ b/examples/simple-udp/dev-gameserver.yaml @@ -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. diff --git a/examples/simple-udp/gameserver.yaml b/examples/simple-udp/gameserver.yaml index b10e7f5463..af3a9a04e6 100644 --- a/examples/simple-udp/gameserver.yaml +++ b/examples/simple-udp/gameserver.yaml @@ -19,7 +19,7 @@ metadata: spec: ports: - name: default - portPolicy: "dynamic" + portPolicy: Dynamic containerPort: 7654 template: spec: diff --git a/examples/simple-udp/gameserverset.yaml b/examples/simple-udp/gameserverset.yaml index c3609dc244..26c754f210 100644 --- a/examples/simple-udp/gameserverset.yaml +++ b/examples/simple-udp/gameserverset.yaml @@ -25,7 +25,7 @@ spec: spec: ports: - name: default - portPolicy: "dynamic" + portPolicy: Dynamic containerPort: 7654 template: spec: diff --git a/examples/xonotic/fleet.yaml b/examples/xonotic/fleet.yaml index f04fce9a4c..755cbbc3a0 100644 --- a/examples/xonotic/fleet.yaml +++ b/examples/xonotic/fleet.yaml @@ -27,7 +27,6 @@ spec: spec: ports: - name: default - portPolicy: "dynamic" containerPort: 26000 health: initialDelaySeconds: 30 diff --git a/examples/xonotic/gameserver.yaml b/examples/xonotic/gameserver.yaml index 07fb2dc60e..6400e4d0a7 100644 --- a/examples/xonotic/gameserver.yaml +++ b/examples/xonotic/gameserver.yaml @@ -19,7 +19,6 @@ metadata: spec: ports: - name: default - portPolicy: "dynamic" containerPort: 26000 template: spec: diff --git a/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml b/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml index 75135d8a50..104d490255 100644 --- a/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml +++ b/install/helm/agones/templates/crds/_gameserverspecvalidation.yaml @@ -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 @@ -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 diff --git a/install/yaml/install.yaml b/install/yaml/install.yaml index 3af2eaa170..bfa5ed0912 100644 --- a/install/yaml/install.yaml +++ b/install/yaml/install.yaml @@ -276,13 +276,13 @@ spec: 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 @@ -296,7 +296,7 @@ spec: 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 @@ -590,13 +590,13 @@ spec: 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 @@ -610,7 +610,7 @@ spec: 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 @@ -884,13 +884,13 @@ spec: 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 @@ -904,7 +904,7 @@ spec: 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 diff --git a/pkg/apis/stable/v1alpha1/gameserver.go b/pkg/apis/stable/v1alpha1/gameserver.go index 5a33cb4278..2ccfa33750 100644 --- a/pkg/apis/stable/v1alpha1/gameserver.go +++ b/pkg/apis/stable/v1alpha1/gameserver.go @@ -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" diff --git a/site/content/en/docs/Advanced/limiting-resources.md b/site/content/en/docs/Advanced/limiting-resources.md index d7eb58d943..de47c7ded1 100644 --- a/site/content/en/docs/Advanced/limiting-resources.md +++ b/site/content/en/docs/Advanced/limiting-resources.md @@ -33,7 +33,6 @@ metadata: spec: ports: - name: default - portPolicy: "dynamic" containerPort: 7654 template: spec: diff --git a/site/content/en/docs/Getting Started/create-fleet.md b/site/content/en/docs/Getting Started/create-fleet.md index 675580abf2..a9ac484172 100644 --- a/site/content/en/docs/Getting Started/create-fleet.md +++ b/site/content/en/docs/Getting Started/create-fleet.md @@ -105,7 +105,7 @@ Spec: Ports: Container Port: 7654 Name: default - Port Policy: dynamic + Port Policy: Dynamic Template: Metadata: Creation Timestamp: @@ -305,7 +305,7 @@ status: - containerPort: 7654 hostPort: 7604 name: default - portPolicy: dynamic + portPolicy: Dynamic protocol: UDP template: metadata: diff --git a/site/content/en/docs/Getting Started/create-gameserver.md b/site/content/en/docs/Getting Started/create-gameserver.md index 43e9d13199..ab68ce216f 100644 --- a/site/content/en/docs/Getting Started/create-gameserver.md +++ b/site/content/en/docs/Getting Started/create-gameserver.md @@ -100,7 +100,7 @@ Spec: Container Port: 7654 Host Port: 7614 Name: default - Port Policy: dynamic + Port Policy: Dynamic Protocol: UDP Template: Metadata: diff --git a/site/content/en/docs/Guides/access-api.md b/site/content/en/docs/Guides/access-api.md index b327900f9b..7d370794eb 100644 --- a/site/content/en/docs/Guides/access-api.md +++ b/site/content/en/docs/Guides/access-api.md @@ -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": { @@ -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" } ], diff --git a/site/content/en/docs/Guides/local-game-server.md b/site/content/en/docs/Guides/local-game-server.md index 19ba01aca7..e172f7e875 100644 --- a/site/content/en/docs/Guides/local-game-server.md +++ b/site/content/en/docs/Guides/local-game-server.md @@ -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 @@ -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` diff --git a/site/content/en/docs/Reference/fleet.md b/site/content/en/docs/Reference/fleet.md index 9965822ae6..2803b4d879 100644 --- a/site/content/en/docs/Reference/fleet.md +++ b/site/content/en/docs/Reference/fleet.md @@ -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 @@ -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/) diff --git a/site/content/en/docs/Reference/gameserver.md b/site/content/en/docs/Reference/gameserver.md index d41105f49b..614b5dedd6 100644 --- a/site/content/en/docs/Reference/gameserver.md +++ b/site/content/en/docs/Reference/gameserver.md @@ -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 @@ -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`. @@ -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" >}}).