Skip to content

Commit

Permalink
Merge branch 'master' into grpc
Browse files Browse the repository at this point in the history
  • Loading branch information
markmandel authored Sep 4, 2019
2 parents 61b1e71 + ff2c0fc commit c620106
Show file tree
Hide file tree
Showing 11 changed files with 1,162 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/simple-udp/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ REPOSITORY = gcr.io/agones-images

mkfile_path := $(abspath $(lastword $(MAKEFILE_LIST)))
project_path := $(dir $(mkfile_path))
server_tag = $(REPOSITORY)/udp-server:0.14
server_tag = $(REPOSITORY)/udp-server:0.15
root_path = $(realpath $(project_path)/../..)

# _____ _
Expand Down
15 changes: 13 additions & 2 deletions examples/simple-udp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ func main() {

port := flag.String("port", "7654", "The port to listen to udp traffic on")
passthrough := flag.Bool("passthrough", false, "Get listening port from the SDK, rather than use the 'port' value")
readyOnStart := flag.Bool("ready", true, "Mark this GameServer as Ready on startup")
flag.Parse()
if ep := os.Getenv("PORT"); ep != "" {
port = &ep
Expand All @@ -45,6 +46,10 @@ func main() {
p := strings.ToUpper(epass) == "TRUE"
passthrough = &p
}
if eready := os.Getenv("READY"); eready != "" {
r := strings.ToUpper(eready) == "TRUE"
readyOnStart = &r
}

log.Print("Creating SDK instance")
s, err := sdk.NewSDK()
Expand Down Expand Up @@ -74,8 +79,10 @@ func main() {
}
defer conn.Close() // nolint: errcheck

log.Print("Marking this server as ready")
ready(s)
if *readyOnStart {
log.Print("Marking this server as ready")
ready(s)
}

readWriteLoop(conn, stop, s)
}
Expand Down Expand Up @@ -132,6 +139,10 @@ func readWriteLoop(conn net.PacketConn, stop chan struct{}, s *sdk.SDK) {
continue
}

case "CRASH":
log.Print("Crashing.")
os.Exit(1)

case "ANNOTATION":
switch len(parts) {
case 1:
Expand Down
95 changes: 95 additions & 0 deletions site/content/en/docs/Guides/fleet-updates.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
---
title: "Fleet Updates"
date: 2019-08-27T03:58:19Z
weight: 20
description: >
Common patterns and approaches for updating Fleets with newer and/or different versions of your `GameServer` configuration.
---

## Rolling Update Strategy

When Fleets are edited and updated, the default strategy of Agones is to roll the new version of the `GameServer`
out to the entire `Fleet`, in a step by step increment and decrement by adding a chunk of the new version and removing
a chunk of the current set of `GameServers`.

This is done while ensuring that `Allocated` `GameServers` are not deleted
until they are specifically shutdown through the game servers SDK, as they are expected to have players on them.

You can see this in the `Fleet.Spec.Strategy` [reference]({{< ref "/docs/Reference/fleet.md" >}}), with controls for how
much of the `Fleet` is incremented and decremented at one time:

```yaml
strategy:
type: RollingUpdate
rollingUpdate:
maxSurge: 25%
maxUnavailable: 25%
```
So when a Fleet is edited, either through `kubectl` `edit`/`apply` or via the Kubernetes API, this performs the following operations:

1. Adds the `maxSurge` number of `GameServers` to the Fleet.
1. Shutdown the `maxUnavailable` number of `GameServers` in the Fleet, skipping `Allocated` `GameServers`.
1. Repeat above steps until all the previous `GameServer` configurations have been `Shutdown` and deleted.

## Recreate Strategy

This is an optimal `Fleet` update strategy if you want to replace all `GameServers` that are not `Allocated`
with a new version as quickly as possible.

You can see this in the `Fleet.Spec.Strategy` [reference]({{< ref "/docs/Reference/fleet.md" >}}):

```yaml
strategy:
type: Recreate
```

So when a Fleet is edited, either through `kubectl` `edit`/`apply` or via the Kubernetes API, this performs the following operations:

1. `Shutdown` all `GameServers` in the Fleet that are not currently `Allocated`.
1. Create the same number of the new version of the `GameServers` that were previously deleted.
1. Repeat above steps until all the previous `GameServer` configurations have been `Shutdown` and deleted.

## Two (or more) Fleets Strategy

If you want very fine-grained control over the rate that new versions of a `GameServer` configuration is rolled out, or
if you want to do some version of A/B testing or smoke test between different versions, running two (or more) `Fleets` at the same time is a
good solution for this.

To do this, create a second `Fleet` inside your cluster, starting with zero replicas. From there you can scale this newer `Fleet`
up and the older `Fleet` down as required by your specific rollout strategy.

This also allows you to rollback if issues arise with the newer version, as you can delete the newer `Fleet`
and scale up the old Fleet to its previous levels, resulting in minimal impact to the players.

> For GameServerAllocation, you will need to have at least a single shared label between the `GameServers` in each
> Fleet.

### GameServerAllocation Across Fleets

Since `GameServerAllocation` is powered by label selectors, it is possible to allocate across multiple fleets, and/or
give preference to particular sets of `GameServers` over others. You can see details of this in
the `GameServerAllocation` [reference]({{< ref "/docs/Reference/gameserverallocation.md" >}}).

In a scenario where a new `v2` version of a `Fleet` is being slowly scaled up in a separate Fleet from the previous `v1`
Fleet, we can specify that we `prefer` allocation to occur from the `v2` fleet, and if none are available, fallback to
the `v1` fleet, like so:

```yaml
apiVersion: "allocation.agones.dev/v1"
kind: GameServerAllocation
spec:
required:
matchLabels:
game: my-awesome-game
preferred:
- matchLabels:
agones.dev/fleet: v2
```

In this example, all `GameServers` have the label `game: my-awesome-game`, so the Allocation will search across both
Fleets through that mechanism. The `preferred` label matching selector tells the allocation system to first search
all `GameServers` with the `v2` `Fleet` label, and if not found, search through the rest of the set.

The above `GameServerAllocation` can then be used while you scale up the `v2` Fleet and scale down the original Fleet at
the rate that you deem fit for your specific rollout.
3 changes: 3 additions & 0 deletions site/gen-api-docs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
# See the License for the specific language governing permissions and
# limitations under the License.

export GOPROXY=http://proxy.golang.org
echo "using go proxy as a workaround for git.agache.org being down: $GOPROXY"

cd /go/src/github.com/ahmetb/gen-crd-api-reference-docs

#Use local version of agones
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c620106

Please sign in to comment.