diff --git a/README.md b/README.md index 049ed18..6c24f91 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ You can also click on the following icon to open this repository in a 'batteries [![Open in Cloud Shell](https://gstatic.com/cloudssh/images/open-btn.svg)](https://ssh.cloud.google.com/cloudshell/editor?cloudshell_git_repo=https%3A%2F%2Fgithub.com%2Fgoogleforgames%2Fglobal-multiplayer-demo.git&cloudshell_git_branch=main&cloudshell_open_in_editor=README.md&cloudshell_workspace=.) -## Google Cloud Auth +### Google Cloud Auth Once you have Google Cloud CLI installed, you will need to authenticate against Google Cloud: @@ -56,7 +56,7 @@ Provision the infrastructure. terraform apply ``` -### Deploy Agones To GKE Clusters +#### Deploy Agones To Agones GKE Clusters The Agones deployment is in two steps: The Initial Install and the Allocation Endpoint Patch. @@ -80,7 +80,7 @@ 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. -#### Allocation Endpoint Patch +##### Allocation Endpoint Patch After the Agones install has completed and the GKE Workloads show complete, run the Allocation Endpoint Patch Cloud Deploy to apply the appropriate endpoint patches to each cluster: ```shell @@ -94,7 +94,7 @@ You can monitor the status of the deployment through the Cloud Logging URL retur nd as well as the Kubernetes Engine/Worloads panel in the GCP Console. Once the Worloads have been marked as O K, Agones should be avaialable. -#### Deploy Open Match to GKE Cluster +#### Deploy Open Match to Game Services GKE Cluster Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Open Match using Cloud Deploy. @@ -103,15 +103,9 @@ cd $GAME_DEMO_HOME/infrastructure/deploy/open-match gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1 ``` -### Deploy Spanner Applications to GKE Cluster +## Install Game Backend Services -#### Initial Deploy -Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Spanner applications using Cloud Deploy. - -```shell -cd $GAME_DEMO_HOME/infrastructure/deploy/spanner/install -gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1 -``` +TODO: fill in once we have services. ## Game Client diff --git a/infrastructure/deploy/open-match/cloudbuild.yaml b/infrastructure/deploy/open-match/cloudbuild.yaml index b7e3488..477feb1 100644 --- a/infrastructure/deploy/open-match/cloudbuild.yaml +++ b/infrastructure/deploy/open-match/cloudbuild.yaml @@ -19,7 +19,7 @@ steps: args: [ "deploy", "releases", "create", "${_RELEASE_NAME}", - "--delivery-pipeline", "global-game-open-match-deploy-pipeline", + "--delivery-pipeline", "global-game-open-match", "--region", "us-central1" ] substitutions: diff --git a/infrastructure/deploy/services/install/cloudbuild.yaml b/infrastructure/deploy/services/install/cloudbuild.yaml index 40b10f9..e76796a 100644 --- a/infrastructure/deploy/services/install/cloudbuild.yaml +++ b/infrastructure/deploy/services/install/cloudbuild.yaml @@ -27,7 +27,7 @@ steps: args: [ "deploy", "releases", "create", "${_RELEASE_NAME}", - "--delivery-pipeline", "global-game-spanner-deploy-pipeline", + "--delivery-pipeline", "global-game-services", "--region", "us-central1" ] diff --git a/infrastructure/open-match-gke.tf b/infrastructure/open-match-gke.tf deleted file mode 100644 index 4f67773..0000000 --- a/infrastructure/open-match-gke.tf +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright 2023 Google LLC -// -// 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 -// -// https://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. - -resource "google_container_cluster" "game-demo-open-match-gke" { - name = var.open-match_gke_config.cluster_name - location = var.open-match_gke_config.location - - network = google_compute_network.vpc.name - subnetwork = google_compute_subnetwork.subnet[var.open-match_gke_config.location].name - - # See issue: https://github.com/hashicorp/terraform-provider-google/issues/10782 - ip_allocation_policy {} - - # Enabling Autopilot for this cluster - enable_autopilot = true - - # Private IP Config - private_cluster_config { - enable_private_nodes = true - enable_private_endpoint = false - } - - depends_on = [google_compute_subnetwork.subnet, google_project_service.project] -} - -data "google_container_cluster" "game-demo-open-match-gke" { - name = var.open-match_gke_config.cluster_name - location = var.open-match_gke_config.location - - depends_on = [google_container_cluster.game-demo-open-match-gke] -} diff --git a/infrastructure/pipelines.tf b/infrastructure/pipelines.tf index 6fdeb55..8b4b96a 100644 --- a/infrastructure/pipelines.tf +++ b/infrastructure/pipelines.tf @@ -14,26 +14,13 @@ ##### Spanner Pipelines ##### -resource "google_clouddeploy_target" "spanner" { - location = var.spanner_gke_config.location - name = "global-game-spanner-deploy-target" - - annotations = { - my_first_annotation = "spanner-annotation-1" - - my_second_annotation = "spanner-annotation-2" - } - - description = "Global Game: Spanner Deploy Target" +resource "google_clouddeploy_target" "services_deploy_target" { + location = var.services_gke_config.location + name = "global-game-services-target" + description = "Global Game: Backend Services Deploy Target" gke { - cluster = data.google_container_cluster.game-demo-spanner-gke.id - } - - labels = { - my_first_label = "global-game-demo" - - my_second_label = "spanner" + cluster = data.google_container_cluster.services-gke.id } project = var.project @@ -42,29 +29,17 @@ resource "google_clouddeploy_target" "spanner" { depends_on = [google_project_service.project] } -resource "google_clouddeploy_delivery_pipeline" "spanner" { - location = var.spanner_gke_config.location - name = "global-game-spanner-deploy-pipeline" +resource "google_clouddeploy_delivery_pipeline" "services_pipeline" { + location = var.services_gke_config.location + name = "global-game-services" - annotations = { - my_first_annotation = "spanner-annotation-1" - - my_second_annotation = "spanner-annotation-2" - } - - description = "Global Game: Spanner Deploy Pipeline" - - labels = { - my_first_label = "global-game-demo" - - my_second_label = "spanner" - } + description = "Global Game: Backend Services Pipeline" project = var.project serial_pipeline { stages { - target_id = google_clouddeploy_target.spanner.target_id + target_id = google_clouddeploy_target.services_deploy_target.target_id } } } @@ -135,25 +110,13 @@ resource "google_clouddeploy_delivery_pipeline" "agones" { ##### Open Match Pipelines ##### resource "google_clouddeploy_target" "open-match-target" { - location = var.open-match_gke_config.location - name = "global-game-open-match-deploy-target" - - annotations = { - my_first_annotation = "open-match-annotation-1" - - my_second_annotation = "open-match-annotation-2" - } + location = var.services_gke_config.location + name = "global-game-open-match-target" description = "Global Game: Open Match Deploy Target" gke { - cluster = data.google_container_cluster.game-demo-open-match-gke.id - } - - labels = { - my_first_label = "global-game-demo" - - my_second_label = "open-match" + cluster = data.google_container_cluster.services-gke.id } project = var.project @@ -163,24 +126,11 @@ resource "google_clouddeploy_target" "open-match-target" { } resource "google_clouddeploy_delivery_pipeline" "open-match" { - location = var.open-match_gke_config.location - name = "global-game-open-match-deploy-pipeline" - - annotations = { - my_first_annotation = "open-match-annotation-1" - - my_second_annotation = "open-match-annotation-2" - } + location = var.services_gke_config.location + name = "global-game-open-match" description = "Global Game: Open Match Deploy Pipeline" - - labels = { - my_first_label = "global-game-demo" - - my_second_label = "open-match" - } - - project = var.project + project = var.project serial_pipeline { stages { diff --git a/infrastructure/spanner-gke.tf b/infrastructure/services-gke.tf similarity index 79% rename from infrastructure/spanner-gke.tf rename to infrastructure/services-gke.tf index fd68916..1b18c3b 100644 --- a/infrastructure/spanner-gke.tf +++ b/infrastructure/services-gke.tf @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -resource "google_container_cluster" "game-demo-spanner-gke" { - name = var.spanner_gke_config.cluster_name - location = var.spanner_gke_config.location +resource "google_container_cluster" "services-gke" { + name = var.services_gke_config.cluster_name + location = var.services_gke_config.location network = google_compute_network.vpc.name - subnetwork = google_compute_subnetwork.subnet[var.spanner_gke_config.location].name + subnetwork = google_compute_subnetwork.subnet[var.services_gke_config.location].name # See issue: https://github.com/hashicorp/terraform-provider-google/issues/10782 ip_allocation_policy {} @@ -34,11 +34,11 @@ resource "google_container_cluster" "game-demo-spanner-gke" { depends_on = [google_compute_subnetwork.subnet, google_project_service.project] } -data "google_container_cluster" "game-demo-spanner-gke" { - name = var.spanner_gke_config.cluster_name - location = var.spanner_gke_config.location +data "google_container_cluster" "services-gke" { + name = var.services_gke_config.cluster_name + location = var.services_gke_config.location - depends_on = [google_container_cluster.game-demo-spanner-gke] + depends_on = [google_container_cluster.services-gke] } resource "google_service_account" "app-service-account" { @@ -63,5 +63,5 @@ resource "google_service_account_iam_policy" "app-service-account-iam" { service_account_id = google_service_account.app-service-account.name policy_data = data.google_iam_policy.workload-id-policy.policy_data - depends_on = [google_project_service.project, google_container_cluster.game-demo-spanner-gke] + depends_on = [google_project_service.project, google_container_cluster.services-gke] } diff --git a/infrastructure/terraform.tfvars.sample b/infrastructure/terraform.tfvars.sample index 0b0493e..c0c83f3 100644 --- a/infrastructure/terraform.tfvars.sample +++ b/infrastructure/terraform.tfvars.sample @@ -75,18 +75,9 @@ spanner_config = { num_nodes = 3 } -# Spanner GKE Config Values -spanner_gke_config = { - cluster_name = "global-game-gke-spanner" - location = "us-central1" - resource_labels = { - environment = "staging" - } -} - -# Open Match GKE Config Values -open-match_gke_config = { - cluster_name = "global-game-gke-open-match" +# Services GKE Config Values +services_gke_config = { + cluster_name = "global-game-services" location = "us-central1" resource_labels = { environment = "staging" diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index bc0b0ea..19ad652 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -65,24 +65,14 @@ variable "spanner_config" { description = "Configuration specs for Spanner" } -variable "spanner_gke_config" { +variable "services_gke_config" { type = object({ cluster_name = string location = string resource_labels = map(string) }) - description = "Configuration specs for Spanner GKE Autopilot cluster" -} - -variable "open-match_gke_config" { - type = object({ - cluster_name = string - location = string - resource_labels = map(string) - }) - - description = "Configuration specs for Open Match GKE Autopilot cluster" + description = "Configuration specs for GKE Autopilot cluster that hosts all backend services" } variable "app_service_account_config" {