Skip to content

Commit

Permalink
Migration of service to Cloud Deploy Params (#238)
Browse files Browse the repository at this point in the history
This finishes the migration of all the services to use Cloud Deploy
params rather than generating configuration files locally.

Work on #181
  • Loading branch information
markmandel authored Mar 11, 2024
1 parent b5465e8 commit 86efe95
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 86 deletions.
25 changes: 20 additions & 5 deletions infrastructure/pipelines.tf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
// See the License for the specific language governing permissions and
// limitations under the License.

##### Spanner Pipelines #####
##### Services Pipelines #####

resource "google_clouddeploy_target" "services_deploy_target" {
location = var.services_gke_config.location
Expand Down Expand Up @@ -50,10 +50,25 @@ resource "google_clouddeploy_delivery_pipeline" "services_pipeline" {
target_id = google_clouddeploy_target.services_deploy_target.target_id
deploy_parameters {
values = {
project = var.project
spanner_service_email = google_service_account.spanner-sa.email
spanner_instance_id = google_spanner_instance.global-game-spanner.name
spanner_database_id = google_spanner_database.spanner-database.name
project = var.project

# Spanner config
spanner_service_account = google_service_account.spanner-sa.email
spanner_instance_id = google_spanner_instance.global-game-spanner.name
spanner_database_id = google_spanner_database.spanner-database.name

# Ping Service config
ping_service_account = google_service_account.ping_discovery_sa.email

# Frontend config
frontend_client_id = var.frontend-service.client_id
frontend_client_secret = var.frontend-service.client_secret
frontend_jwt_key = var.frontend-service.jwt_key
frontend_service_address = google_compute_address.frontend-service.address
frontend_callback_hostname = "http://${google_compute_address.frontend-service.address}.sslip.io/callback"

# Open Match config
players_per_match = var.open-match-matchfunction.players_per_match
}
}
}
Expand Down
28 changes: 0 additions & 28 deletions infrastructure/services-gke.tf
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,6 @@ resource "google_project_iam_member" "ping_discovery_sa" {
member = "serviceAccount:${google_service_account.ping_discovery_sa.email}"
}

# Make Service Account file for deploy with Cloud Deploy
resource "local_file" "services-ping-service-account" {
content = templatefile(
"${path.module}/files/services/ping-service-account.yaml.tpl", {
service_email = google_service_account.ping_discovery_sa.email
})
filename = "${path.module}/${var.services_directory}/ping-discovery/service-account.yaml"
}

#
# Frontend Service
#
Expand All @@ -142,25 +133,6 @@ resource "google_compute_address" "frontend-service" {
}
}

resource "local_file" "services-frontend-config-map" {
content = templatefile(
"${path.module}/files/services/frontend-config.yaml.tpl", {
service_address = google_compute_address.frontend-service.address
client_id = var.frontend-service.client_id
client_secret = var.frontend-service.client_secret
jwt_key = var.frontend-service.jwt_key
})
filename = "${path.module}/${var.services_directory}/frontend/config.yaml"
}

resource "local_file" "open-match-matchfunction-config-map" {
content = templatefile(
"${path.module}/files/services/open-match-matchfunction-config.yaml.tpl", {
players_per_match = format("%q", var.open-match-matchfunction.players_per_match)
})
filename = "${path.module}/${var.services_directory}/open-match/matchfunction/config.yaml"
}

resource "google_gke_hub_membership" "services-gke-membership" {
provider = google-beta
project = var.project
Expand Down
15 changes: 0 additions & 15 deletions services/frontend/.gitignore

This file was deleted.

10 changes: 5 additions & 5 deletions ...e/files/services/frontend-config.yaml.tpl → services/frontend/config.yaml
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ kind: ConfigMap
metadata:
name: frontend-service
data:
CLIENT_ID: ${client_id}
CLIENT_SECRET: ${client_secret}
CLIENT_ID: client_id # from-param: ${frontend_client_id}
CLIENT_SECRET: client_secret # from-param: ${frontend_client_secret}
LISTEN_PORT: "8080"
CALLBACK_HOSTNAME: http://${service_address}.sslip.io/callback
CALLBACK_HOSTNAME: http://service_address.sslip.io/callback # from-param: ${frontend_callback_hostname}
CLIENT_LAUNCHER_PORT: "8082"
PROFILE_SERVICE: http://profile
PING_SERVICE: http://ping-discovery
JWT_KEY: ${jwt_key}
JWT_KEY: jwt_key # from-param: ${frontend_jwt_key}
---
apiVersion: v1
kind: Service
Expand All @@ -37,4 +37,4 @@ spec:
ports:
- port: 80
targetPort: 8080
loadBalancerIP: ${service_address}
loadBalancerIP: service_address # from-param: ${frontend_service_address}
15 changes: 0 additions & 15 deletions services/open-match/matchfunction/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ metadata:
name: open-match-matchfunction
namespace: open-match
data:
PLAYERS_PER_MATCH: ${players_per_match}
PLAYERS_PER_MATCH: "3" # from-param: ${players_per_match}
15 changes: 0 additions & 15 deletions services/ping-discovery/.gitignore

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ kind: ServiceAccount
metadata:
name: ping-discovery
annotations:
iam.gke.io/gcp-service-account: ${service_email}
iam.gke.io/gcp-service-account: [email protected] # from-param: ${ping_service_account}
2 changes: 1 addition & 1 deletion services/profile/spanner-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ kind: ServiceAccount
metadata:
name: profile
annotations:
iam.gke.io/gcp-service-account: [email protected] # from-param: ${spanner_service_email}
iam.gke.io/gcp-service-account: [email protected] # from-param: ${spanner_service_account}

---

Expand Down

0 comments on commit 86efe95

Please sign in to comment.