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

CountersAndLists in Reference Documentation #3529

Closed
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
9 changes: 9 additions & 0 deletions site/content/en/docs/Reference/fleet.md
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,15 @@ spec:
version: "" # empty an existing label value
annotations:
otherkey: setthisvalue
#
# [Stage:Alpha]
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# [FeatureFlag:CountsAndLists]
# Which gameservers in the Fleet are most important to keep around - impacts scale down logic.
# priorities:
# - type: List # Whether a Counter or a List.
# key: rooms # The name of the Counter or List.
# order: Ascending # Default is "Ascending" so smaller capacity will be removed first on down scaling.
#
template:
# GameServer metadata
metadata:
Expand Down
59 changes: 59 additions & 0 deletions site/content/en/docs/Reference/fleetautoscaler.md
markmandel marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,65 @@ spec:
seconds: 30
```

{{% feature publishVersion="1.37.0" %}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In terms of ordering the page, the Counters and Lists examples should probably go after the webhook autoscaling example since they're still in Alpha.

Counter-based `FleetAutoscaler` specification below and in the {{< ghlink href="examples/counterfleetautoscaler.yaml" >}}example folder{{< /ghlink >}}:

```yaml
markmandel marked this conversation as resolved.
Show resolved Hide resolved
apiVersion: autoscaling.agones.dev/v1
kind: FleetAutoscaler
metadata:
name: fleet-autoscaler-counter
spec:
fleetName: fleet-example
policy:
type: Counter # Counter based autoscaling
counter:
# The name of the Counter.
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# Required.
key: players
# Size of a buffer of counted items that are available in the Fleet (available capacity).
# bufferSize can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%).
# Required.
bufferSize: 5
# Minimum aggregate counter capacity that can be provided by this FleetAutoscaler.
# If minCapacity is not specified, the effective minimum capacity will be bufferSize.
# When bufferSize in percentage format is used, minCapacity should be set and more than 0.
minCapacity: 10
# Maximum aggregate counter capacity that can be provided by this FleetAutoscaler.
# Required.
maxCapacity: 100
```

List-based `FleetAutoscaler` specification below and in the {{< ghlink href="examples/listfleetautoscaler.yaml" >}}example folder{{< /ghlink >}}:

```yaml
apiVersion: autoscaling.agones.dev/v1
kind: FleetAutoscaler
metadata:
name: fleet-autoscaler-list
spec:
fleetName: fleet-example
policy:
type: List # List based autoscaling.
list:
# The name of the List.
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# Required.
key: rooms
# Size of a buffer based on the list capacity that is available over the current aggregate
# list length in the Fleet (available capacity).
# bufferSize can be specified either in absolute (i.e. 5) or percentage format (i.e. 5%)
# Required.
bufferSize: 5
# Minimum aggregate list capacity that can be provided by this FleetAutoscaler.
# If minCapacity is not specified, the effective minimum capacity will be bufferSize.
# When bufferSize in percentage format is used, minCapacity should be set and more than 0.
minCapacity: 10
# Maximum aggregate list capacity that can be provided by this FleetAutoscaler.
# Required.
maxCapacity: 100
```
{{% /feature %}}

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as you did in fleet.md - need the fields desribed in the section from 144 onwards.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same doubt, the fields in the counter and list for the autoscaling to be included in the spec field?

Or for Webhook FleetAutoscaler below and in {{< ghlink href="examples/webhookfleetautoscaler.yaml" >}}example folder{{< /ghlink >}}:

```yaml
Expand Down
112 changes: 112 additions & 0 deletions site/content/en/docs/Reference/gameserver.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar comment to what Mark mentioned in fleet.md. Mention Counters and Lists in the bullet point notes below the examples

- `players` (Alpha, behind "PlayerTracking" feature gate), sets this GameServer's initial player capacity

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="1.37.0" %}}
```yaml
apiVersion: "agones.dev/v1"
kind: GameServer
Expand Down Expand Up @@ -96,7 +97,118 @@ spec:
# nodeSelector:
# kubernetes.io/os: windows
```
{{% /feature %}}

{{% feature publishVersion="1.37.0" %}}
```yaml
apiVersion: "agones.dev/v1"
kind: GameServer
# GameServer Metadata
# {{< k8s-api-version href="#objectmeta-v1-meta" >}}
metadata:
# generateName: "gds-example" # generate a unique name, with the given prefix
name: "gds-example" # set a fixed name
spec:
# if there is more than one container, specify which one is the game server
container: example-server
# Array of ports that can be exposed as direct connections to the game server container
ports:
# name is a descriptive name for the port
- name: default
# portPolicy has three 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
# port is available. When static is the policy specified, `hostPort` is required to be populated
# - "Passthrough" dynamically sets the `containerPort` to the same value as the dynamically selected hostPort.
# This will mean that users will need to lookup what port has been opened through the server side SDK.
portPolicy: Static
# The name of the container to open the port on. Defaults to the game server container if omitted or empty.
container: simple-game-server
# 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".
hostPort: 7777
# protocol being used. Defaults to UDP. TCP and TCPUDP are other options
# - "UDP" (default) use the UDP protocol
# - "TCP", use the TCP protocol
# - "TCPUDP", uses both TCP and UDP, and exposes the same hostPort for both protocols.
# This will mean that it adds an extra port, and the first port is set to TCP, and second port set to UDP
protocol: UDP
# Health checking for the running game server
health:
# Disable health checking. defaults to false, but can be set to true
disabled: false
# Number of seconds after the container has started before health check is initiated. Defaults to 5 seconds
initialDelaySeconds: 5
# If the `Health()` function doesn't get called at least once every period (seconds), then
# the game server is not healthy. Defaults to 5
periodSeconds: 5
# Minimum consecutive failures for the health probe to be considered failed after having succeeded.
# Defaults to 3. Minimum value is 1
failureThreshold: 3
# Parameters for game server sidecar
sdkServer:
# sdkServer log level parameter has three options:
# - "Info" (default) The SDK server will output all messages except for debug messages
# - "Debug" The SDK server will output all messages including debug messages
# - "Error" The SDK server will only output error messages
logLevel: Info
# grpcPort and httpPort control what ports the sdkserver listens on.
# Starting with Agones 1.2 the default grpcPort is 9357 and the default
# httpPort is 9358. In earlier releases, the defaults were 59357 and 59358
# respectively but as these were in the ephemeral port range they could
# conflict with other TCP connections.
grpcPort: 9357
httpPort: 9358
# [Stage:Alpha]
# [FeatureFlag:PlayerTracking]
# Players provides the configuration for player tracking features.
# Commented out since Alpha, and disabled by default
# players:
# # set this GameServer's initial player capacity
# initialCapacity: 10
#
# [Stage:Alpha]
# [FeatureFlag:CountsAndLists]
# Counts and Lists provides the configuration for generic (player, room, session, etc.) tracking features.
# Commented out since Alpha, and disabled by default
# counters:
# games:
# count: 1
# capacity: 100
# sessions:
# count: # Count and/or capacity must be listed (but may be nil) otherwise the counter will by dropped by the CRD schema.
markmandel marked this conversation as resolved.
Show resolved Hide resolved
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# lists:
# players:
# capacity: # Capacity and/or values must be listed (but may be nil) otherwise the list will be dropped by the CRD schema.
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# rooms:
# capacity: 333
# values:
# - room1
# - room2
# - room3
markmandel marked this conversation as resolved.
Show resolved Hide resolved
#
# Pod template configuration
# {{< k8s-api-version href="#podtemplate-v1-core" >}}
template:
# pod metadata. Name & Namespace is overwritten
metadata:
labels:
myspeciallabel: myspecialvalue
# Pod Specification
spec:
containers:
- name: simple-game-server
image: {{< example-image >}}
imagePullPolicy: Always
# nodeSelector is a label that can be used to tell Kubernetes which host
# OS to use. For Windows game servers uncomment the nodeSelector
# definition below.
# Details: https://kubernetes.io/docs/setup/production-environment/windows/user-guide-windows-containers/#ensuring-os-specific-workloads-land-on-the-appropriate-container-host
# nodeSelector:
# kubernetes.io/os: windows
```
{{% /feature %}}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as the markdown files - need each of the fields described below please (line 219 onwards)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you intended for the counters and lists fields to be included within the spec field?

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 `agones.dev` and API version `v1`.

You can use the metadata field to target a specific [namespaces](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/)
Expand Down
124 changes: 124 additions & 0 deletions site/content/en/docs/Reference/gameserverallocation.md
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add below suggested code after (and inline with) "metadata".

  # [Stage:Alpha]
  # [FeatureFlag:CountsAndLists]
  # The first Priority on the array of Priorities is the most important for sorting. The allocator will
  # use the first priority for sorting GameServers by available Capacity in the Selector set. Acts as a
  # tie-breaker after sorting the game servers by State and Strategy Packed. Impacts which GameServer
  # is checked first. Optional.
  # priorities:
  # - type: List  # Whether a Counter or a List.
  #   key: rooms  # The name of the Counter or List.
  #   order: Ascending  # "Ascending" lists smaller available capacity first.
  # [Stage:Alpha]
  # [FeatureFlag:CountsAndLists]
  # Counter actions to perform during allocation. Optional.
  # counters:
  #   rooms:
  #     action: increment # Either "Increment" or "Decrement" the Counter’s Count.
  #     amount: 1 # Amount is the amount to increment or decrement the Count. Must be a positive integer.
  #     capacity: 5 # Amount to update the maximum capacity of the Counter to this number. Min 0, Max int64.
  # List actions to perform during allocation. Optional.
  # lists:
  #   players:
  #     addValues: # appends values to a List’s Values array. Any duplicate values will be ignored
  #       - x7un
  #       - 8inz
  #     capacity: 40 # Updates the maximum capacity of the Counter to this number. Min 0, Max 1000.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Under "selectors is an ordered list of..." add:

  - `matchLabels` is a map of {key,value} pairs. A single {key,value} in the matchLabels map is equivalent to an element
    of matchExpressions, whose key field is "key", the operator is "In", and the values array contains only "value".
    The requirements are ANDed. Optional.
  - `matchExpressions` is a list of label selector requirements. The requirements are ANDed. Optional.
  - `gameServerState` GameServerState specifies which State is the filter to be used when attempting to retrieve a
    GameServer via Allocation. Defaults to "Ready". The only other option is "Allocated", which can be used in
    conjunction with label/annotation/player selectors to retrieve an already Allocated GameServer.
  - `counters` (Alpha, "CountsAndLists" feature flag) enables filtering based on game server Counter status, such as
    the minimum and maximum number of active rooms. This helps in selecting game servers based on their current activity
    or capacity. Optional.
  - `lists` (Alpha, "CountsAndLists" feature flag) enables filtering based on game server List status, such as allowing
    for inclusion or exclusion of specific players. Optional.

Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,121 @@ weight: 30
A full `GameServerAllocation` specification is available below and in the
{{< ghlink href="/examples/gameserverallocation.yaml" >}}example folder{{< /ghlink >}} for reference:

{{% feature expiryVersion="1.37.0" %}}
{{< tabpane >}}
{{< tab header="selectors" lang="yaml" >}}
apiVersion: "allocation.agones.dev/v1"
kind: GameServerAllocation
spec:
# GameServer selector from which to choose GameServers from.
# Defaults to all GameServers.
# matchLabels, matchExpressions, gameServerState and player filters can be used for filtering.
# See: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more details on label selectors.
# An ordered list of GameServer label selectors.
# If the first selector is not matched, the selection attempts the second selector, and so on.
# This is useful for things like smoke testing of new game servers.
selectors:
- matchLabels:
agones.dev/fleet: green-fleet
# [Stage:Alpha]
# [FeatureFlag:PlayerAllocationFilter]
players:
minAvailable: 0
maxAvailable: 99
- matchLabels:
agones.dev/fleet: blue-fleet
- matchLabels:
game: my-game
matchExpressions:
- {key: tier, operator: In, values: [cache]}
# Specifies which State is the filter to be used when attempting to retrieve a GameServer
# via Allocation. Defaults to "Ready". The only other option is "Allocated", which can be used in conjunction with
# label/annotation/player selectors to retrieve an already Allocated GameServer.
gameServerState: Ready
# [Stage:Alpha]
# [FeatureFlag:PlayerAllocationFilter]
# Provides a filter on minimum and maximum values for player capacity when retrieving a GameServer
# through Allocation. Defaults to no limits.
players:
minAvailable: 0
maxAvailable: 99
# defines how GameServers are organised across the cluster.
# Options include:
# "Packed" (default) is aimed at dynamic Kubernetes clusters, such as cloud providers, wherein we want to bin pack
# resources
# "Distributed" is aimed at static Kubernetes clusters, wherein we want to distribute resources across the entire
# cluster
scheduling: Packed
# Optional custom metadata that is added to the game server at allocation
# You can use this to tell the server necessary session data
metadata:
labels:
mode: deathmatch
annotations:
map: garden22
{{< /tab >}}
{{< tab header="required & preferred (deprecated)" lang="yaml" >}}
apiVersion: "allocation.agones.dev/v1"
kind: GameServerAllocation
spec:
# Deprecated, use field selectors instead.
# GameServer selector from which to choose GameServers from.
# Defaults to all GameServers.
# matchLabels, matchExpressions, gameServerState and player filters can be used for filtering.
# See: https://kubernetes.io/docs/concepts/overview/working-with-objects/labels/ for more details on label selectors.
# Deprecated, use field selectors instead.
required:
matchLabels:
game: my-game
matchExpressions:
- {key: tier, operator: In, values: [cache]}
# Specifies which State is the filter to be used when attempting to retrieve a GameServer
# via Allocation. Defaults to "Ready". The only other option is "Allocated", which can be used in conjunction with
# label/annotation/player selectors to retrieve an already Allocated GameServer.
gameServerState: Ready
# [Stage:Alpha]
# [FeatureFlag:PlayerAllocationFilter]
# Provides a filter on minimum and maximum values for player capacity when retrieving a GameServer
# through Allocation. Defaults to no limits.
players:
minAvailable: 0
maxAvailable: 99
# Deprecated, use field selectors instead.
# An ordered list of preferred GameServer label selectors
# that are optional to be fulfilled, but will be searched before the `required` selector.
# If the first selector is not matched, the selection attempts the second selector, and so on.
# If any of the preferred selectors are matched, the required selector is not considered.
# This is useful for things like smoke testing of new game servers.
# This also support matchExpressions, gameServerState and player filters.
preferred:
- matchLabels:
agones.dev/fleet: green-fleet
# [Stage:Alpha]
# [FeatureFlag:PlayerAllocationFilter]
players:
minAvailable: 0
maxAvailable: 99
- matchLabels:
agones.dev/fleet: blue-fleet
# defines how GameServers are organised across the cluster.
# Options include:
# "Packed" (default) is aimed at dynamic Kubernetes clusters, such as cloud providers, wherein we want to bin pack
# resources
# "Distributed" is aimed at static Kubernetes clusters, wherein we want to distribute resources across the entire
# cluster
scheduling: Packed
# Optional custom metadata that is added to the game server at allocation
# You can use this to tell the server necessary session data
metadata:
labels:
mode: deathmatch
annotations:
map: garden22
{{< /tab >}}
{{< /tabpane >}}
{{% /feature %}}

{{% feature publishVersion="1.37.0" %}}
{{< tabpane >}}
{{< tab header="selectors" lang="yaml" >}}
apiVersion: "allocation.agones.dev/v1"
Expand Down Expand Up @@ -41,6 +156,14 @@ spec:
# label/annotation/player selectors to retrieve an already Allocated GameServer.
gameServerState: Ready
# [Stage:Alpha]
# [FeatureFlag:CountsAndLists]
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# Counts and Lists provides the configuration for generic (player, room, session, etc.) tracking features.
# Commented out since Alpha, and disabled by default
# counters:
# players:
# minAvailable: 1
# maxAvailable: 10
markmandel marked this conversation as resolved.
Show resolved Hide resolved
# [Stage:Alpha]
# [FeatureFlag:PlayerAllocationFilter]
# Provides a filter on minimum and maximum values for player capacity when retrieving a GameServer
# through Allocation. Defaults to no limits.
Expand Down Expand Up @@ -121,6 +244,7 @@ spec:
map: garden22
{{< /tab >}}
{{< /tabpane >}}
{{% /feature %}}

The `spec` field is the actual `GameServerAllocation` specification, and it is composed as follows:

Expand Down