diff --git a/infrastructure/files/open-match/kustomization.yaml.tpl b/infrastructure/files/open-match/kustomization.yaml.tpl new file mode 100644 index 0000000..b318b1b --- /dev/null +++ b/infrastructure/files/open-match/kustomization.yaml.tpl @@ -0,0 +1,43 @@ +# 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. + +# ./base/kustomization.yaml +helmCharts: +- name: open-match + namespace: open-match + repo: https://open-match.dev/chart/stable + version: 1.6.0 + releaseName: open-match + valuesInline: + open-match-override: + enabled: true + open-match-customize: + enabled: true + evaluator: + enabled: true + open-match-core: + redis: + enabled: false + # If open-match-core.redis.enabled is set to false, have Open Match components talk to this redis address instead. + # Otherwise the default is set to the om-redis instance. + hostname: ${redis_host} + port: ${redis_port} + pool: + maxIdle: 500 + maxActive: 500 + idleTimeout: 0 + healthCheckTimeout: 300ms + +resources: + - open-match.yaml diff --git a/infrastructure/open-match.tf b/infrastructure/open-match.tf new file mode 100644 index 0000000..3018d20 --- /dev/null +++ b/infrastructure/open-match.tf @@ -0,0 +1,70 @@ +// 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. + + +data "google_compute_network" "vpc" { + name = var.vpc_name +} + +resource "google_redis_instance" "open-match" { + name = "global-game-open-match" + tier = "STANDARD_HA" + memory_size_gb = 1 + region = var.services_gke_config.location + + location_id = "${var.services_gke_config.location}-a" + alternative_location_id = "${var.services_gke_config.location}-f" + + authorized_network = data.google_compute_network.vpc.id + transit_encryption_mode = "DISABLED" + connect_mode = "PRIVATE_SERVICE_ACCESS" + + redis_version = "REDIS_6_X" + display_name = "Global Game Demo: Open Match" + + labels = { + "environment" = var.resource_env_label + } + + depends_on = [google_service_networking_connection.private_service_connection, google_project_service.project, google_container_cluster.services-gke] +} + +resource "google_compute_global_address" "private_service_range" { + name = "private-service-range" + purpose = "VPC_PEERING" + address_type = "INTERNAL" + prefix_length = 16 + network = data.google_compute_network.vpc.id + + depends_on = [google_project_service.project] +} + +resource "google_service_networking_connection" "private_service_connection" { + network = data.google_compute_network.vpc.id + service = "servicenetworking.googleapis.com" + reserved_peering_ranges = [google_compute_global_address.private_service_range.name] + + depends_on = [google_project_service.project] +} + +# Add Redis Host & IP to Open Match kustomization.yaml +resource "local_file" "open-match-kustomization-file" { + + content = templatefile( + "${path.module}/files/open-match/kustomization.yaml.tpl", { + redis_host = google_redis_instance.open-match.host + redis_port = google_redis_instance.open-match.port + }) + filename = "${path.module}/${var.platform_directory}/open-match/base/kustomization.yaml" +} diff --git a/infrastructure/terraform.tfvars.sample b/infrastructure/terraform.tfvars.sample index 707aa8b..1d459b9 100644 --- a/infrastructure/terraform.tfvars.sample +++ b/infrastructure/terraform.tfvars.sample @@ -85,7 +85,9 @@ gcp_project_services = [ "artifactregistry.googleapis.com", "spanner.googleapis.com", "secretmanager.googleapis.com", + "servicenetworking.googleapis.com", "servicecontrol.googleapis.com", + "redis.googleapis.com", "run.googleapis.com", "iap.googleapis.com" ] diff --git a/platform/open-match/base/kustomization.yaml b/platform/open-match/base/kustomization.yaml deleted file mode 100644 index 44bfe77..0000000 --- a/platform/open-match/base/kustomization.yaml +++ /dev/null @@ -1,17 +0,0 @@ -# ./base/kustomization.yaml -helmCharts: -- name: open-match - namespace: open-match - repo: https://open-match.dev/chart/stable - version: 1.6.0 - releaseName: open-match - valuesInline: - open-match-override: - enabled: true - open-match-customize: - enabled: true - evaluator: - enabled: true - -resources: - - open-match.yaml