Skip to content

Commit

Permalink
Initial code to deploy core open match (#31)
Browse files Browse the repository at this point in the history
* initial code to deploy core open match

* Updated per suggestions and mapped to new folder structure

* Updated README to include open match

* Removed redundant namespace config
  • Loading branch information
zaratsian authored Feb 7, 2023
1 parent f0656c7 commit e3a92bf
Show file tree
Hide file tree
Showing 10 changed files with 186 additions and 0 deletions.
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ 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

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
gcloud builds submit --config=cloudbuild.yaml --substitutions=_RELEASE_NAME=rel-1
```

### Deploy Spanner Applications to GKE Cluster

#### Initial Deploy
Expand Down
16 changes: 16 additions & 0 deletions infrastructure/deploy/open-match/base/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# ./base/kustomization.yaml
helmCharts:
- name: 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
4 changes: 4 additions & 0 deletions infrastructure/deploy/open-match/base/open-match.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: v1
kind: Namespace
metadata:
name: open-match
28 changes: 28 additions & 0 deletions infrastructure/deploy/open-match/cloudbuild.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
# 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/google.com/cloudsdktool/cloud-sdk
entrypoint: gcloud
args:
[
"deploy", "releases", "create", "${_RELEASE_NAME}",
"--delivery-pipeline", "global-game-open-match-deploy-pipeline",
"--region", "us-central1"
]
substitutions:
_RELEASE_NAME: rel-0002
options:
logging: CLOUD_LOGGING_ONLY
3 changes: 3 additions & 0 deletions infrastructure/deploy/open-match/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# ./kustomization.yaml
resources:
- base
9 changes: 9 additions & 0 deletions infrastructure/deploy/open-match/skaffold.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: skaffold/v2beta29
kind: Config
deploy:
kustomize:
paths:
- "."
buildArgs: ["--enable-helm"]
flags:
apply: ['--server-side']
42 changes: 42 additions & 0 deletions infrastructure/open-match-gke.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
// 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]
}
57 changes: 57 additions & 0 deletions infrastructure/pipelines.tf
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,63 @@ 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"
}

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"
}

project = var.project
require_approval = false

depends_on = [google_project_service.project]
}

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"
}

description = "Global Game: Open Match Deploy Pipeline"

labels = {
my_first_label = "global-game-demo"

my_second_label = "open-match"
}

project = var.project

serial_pipeline {
stages {
target_id = google_clouddeploy_target.open-match-target.target_id
}
}
}

##### Cloud Deploy IAM #####

resource "google_project_iam_member" "clouddeploy-container" {
Expand Down
8 changes: 8 additions & 0 deletions infrastructure/terraform.tfvars.sample
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,14 @@ spanner_gke_config = {
}
}

# Open Match GKE Config Values
open-match_gke_config = {
cluster_name = "global-game-gke-open-match"
location = "us-central1"
resource_labels = {
environment = "staging"
}
}

# Agones Application Service Account Name
app_service_account_config = {
Expand Down
10 changes: 10 additions & 0 deletions infrastructure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,16 @@ variable "spanner_gke_config" {
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"
}

variable "app_service_account_config" {
type = object({
name = string
Expand Down

0 comments on commit e3a92bf

Please sign in to comment.