diff --git a/README.md b/README.md index 6c24f91..7318574 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ The Agones deployment is in two steps: The Initial Install and the Allocation En Replace the` _RELEASE_NAME` substitution with a unique build name. Cloudbuild will deploy Agones using Cloud Deploy. ```shell -cd $GAME_DEMO_HOME/infrastructure/deploy/agones/install +cd $GAME_DEMO_HOME/platform/agones/install gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1 ``` @@ -84,7 +84,7 @@ You can monitor the status of the deployment through the Cloud Logging URL retur 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 -cd $GAME_DEMO_HOME/infrastructure/deploy/agones/endpoint-patch/ +cd $GAME_DEMO_HOME/platform/agones/endpoint-patch/ gcloud builds submit --config=cloudbuild.yaml ``` @@ -94,12 +94,12 @@ 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 Game Services GKE Cluster +#### 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. ```shell -cd $GAME_DEMO_HOME/infrastructure/deploy/open-match +cd $GAME_DEMO_HOME/platform/open-match/ gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1 ``` diff --git a/infrastructure/allocation-endpoint.tf b/infrastructure/allocation-endpoint.tf index 3a69580..3e7eedb 100644 --- a/infrastructure/allocation-endpoint.tf +++ b/infrastructure/allocation-endpoint.tf @@ -207,7 +207,7 @@ resource "local_file" "agones-skaffold-file" { "${path.module}/files/agones/skaffold.yaml.tpl", { gke_clusters = var.game_gke_clusters }) - filename = "${path.module}/deploy/agones/install/skaffold.yaml" + filename = "${path.module}/${var.platform_directory}/agones/install/skaffold.yaml" } # Make cluster specific helm value for LB IP @@ -218,15 +218,15 @@ resource "local_file" "agones-ae-lb-file" { "${path.module}/files/agones/ae-lb-ip-patch.yaml.tpl", { lb_ip = google_compute_address.allocation-endpoint[each.key].address }) - filename = "${path.module}/deploy/agones/install/${each.key}/kustomization.yaml" + filename = "${path.module}/${var.platform_directory}/agones/install/${each.key}/kustomization.yaml" } # Create agones-system ns manifest as resource referenced by kustomization.yaml resource "local_file" "agones-ns-file" { for_each = var.game_gke_clusters - content = file("${path.module}/files/agones/agones-system.yaml") - filename = "${path.module}/deploy/agones/install/${each.key}/agones-system.yaml" + content = file("${path.module}/files/agones/agones-system.yaml") + filename = "${path.module}/${var.platform_directory}/agones/install/${each.key}/agones-system.yaml" } # Make Kubernetes manifest files to patch the Agones deployment for Allocation Endpoint @@ -241,5 +241,5 @@ resource "local_file" "patch-agones-manifest" { service_name = "${each.key}-${random_string.endpoint_random_string.result}.endpoints.${var.project}.cloud.goog" sa_email = google_service_account.ae_sa.email }) - filename = "${path.module}/deploy/agones/endpoint-patch/patch-agones-allocator-${each.key}.yaml" + filename = "${path.module}/${var.platform_directory}/agones/endpoint-patch/patch-agones-allocator-${each.key}.yaml" } diff --git a/infrastructure/deploy/open-match/kustomization.yaml b/infrastructure/deploy/open-match/kustomization.yaml deleted file mode 100644 index 3db2dab..0000000 --- a/infrastructure/deploy/open-match/kustomization.yaml +++ /dev/null @@ -1,3 +0,0 @@ -# ./kustomization.yaml -resources: -- base diff --git a/infrastructure/deploy/open-match/skaffold.yaml b/infrastructure/deploy/open-match/skaffold.yaml deleted file mode 100644 index e72282e..0000000 --- a/infrastructure/deploy/open-match/skaffold.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: skaffold/v2beta29 -kind: Config -deploy: - kustomize: - paths: - - "." - buildArgs: ["--enable-helm"] - flags: - apply: ['--server-side'] diff --git a/infrastructure/deploy/services/install/cloudbuild.yaml b/infrastructure/deploy/services/install/cloudbuild.yaml deleted file mode 100644 index e76796a..0000000 --- a/infrastructure/deploy/services/install/cloudbuild.yaml +++ /dev/null @@ -1,37 +0,0 @@ -# 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. - -serviceAccount: projects/${PROJECT_ID}/serviceAccounts/cloudbuild-cicd@${PROJECT_ID}.iam.gserviceaccount.com -steps: - - name: "gcr.io/cloud-builders/gke-deploy" - args: - - run - - --filename=spanner-system.yaml - - --location=us-central1 - - --cluster=global-game-gke-spanner - - --output=output/spanner-deploy-us-central1-01 - - - name: gcr.io/google.com/cloudsdktool/cloud-sdk - entrypoint: gcloud - args: - [ - "deploy", "releases", "create", "${_RELEASE_NAME}", - "--delivery-pipeline", "global-game-services", - "--region", "us-central1" - ] - -substitutions: - _RELEASE_NAME: rel-0001 -options: - logging: CLOUD_LOGGING_ONLY diff --git a/infrastructure/deploy/services/install/nginx/kustomization.yaml b/infrastructure/deploy/services/install/nginx/kustomization.yaml deleted file mode 100644 index 40fa4d8..0000000 --- a/infrastructure/deploy/services/install/nginx/kustomization.yaml +++ /dev/null @@ -1,8 +0,0 @@ -# ./nginx/kustomization.yaml -helmCharts: -- name: nginx - repo: https://charts.bitnami.com/bitnami - releaseName: nginx - version: 13.2.23 - releaseName: example-web - namespace: spanner diff --git a/infrastructure/deploy/services/install/spanner-system.yaml b/infrastructure/deploy/services/install/spanner-system.yaml deleted file mode 100644 index e469b46..0000000 --- a/infrastructure/deploy/services/install/spanner-system.yaml +++ /dev/null @@ -1,4 +0,0 @@ -apiVersion: v1 -kind: Namespace -metadata: - name: spanner diff --git a/infrastructure/pipelines.tf b/infrastructure/pipelines.tf index 8b4b96a..cf7e647 100644 --- a/infrastructure/pipelines.tf +++ b/infrastructure/pipelines.tf @@ -50,7 +50,8 @@ resource "google_clouddeploy_target" "agones" { for_each = var.game_gke_clusters location = var.clouddeploy_config.location - name = "agones-deploy-target-${each.key}" + name = "${each.value.short_name}-agones-deploy" + annotations = { my_first_annotation = "agones-annotation-1" @@ -101,7 +102,7 @@ resource "google_clouddeploy_delivery_pipeline" "agones" { for_each = var.game_gke_clusters content { target_id = google_clouddeploy_target.agones[stages.key].target_id - profiles = [stages.key] + profiles = [stages.key] } } } diff --git a/infrastructure/terraform.tfvars.sample b/infrastructure/terraform.tfvars.sample index 82dd488..1136cdf 100644 --- a/infrastructure/terraform.tfvars.sample +++ b/infrastructure/terraform.tfvars.sample @@ -12,9 +12,11 @@ # See the License for the specific language governing permissions and # limitations under the License. +# Project Specific Variables project = "PROJECT_ID" # Cloud Deploy Configuration +platform_directory = "../platform" # Relative to Terraform directory clouddeploy_config = { "location" : "us-central1" } @@ -40,18 +42,32 @@ vpc_regions = { ### `agones/install` & `deploy/agones/endpoint-patch/` as they are not dynamically created. game_gke_clusters = { "global-game-us-central1-01" : { + "short_name" : "us-central1-01", "region" : "us-central1", "machine_type" : "e2-standard-4" }, "global-game-us-central1-02" : { + "short_name" : "us-central1-02", "region" : "us-central1", "machine_type" : "e2-standard-4" }, "global-game-eu-west1-01" : { + "short_name" : "europe-west1-01", + "region" : "europe-west1", + "machine_type" : "e2-standard-4" + }, + "global-game-eu-west1-02" : { + "short_name" : "europe-west1-02", "region" : "europe-west1", "machine_type" : "e2-standard-4" }, "global-game-asia-east1-01" : { + "short_name" : "asia-east1-01", + "region" : "asia-east1", + "machine_type" : "e2-standard-4" + }, + "global-game-asia-east1-02" : { + "short_name" : "asia-east1-02", "region" : "asia-east1", "machine_type" : "e2-standard-4" } diff --git a/infrastructure/variables.tf b/infrastructure/variables.tf index 19ad652..c774c74 100644 --- a/infrastructure/variables.tf +++ b/infrastructure/variables.tf @@ -65,6 +65,8 @@ variable "spanner_config" { description = "Configuration specs for Spanner" } +### Services GKE Variables ### + variable "services_gke_config" { type = object({ cluster_name = string @@ -100,3 +102,8 @@ variable "allocation_endpoint" { }) description = "Allocation Endpoint Configuration Variables" } + +variable "platform_directory" { + type = string + description = "Services Directory for outputed Cloud Deploy related files" +} diff --git a/infrastructure/deploy/agones/endpoint-patch/cloudbuild.yaml b/platform/agones/endpoint-patch/cloudbuild.yaml similarity index 77% rename from infrastructure/deploy/agones/endpoint-patch/cloudbuild.yaml rename to platform/agones/endpoint-patch/cloudbuild.yaml index 564f1e8..a8cf6ca 100644 --- a/infrastructure/deploy/agones/endpoint-patch/cloudbuild.yaml +++ b/platform/agones/endpoint-patch/cloudbuild.yaml @@ -22,6 +22,14 @@ steps: - --cluster=global-game-asia-east1-01 - --output=output/agones-patch-asia-east1-01 + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=patch-agones-allocator-global-game-asia-east1-02.yaml + - --location=asia-east1 + - --cluster=global-game-asia-east1-02 + - --output=output/agones-patch-asia-east1-02 + - name: "gcr.io/cloud-builders/gke-deploy" args: - run @@ -30,6 +38,14 @@ steps: - --cluster=global-game-eu-west1-01 - --output=output/agones-patch-europe-west1-01 + - name: "gcr.io/cloud-builders/gke-deploy" + args: + - run + - --filename=patch-agones-allocator-global-game-eu-west1-02.yaml + - --location=europe-west1 + - --cluster=global-game-eu-west1-02 + - --output=output/agones-patch-europe-west1-02 + - name: "gcr.io/cloud-builders/gke-deploy" args: - run diff --git a/infrastructure/deploy/agones/install/cloudbuild.yaml b/platform/agones/install/cloudbuild.yaml similarity index 94% rename from infrastructure/deploy/agones/install/cloudbuild.yaml rename to platform/agones/install/cloudbuild.yaml index b2d37ea..166a128 100644 --- a/infrastructure/deploy/agones/install/cloudbuild.yaml +++ b/platform/agones/install/cloudbuild.yaml @@ -18,7 +18,7 @@ steps: entrypoint: gcloud args: [ - "deploy", "releases", "create", "${_RELEASE_NAME}", + "deploy", "releases", "create", "agones-${_RELEASE_NAME}", "--delivery-pipeline", "agones-deploy-pipeline", "--skaffold-file", "skaffold.yaml", "--skaffold-version", "1.39", diff --git a/platform/agones/install/skaffold.yaml b/platform/agones/install/skaffold.yaml new file mode 100755 index 0000000..6ff43fd --- /dev/null +++ b/platform/agones/install/skaffold.yaml @@ -0,0 +1,40 @@ +apiVersion: skaffold/v2beta29 +kind: Config +deploy: + kustomize: + paths: + - "./path_to_cluster_specific_skaffold" + buildArgs: ["--enable-helm"] + flags: + apply: ['--server-side'] # Avoid the "Too long: must have at most 262144 bytes" problem +profiles: +- name: global-game-asia-east1-01 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-asia-east1-01" +- name: global-game-asia-east1-02 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-asia-east1-02" +- name: global-game-eu-west1-01 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-eu-west1-01" +- name: global-game-eu-west1-02 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-eu-west1-02" +- name: global-game-us-central1-01 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-us-central1-01" +- name: global-game-us-central1-02 + patches: + - op: replace + path: /deploy/kustomize/paths/0 + value: "./global-game-us-central1-02" diff --git a/infrastructure/deploy/open-match/base/kustomization.yaml b/platform/open-match/base/kustomization.yaml similarity index 93% rename from infrastructure/deploy/open-match/base/kustomization.yaml rename to platform/open-match/base/kustomization.yaml index 9c04dd8..44bfe77 100644 --- a/infrastructure/deploy/open-match/base/kustomization.yaml +++ b/platform/open-match/base/kustomization.yaml @@ -1,6 +1,7 @@ # ./base/kustomization.yaml helmCharts: - name: open-match + namespace: open-match repo: https://open-match.dev/chart/stable version: 1.6.0 releaseName: open-match diff --git a/infrastructure/deploy/open-match/base/open-match.yaml b/platform/open-match/base/open-match.yaml similarity index 100% rename from infrastructure/deploy/open-match/base/open-match.yaml rename to platform/open-match/base/open-match.yaml diff --git a/infrastructure/deploy/open-match/cloudbuild.yaml b/platform/open-match/cloudbuild.yaml similarity index 84% rename from infrastructure/deploy/open-match/cloudbuild.yaml rename to platform/open-match/cloudbuild.yaml index 477feb1..6245784 100644 --- a/infrastructure/deploy/open-match/cloudbuild.yaml +++ b/platform/open-match/cloudbuild.yaml @@ -18,11 +18,14 @@ steps: entrypoint: gcloud args: [ - "deploy", "releases", "create", "${_RELEASE_NAME}", + "deploy", "releases", "create", "open-match-${_RELEASE_NAME}", "--delivery-pipeline", "global-game-open-match", + "--skaffold-file", "skaffold.yaml", + "--skaffold-version", "1.39", "--region", "us-central1" ] + substitutions: - _RELEASE_NAME: rel-0002 + _RELEASE_NAME: rel-0001 options: logging: CLOUD_LOGGING_ONLY diff --git a/infrastructure/deploy/services/install/skaffold.yaml b/platform/open-match/skaffold.yaml similarity index 92% rename from infrastructure/deploy/services/install/skaffold.yaml rename to platform/open-match/skaffold.yaml index 60ff692..c04ee1c 100644 --- a/infrastructure/deploy/services/install/skaffold.yaml +++ b/platform/open-match/skaffold.yaml @@ -3,7 +3,7 @@ kind: Config deploy: kustomize: paths: - - "./nginx" + - "./base" buildArgs: ["--enable-helm"] flags: apply: ['--server-side'] # Avoid the "Too long: must have at most 262144 bytes" problem