Skip to content

Commit

Permalink
Add Service Mesh for cross-cluster communication (#101)
Browse files Browse the repository at this point in the history
* Deploy managed ASM to all clusters

* Add agones allocator virtual service

* Updates for service mesh

* Remove Cloudrun components

* Update headless agones service spec

* Ignore generated open match kustomization.yaml

* terraform fmt

* Update README.md

* Rename patch file

* Remove allocation endpoint artifacts

* udp not needed

* Move ASM install as Agones Cloudbuild step

* Refactoring platform deployments into single cloudbuild
  • Loading branch information
benfogel authored Mar 6, 2023
1 parent 89e035a commit 76262ac
Show file tree
Hide file tree
Showing 19 changed files with 246 additions and 450 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,4 @@ infrastructure/deploy/agones/install/skaffold.yaml
# Ignore Terraform generated kustomization files
**/global-game-*/kustomization.yaml
**/global-game-*/agones-system.yaml
platform/open-match/base/kustomization.yaml
27 changes: 9 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,37 +106,28 @@ This should give you back an IP, such as `35.202.107.204`.

Since OAuth needs a domain to authenticate against, we'll use [sslip.io](https://sslip.io) for development purposes.

### Deploy Agones To Agones GKE Clusters
### Deploy Platform Components
Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy

The Agones deployment is in two steps: The Initial Install and the Allocation Endpoint Patch.

### Initial Install
Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Agones using Cloud Deploy.
- Anthos Service Mesh (ASM) to all clusters using the fleet feature API
- Agones using Cloud Deploy
- Open Match using Cloud Deploy

```shell
cd $GAME_DEMO_HOME/platform/agones/
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. Cloudbuild will create a Cloud Deploy release which automatically deploys Agones to 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. Cloudbuild 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`
```

Continue the promotion until Agones has been deployed to all clusters.

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/Worloads panel in the GCP Console. Once the Worloads have been marked as OK, you can proceed to apply the Allocation Endpoint Patch.

### Deploy Open Match to Services GKE Cluster

Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Open Match using Cloud Deploy.
Continue the promotion until Agones has been deployed to all clusters. 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/Worloads panel in the GCP Console.

```shell
cd $GAME_DEMO_HOME/platform/open-match/
gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1
```
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.

## Install Game Backend Services

Expand Down
48 changes: 48 additions & 0 deletions infrastructure/agones-gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,25 @@ data "google_container_cluster" "game-demo-agones" {
depends_on = [module.agones_gke_standard_clusters, module.agones_gke_autopilot_clusters]
}

resource "google_gke_hub_membership" "membership" {
for_each = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters)
provider = google-beta
project = var.project
membership_id = "${each.key}-membership"
endpoint {
gke_cluster {
resource_link = "//container.googleapis.com/${data.google_container_cluster.game-demo-agones[each.key].id}"
}
}
}

resource "google_gke_hub_feature" "mesh" {
name = "servicemesh"
project = var.project
location = "global"
provider = google-beta
}

resource "google_compute_firewall" "agones-gameservers" {
name = "agones-gameservers"
project = var.project
Expand All @@ -89,3 +108,32 @@ resource "google_compute_firewall" "agones-gameservers" {
target_tags = ["game-server"]
source_ranges = ["0.0.0.0/0"]
}

# Make Skaffold file for Cloud Deploy into each GKE Cluster
resource "local_file" "agones-skaffold-file" {
content = templatefile(
"${path.module}/files/agones/skaffold.yaml.tpl", {
gke_clusters = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters)
})
filename = "${path.module}/${var.platform_directory}/agones/skaffold.yaml"
}

# Make cluster specific helm value for LB IP
resource "local_file" "agones-ae-lb-file" {
for_each = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters)

content = templatefile(
"${path.module}/files/agones/agones-install.yaml.tpl", {
location = each.value.region
})
filename = "${path.module}/${var.platform_directory}/agones/${each.key}/kustomization.yaml"
}

# Create agones-system ns manifest as resource referenced by kustomization.yaml
resource "local_file" "agones-ns-file" {
for_each = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters)

content = file("${path.module}/files/agones/agones-system.yaml")
filename = "${path.module}/${var.platform_directory}/agones/${each.key}/agones-system.yaml"
}

246 changes: 0 additions & 246 deletions infrastructure/allocation-endpoint.tf

This file was deleted.

Loading

0 comments on commit 76262ac

Please sign in to comment.