Skip to content

Commit

Permalink
Deploy Dedicated Server to Global Pipeline (#130)
Browse files Browse the repository at this point in the history
Takes the dedicated game server image and applies it to the Agones
deploy pipeline for staged regional rollouts!

Also renamed `global-game-servers` to `global-game-agones-gameservers`
since it was easy to mix up `global-game-servers` with
`global-game-services`.

Snuck in a `depends_on` fix as well.

Closes #44
  • Loading branch information
markmandel authored Mar 9, 2023
1 parent ecb4b55 commit 08ad9bf
Show file tree
Hide file tree
Showing 6 changed files with 75 additions and 11 deletions.
34 changes: 26 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,15 @@ cd $GAME_DEMO_HOME/platform/
gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1
```

Navigate to the [agones-deploy-pipeline](https://console.cloud.google.
com/deploy/delivery-pipelines/us-central1/agones-deploy-pipeline) delivery pipeline to review the rollout status.
Cloud Build will create a Cloud Deploy release which automatically deploys Agones the first game server cluster. Agones can be deployed to subsequent clusters by clicking on the `promote` button within the Pipeline visualization or by running the following gcloud command:
Navigate to the
[agones-deploy-pipeline](https://console.cloud.google.com/deploy/delivery-pipelines/us-central1/agones-deploy-pipeline)
delivery pipeline to review the rollout status. Cloud Build will create a Cloud Deploy release which automatically
deploys Agones the first game server cluster. Agones can be deployed to subsequent clusters by clicking on the
`promote` button within the Pipeline visualization or by running the following gcloud command:

```shell
# Replace RELEASE_NAME with the unique build name
gcloud deploy releases promote --release=RELEASE_NAME --delivery-pipeline=agones-deploy-pipeline --region=us-central1`
gcloud deploy releases promote --release=RELEASE_NAME --delivery-pipeline=agones-deploy-pipeline --region=us-central1
```

Continue the promotion until Agones has been deployed to all clusters. You can monitor the status of the deployment
Expand All @@ -168,17 +170,33 @@ This will:

## Dedicated Game Server

To build the Unreal dedicated game server image, run the following command:
To build the Unreal dedicated game server image, run the following command, and replace the` _RELEASE_NAME`
substitution with a unique build name.

```shell
cd $GAME_DEMO_HOME/game
gcloud builds submit --config=cloudbuild.yaml
gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1
```

This will:
Cloud Build will deploy:

* Build the image for the dedicated game server.
* Store those image in [Artifact Registry](https://cloud.google.com/artifact-registry).
* Store the image in [Artifact Registry](https://cloud.google.com/artifact-registry).
* Start the staged rollout of the Agones Fleet to each regional set of clusters.

> This will take ~20 minutes or so, so feel free to grab a cup of ☕
Navigate to the
[agones-deploy-pipeline](https://console.cloud.google.com/deploy/delivery-pipelines/us-central1/global-game-agones-gameservers)
delivery pipeline to review the rollout status. Cloud Build will create a Cloud Deploy release which automatically
deploys the game server Agones Fleet to the `asia-east1` region first.
The Fleet can be deployed to the next region in the queue via pressing the
`promote` button within the Pipeline visualization or by running the following gcloud command:

```shell
# Replace RELEASE_NAME with the unique build name
gcloud deploy releases promote --release=RELEASE_NAME --delivery-pipeline=global-game-agones-gameservers --region=us-central1
```

## Game Client

Expand Down
25 changes: 24 additions & 1 deletion game/cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@

serviceAccount: projects/${PROJECT_ID}/serviceAccounts/cloudbuild-cicd@${PROJECT_ID}.iam.gserviceaccount.com
steps:

#
# Building of the images
#

- name: gcr.io/cloud-builders/docker
id: github-login
script: |
Expand All @@ -22,13 +27,31 @@ steps:
- CR_PAT
- name: gcr.io/cloud-builders/docker
id: build-image
args: ["build", ".", "-t", "${_UNREAL_SERVER_IMAGE}"]
args: [ "build", ".", "-t", "${_UNREAL_SERVER_IMAGE}" ]

#
# Deployment
#

- name: gcr.io/google.com/cloudsdktool/cloud-sdk
id: cloud-deploy-release
entrypoint: gcloud
args:
[
"deploy", "releases", "create", "${_RELEASE_NAME}",
"--delivery-pipeline", "global-game-agones-gameservers",
"--skaffold-file", "skaffold.yaml",
"--images", "droidshooter-server=${_UNREAL_SERVER_IMAGE}",
"--region", "us-central1"
]

artifacts:
images:
- ${_REGISTRY}/droidshooter-server
substitutions:
_UNREAL_SERVER_IMAGE: ${_REGISTRY}/droidshooter-server:${BUILD_ID}
_REGISTRY: us-docker.pkg.dev/${PROJECT_ID}/global-game-images
_RELEASE_NAME: rel-01
availableSecrets:
secretManager:
- versionName: projects/${PROJECT_ID}/secrets/github-packages/versions/latest
Expand Down
2 changes: 1 addition & 1 deletion game/fleet.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,4 @@ spec:
spec:
containers:
- name: droidshooter
image: us-docker.pkg.dev/mark-world-scale/global-game-images/droidshooter-server:f3a6bb7e-d11d-489c-b2eb-23f9a5b8af1b
image: droidshooter-server
21 changes: 21 additions & 0 deletions game/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# Copyright 2023 Google LLC All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

apiVersion: skaffold/v4beta1
kind: Config
metadata:
name: game
manifests:
rawYaml:
- fleet.yaml
2 changes: 1 addition & 1 deletion infrastructure/pipelines.tf
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ resource "google_clouddeploy_target" "agones_regional_targets" {

resource "google_clouddeploy_delivery_pipeline" "gameservers_gke" {
location = var.clouddeploy_config.location
name = "global-game-servers"
name = "global-game-agones-gameservers"
description = "Global Game: Agones GameServer Deploy Pipeline"
provider = google-beta

Expand Down
2 changes: 2 additions & 0 deletions infrastructure/services-gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,6 @@ resource "google_gke_hub_membership" "services-gke-membership" {
resource_link = "//container.googleapis.com/${google_container_cluster.services-gke.id}"
}
}

depends_on = [google_project_service.project]
}

0 comments on commit 08ad9bf

Please sign in to comment.