-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: Add MySQL support #138
Conversation
Introduces a new variable database_type
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks so much for working on these updates, @akashgangil!
Overall, it's looks good. I've left some comments.
We'll also need to add an integration test for the MySQL option.
We'll need to:
- add an
/examples/mysql/
folder (see thissuffix_example/
folder from another repo) (this folder will be auto-discovered by our integration tests) — it'll be mostly identical to the existing /examples/simple_example folder expect we'll need to pass indatabase_type = 'mysql'
- generate the
/examples/mysql/README.md
by runningmake docker_generate_docs
- update the
/build/int.cloudbuild.yaml
file (see example from another repo) - add a
/test/integration/mysql/mysql_test.go
file (see example from another repo here)
instance = google_sql_database_instance.main.name | ||
deletion_policy = "ABANDON" | ||
name = var.database_type == "postgres" ? "${google_service_account.runsa.account_id}@${var.project_id}.iam" : "foo" | ||
type = var.database_type == "postgres" ? "CLOUD_IAM_SERVICE_ACCOUNT" : null | ||
password = var.database_type == "mysql" ? "bar" : null |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: Does MySQL allow us to use type = CLOUD_IAM_SERVICE_ACCOUNT
? I want to see if we can use the same google_sql_user
definition for both PostgreSQL and MySQL.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried it but didn't work for me just right out of the box. Maybe we can take this in a follow up PR if this is not blocking?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed (let's move this type = CLOUD_IAM_SERVICE_ACCOUNT
issue out of scope from this pull-request).
Issue created: #151
@@ -19,7 +19,7 @@ data "google_project" "project" { | |||
} | |||
|
|||
locals { | |||
api_image = "gcr.io/sic-container-repo/todo-api-postgres:latest" | |||
api_image = (var.database_type == "mysql" ? "gcr.io/sic-container-repo/todo-api" : "gcr.io/sic-container-repo/todo-api-postgres:latest") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Praise: Thanks for digging into the differences between these two images! :) I didn't realize to original 3-tier web app used MySQL.
/gcbrun |
Done. Thanks Nim for the review. Addressed all your comments |
/gcbrun (to trigger the integration tests) |
This fixes lint errors.
Before this change, we would: 1. Test (deploy, verify, and destroy) simple_example 2. Wait for simple_example to destroy 3. Test two new (parallel) deployments of simple_example With this change, we now: 1. Test two deployments in parallel: the simple_example (which uses PostgreSQL); and the MySQL version.
/gcbrun (to trigger the integration tests) |
/gcbrun |
/gcbrun |
/gcbrun |
/gcbrun |
/gcbrun |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've updated the integration tests such that:
- we now deploy the MySQL variation — in parallel to the PostgreSQL version
- we no longer deploy the pre-existing "multiple instance" test since it's now redundant
I've also made some minor lint-related tweaks.
Thank you so much, @akashgangil, for doing this (and addressing all my feedback)! 👏 Everything looks good. Integration tests are passing. Approved. Merging.
Introduces a new variable database_type to configure
the three tier web app to use either MySQL or PostgreSQL.
Resuses gcr.io/sic-container-repo/todo-api, due to this MySQL
instance authentication is configured via a databases user/password
instead of IAM service account like PG.
MySQL
PostgreSQL