diff --git a/README.md b/README.md index d65127b..efce571 100644 --- a/README.md +++ b/README.md @@ -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 @@ -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 diff --git a/game/cloudbuild.yaml b/game/cloudbuild.yaml index b9b6203..83e06df 100644 --- a/game/cloudbuild.yaml +++ b/game/cloudbuild.yaml @@ -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: | @@ -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 diff --git a/game/fleet.yaml b/game/fleet.yaml index c6bbc16..9f8d7ba 100644 --- a/game/fleet.yaml +++ b/game/fleet.yaml @@ -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 diff --git a/game/skaffold.yaml b/game/skaffold.yaml new file mode 100644 index 0000000..5afb194 --- /dev/null +++ b/game/skaffold.yaml @@ -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 diff --git a/infrastructure/pipelines.tf b/infrastructure/pipelines.tf index 70198f7..df1bf2c 100644 --- a/infrastructure/pipelines.tf +++ b/infrastructure/pipelines.tf @@ -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 diff --git a/infrastructure/services-gke.tf b/infrastructure/services-gke.tf index 6f26042..04a35a0 100644 --- a/infrastructure/services-gke.tf +++ b/infrastructure/services-gke.tf @@ -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] }