Skip to content

Commit f59548d

Browse files
abmarcummarkmandel
andauthored
Add Cloud Deploy Automations (#259)
* Updated Google Terraform Provider version to bring in the Cloud Deploy Automations * Added Cloud Deploy Automation Promotions for Agones & Game GKE deployments * Moved pipeline promotion var into clouddeploy_config object * Cleaned out commented args * Updated README to mention automatich cloud deployments for Agones and Game servers * Fixed grammar error in README * Update README.md Co-authored-by: Mark Mandel <[email protected]> * Removed manual pipeline promotion steps since promotion is now automatic * Update README.md Co-authored-by: Mark Mandel <[email protected]> * Update README.md Co-authored-by: Mark Mandel <[email protected]> * Update README.md --------- Co-authored-by: Mark Mandel <[email protected]>
1 parent 3f2eabd commit f59548d

File tree

5 files changed

+58
-19
lines changed

5 files changed

+58
-19
lines changed

README.md

Lines changed: 4 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -201,16 +201,9 @@ gcloud builds submit --config=cloudbuild.yaml
201201
Navigate to the
202202
[agones-deploy-pipeline](https://console.cloud.google.com/deploy/delivery-pipelines/us-central1/agones-deploy-pipeline)
203203
delivery pipeline to review the rollout status. Cloud Build will create a Cloud Deploy release which automatically
204-
deploys Agones the first game server cluster. Agones can be deployed to subsequent clusters by clicking on the
205-
`promote` button within the Pipeline visualization or by running the following gcloud command:
204+
deploys Agones to all of the game server clusters sequentially, with a (by default) 300s wait in between using [Cloud Deploy Automations](https://cloud.google.com/deploy/docs/automation).
206205

207-
```shell
208-
## Replace RELEASE_NAME with the unique id generated from the Cloud Build.
209-
gcloud deploy releases promote --release=RELEASE_NAME --delivery-pipeline=agones-deploy-pipeline --region=us-central1
210-
```
211-
212-
Continue the promotion until Agones has been deployed to all clusters. You can monitor the status of the deployment
213-
through the Cloud Logging URL returned by the `gcloud builds` command as well as the Kubernetes Engine/Workloads panel in the GCP Console.
206+
You can monitor the status of the deployment through the Cloud Logging URL returned by the `gcloud builds` command as well as the Kubernetes Engine/Workloads panel in the GCP Console.
214207

215208
Open Match rollout status can be viewed by navigating to the [global-game-open-match](https://console.cloud.google.com/deploy/delivery-pipelines/us-central1/global-game-open-match) delivery pipeline. Since open match is deployed onto a single services GKE cluster, deployments are automatically rolled out with no need for manual promotion.
216209

@@ -267,14 +260,8 @@ Cloud Build will deploy:
267260
Once the build process is complete, navigate to the
268261
[agones-deploy-pipeline](https://console.cloud.google.com/deploy/delivery-pipelines/us-central1/global-game-agones-gameservers)
269262
delivery pipeline to review the rollout status. Cloud Build will create a Cloud Deploy release which automatically
270-
deploys the game server Agones Fleet to the `asia-east1` region first.
271-
The Fleet can be deployed to the next region in the queue via pressing the
272-
`promote` button within the Pipeline visualization or by running the following gcloud command:
263+
deploys the game server Fleet to the global set of Agones Clusters sequentially using [Cloud Deploy Automations](https://cloud.google.com/deploy/docs/automation), starting with the `asia-east1` region first, and with a (by default) 300s wait in between each region.
273264

274-
```shell
275-
## Replace RELEASE_NAME with the unique build name
276-
gcloud deploy releases promote --release=RELEASE_NAME --delivery-pipeline=global-game-agones-gameservers --region=us-central1
277-
```
278265
#### Retrieve Game Client
279266

280267
The Cloud Build process will build and archive a `Client-${BUILD_ID}.zip` file in the Google Cloud Storage
@@ -429,4 +416,4 @@ Apache 2.0
429416

430417
This is not an officially supported Google product
431418

432-
[go/global-scale-game]: http://go/global-scale-game
419+
[go/global-scale-game]: http://go/global-scale-game

infrastructure/main.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ terraform {
1616
required_providers {
1717
google = {
1818
source = "hashicorp/google"
19-
version = "5.16.0"
19+
version = "5.29.1"
2020
}
2121
}
2222

infrastructure/pipelines.tf

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,31 @@ resource "google_clouddeploy_delivery_pipeline" "agones-gke" {
124124
}
125125
}
126126

127+
resource "google_clouddeploy_automation" "agones-gke" {
128+
name = "agones-deploy-automation-${each.key}"
129+
project = var.project
130+
location = var.clouddeploy_config.location
131+
delivery_pipeline = google_clouddeploy_delivery_pipeline.agones-gke.name
132+
service_account = google_service_account.cloudbuild-sa.email
133+
for_each = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters)
134+
135+
description = "Agones Deploy Automation - ${each.key}"
136+
selector {
137+
targets {
138+
id = google_clouddeploy_target.agones-gke[each.key].target_id
139+
}
140+
}
141+
142+
suspended = false
143+
rules {
144+
promote_release_rule {
145+
id = "promote-release"
146+
wait = var.clouddeploy_config.pipeline_promotion_wait
147+
destination_target_id = "@next"
148+
}
149+
}
150+
}
151+
127152
##### Game Server Pipeline
128153

129154
# Sort as a map of regions, with a list of Cloud Deploy targets within them.
@@ -178,6 +203,31 @@ resource "google_clouddeploy_delivery_pipeline" "gameservers_gke" {
178203
}
179204
}
180205

206+
resource "google_clouddeploy_automation" "gameservers_gke" {
207+
name = "gameserver-deploy-automation-${each.key}"
208+
project = var.project
209+
location = var.clouddeploy_config.location
210+
delivery_pipeline = google_clouddeploy_delivery_pipeline.gameservers_gke.name
211+
service_account = google_service_account.cloudbuild-sa.email
212+
for_each = local.targets_by_region
213+
214+
description = "Gameserver Deploy Automation - ${each.key}"
215+
selector {
216+
targets {
217+
id = google_clouddeploy_target.agones_regional_targets[each.key].target_id
218+
}
219+
}
220+
221+
suspended = false
222+
rules {
223+
promote_release_rule {
224+
id = "promote-release"
225+
wait = var.clouddeploy_config.pipeline_promotion_wait
226+
destination_target_id = "@next"
227+
}
228+
}
229+
}
230+
181231

182232
##### Open Match Pipelines #####
183233

infrastructure/terraform.tfvars.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ services_directory = "../services" # Relative to Terraform director
3333
schema_directory = "../infrastructure/schema" # Relative to Terraform directory
3434
clouddeploy_config = {
3535
"location" : "us-central1"
36+
"pipeline_promotion_wait" : "300s"
3637
}
3738

3839
# VPC Regions & associated subnet CIDRs Values

infrastructure/variables.tf

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ variable "game_gke_autopilot_clusters" {
5858

5959
variable "clouddeploy_config" {
6060
type = object({
61-
location = string
61+
location = string,
62+
pipeline_promotion_wait = string
6263
})
6364
}
6465

0 commit comments

Comments
 (0)