space-agon
space-agon copied to clipboard
Migrate Space Agon Demo from using Open Match 1 to Open Match 2
This pull request changes the Space Agon's match making logic from using Open Match 1 to Open Match 2(https://github.com/googleforgames/open-match2/blob/main)
Key files to review:
- director/director.go
- frontend/frontend.go
- mmf/mmf.go
- install/helm/space-agon/templates && install/helm/space-agon/values.yaml
- omclient/omclient.go - mostly copied from https://github.com/googleforgames/open-match-ecosystem/blob/v2.0/v2/internal/omclient/omclient.go, but added an initializer and assignment related APIs.
- logging/logging.go - completely copied from https://github.com/googleforgames/open-match-ecosystem/blob/v2.0/v2/internal/logging/logging.go.
Key differences between OM1 and OM2:
- Frontend and Director communicates with OM1 via gRPC, but use HTTP to communicate with OM2. Thus the
omclient.go
andlogging.go
was created. - OM1 was previously deployed in Kubernetes via helm, but OM2 is now deployed on Cloud Run (https://github.com/googleforgames/open-match2/blob/main/docs/DEVELOPMENT.md).
- Redis was previously deployed in Kubernetes via helm, but is now deployed on Memorystore on Pantheon UI.
- MMF is now an internal load balancer service because OM2 is not on Kubernetes.
Two tests are intentionally left out in the pull request:
- Frontend/frontend_test.go was deleted because the OM2 repo doesn't provide a
omtest
tool anymore, and the test itself isn't originally covering a lot of the code logic either. - The integration test was skipped in the PR checks because the process of deploying the Space Agon demo has changed a lot, and since OM2 and Redis are no longer deployed on Kubernetes, it is more complicated to set up for the integration test to run. Also, once it's all set up, it's more reasonable to test the demo just by running it, rather than running the integration test.
To run the demo with this PR, first follow the README to until you installed Agones. Then instead of installing Open Match with make openmatch-install
, follow the steps below to install OM2:
- Find the region of your Kubernetes Cluster, and use this region for the steps below.
- Create a Redis instance in Memorystore on Pantheon UI.
- Deploy OM2 by cloning the https://github.com/googleforgames/open-match2/blob/main repo and following the
docs/DEVELOPMENT.md
file to install OM2. You need to replace the IP address of theOM_REDIS_WRITE_HOST
andOM_REDIS_READ_HOST
in theservice.yaml
file to be the IP address of the Redis instance you created.
Now to allow your frontend
to talk to the OM2 you installed:
- Create a Google Service Account in your project and give it the
Cloud Run Invoker
role - Replace the value of
iam.gke.io/gcp-service-account
field infrontend.yaml
to be the Google Service Account you created. - Bind the Kubernetes Service Account in
frontend.yaml
to the Google Service Account(in the form ofSERVICE_ACCOUNT_NAME@PROJECT_ID.iam.gserviceaccount.com
) with
gcloud iam service-accounts add-iam-policy-binding --role roles/iam.workloadIdentityUser --member "serviceAccount:PROJECT_ID.svc.id.goog[default/frontend-sa]" YOUR_GOOGLE_SERVICE_ACCOUNT
- In
install/helm/space-agon/values.yaml
, change theomCoreAddress
field offrontend
to be the address of you OM2 service on Cloud Run.
Because the MMF server are now called from Cloud Run instead of Kubernetes Cluster, the MMF needs to have an IP that the director needs to know when the director is starting up. To do this,
- Reserve an internal IP address for you project in Pantheon UI.
- In
install/helm/space-agon/values.yaml
, replace theipAddress
field formmf
and themmfAddress
field fordirector
to be the IP address that you just reserved. - In
install/helm/space-agon/values.yaml
, change theomCoreAddress
field ofdirector
to be the address of you OM2 service on Cloud Run.
Now in the root directory of the demo and use make build && make install
to start the Space Agon demo. NOTE: after you have the external IP address of the frontend
service, open two chrome windows so you can see them AT THE SAME TIME, and click Find Game
. If you can't see both tabs at the same time, the demo's client has a bug that will connect to a match several times.
Towards #50