From a0bec03f97ec9c76637327ad070e9e934b9f061f Mon Sep 17 00:00:00 2001 From: Mark Mandel Date: Wed, 22 May 2024 17:32:06 -0700 Subject: [PATCH] Agones Installation to Cloud Deploy Params (#260) This is the last piece of removing generating local files from the Terraform configuration to use with Cloud Deploy - everything has now been moved to Cloud Deploy Parameters! This moves the installation of Agones' into each cluster to use a Cloud Deploy parameter set on each Cloud Deploy Target. This also simplifies the Skaffold configuration to remove Kustomize from the yaml. Closes #181 --- .gitignore | 11 ----- infrastructure/agones-gke.tf | 29 ------------ .../files/agones/agones-install.yaml.tpl | 27 ------------ infrastructure/files/agones/skaffold.yaml.tpl | 22 ---------- infrastructure/pipelines.tf | 5 ++- .../agones/agones-system.yaml | 0 platform/agones/skaffold.yaml | 44 +++++++++++++++++++ 7 files changed, 48 insertions(+), 90 deletions(-) delete mode 100644 infrastructure/files/agones/agones-install.yaml.tpl delete mode 100644 infrastructure/files/agones/skaffold.yaml.tpl rename {infrastructure/files => platform}/agones/agones-system.yaml (100%) mode change 100644 => 100755 create mode 100755 platform/agones/skaffold.yaml diff --git a/.gitignore b/.gitignore index 8baa7a2..8629811 100644 --- a/.gitignore +++ b/.gitignore @@ -22,17 +22,6 @@ backend.tf deploy/base/charts/ -# Ignore Terraform generated k8s manifest files -patch-agones-allocator-*.yaml - -# Ignore Terraform generated skaffold files -skaffold-global-game-*.yaml -platform/agones/skaffold.yaml - -# Ignore Terraform generated kustomization files -**/global-game-*/kustomization.yaml -**/global-game-*/agones-system.yaml - # Ignore any tmp files generated infrastructure/tmp diff --git a/infrastructure/agones-gke.tf b/infrastructure/agones-gke.tf index 41d2d35..e8136c0 100644 --- a/infrastructure/agones-gke.tf +++ b/infrastructure/agones-gke.tf @@ -122,32 +122,3 @@ 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" -} - diff --git a/infrastructure/files/agones/agones-install.yaml.tpl b/infrastructure/files/agones/agones-install.yaml.tpl deleted file mode 100644 index 212f79e..0000000 --- a/infrastructure/files/agones/agones-install.yaml.tpl +++ /dev/null @@ -1,27 +0,0 @@ -helmCharts: - - name: agones - repo: https://agones.dev/chart/stable - version: 1.40.0 - releaseName: agones - namespace: agones-system - valuesInline: - agones: - crds: - cleanupOnDelete: false - allocator: - disableMTLS: true - disableTLS: true - service: - serviceType: ClusterIP - http: - port: 8000 - targetPort: 8000 - portName: http-alloc - grpc: - enabled: false - labels: - istio.io/rev: asm-managed #ASM managed dataplane channel - region: ${location} #Region to identify the POD and send traffic - -resources: - - agones-system.yaml diff --git a/infrastructure/files/agones/skaffold.yaml.tpl b/infrastructure/files/agones/skaffold.yaml.tpl deleted file mode 100644 index 5a7bf84..0000000 --- a/infrastructure/files/agones/skaffold.yaml.tpl +++ /dev/null @@ -1,22 +0,0 @@ -apiVersion: skaffold/v4beta1 -kind: Config -manifests: - kustomize: - paths: - - ./path_to_cluster_specific_skaffold - buildArgs: - - --enable-helm -deploy: - kubectl: - flags: - apply: - - --server-side # Avoid the "Too long: must have at most 262144 bytes" problem - tolerateFailuresUntilDeadline: true # Fixes startup timeouts -profiles: -%{ for cluster_name, values in gke_clusters ~} - - name: ${cluster_name} - patches: - - op: replace - path: /manifests/kustomize/paths/0 - value: "./${cluster_name}" -%{ endfor ~} diff --git a/infrastructure/pipelines.tf b/infrastructure/pipelines.tf index 3cc4dc1..194297a 100644 --- a/infrastructure/pipelines.tf +++ b/infrastructure/pipelines.tf @@ -96,6 +96,10 @@ resource "google_clouddeploy_target" "agones-gke" { project = var.project require_approval = false + deploy_parameters = { + "agones.allocator.labels.region" = each.value.region + } + depends_on = [google_project_service.project] } @@ -115,7 +119,6 @@ resource "google_clouddeploy_delivery_pipeline" "agones-gke" { for_each = merge(var.game_gke_standard_clusters, var.game_gke_autopilot_clusters) content { target_id = google_clouddeploy_target.agones-gke[stages.key].target_id - profiles = [stages.key] } } } diff --git a/infrastructure/files/agones/agones-system.yaml b/platform/agones/agones-system.yaml old mode 100644 new mode 100755 similarity index 100% rename from infrastructure/files/agones/agones-system.yaml rename to platform/agones/agones-system.yaml diff --git a/platform/agones/skaffold.yaml b/platform/agones/skaffold.yaml new file mode 100755 index 0000000..ccc11da --- /dev/null +++ b/platform/agones/skaffold.yaml @@ -0,0 +1,44 @@ +# Copyright 2024 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/v4beta9 +kind: Config +manifests: + rawYaml: + - agones-system.yaml + helm: + releases: + - name: agones + namespace: agones-system + repo: https://agones.dev/chart/stable + remoteChart: agones + version: 1.40.0 + setValues: + agones.crds.cleanupOnDelete: false + agones.allocator.disableMTLS: true + agones.allocator.disableTLS: true + agones.allocator.service.serviceType: ClusterIP + agones.allocator.service.http.port: 8000 + agones.allocator.service.http.targetPort: 8000 + agones.allocator.service.http.portName: http-alloc + agones.allocator.service.grpc.enabled: false + agones.allocator.labels.istio\.io/rev: asm-managed + # agones.allocator.labels.region: -- set by convention with Cloud Deploy Parameter attached to the target cluster +deploy: + kubectl: + flags: + apply: + - --server-side # Avoid the "Too long: must have at most 262144 bytes" problem + - --force-conflicts + tolerateFailuresUntilDeadline: true # Fixes startup timeouts \ No newline at end of file