Skip to content

Commit

Permalink
feat: Option to enable redis (#11)
Browse files Browse the repository at this point in the history
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
  • Loading branch information
jsbroks and github-actions[bot] committed Apr 16, 2022
1 parent 26fefde commit 1022cd6
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 7 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ No providers.
| <a name="module_kms"></a> [kms](#module\_kms) | ./modules/kms | n/a |
| <a name="module_networking"></a> [networking](#module\_networking) | ./modules/networking | n/a |
| <a name="module_project_factory_project_services"></a> [project\_factory\_project\_services](#module\_project\_factory\_project\_services) | terraform-google-modules/project-factory/google//modules/project_services | ~> 11.3 |
| <a name="module_redis"></a> [redis](#module\_redis) | ./modules/redis | n/a |
| <a name="module_service_accounts"></a> [service\_accounts](#module\_service\_accounts) | ./modules/service_accounts | n/a |

## Resources
Expand All @@ -95,6 +96,7 @@ No resources.

| Name | Description | Type | Default | Required |
|------|-------------|------|---------|:--------:|
| <a name="input_create_redis"></a> [create\_redis](#input\_create\_redis) | Boolean indicating whether to provision an redis instance (true) or not (false). | `bool` | `false` | no |
| <a name="input_database_version"></a> [database\_version](#input\_database\_version) | Version for MySQL | `string` | `"MYSQL_8_0"` | no |
| <a name="input_deletion_protection"></a> [deletion\_protection](#input\_deletion\_protection) | If the instance should have deletion protection enabled. The database / Bucket can't be deleted when this value is set to `true`. | `bool` | `true` | no |
| <a name="input_domain_name"></a> [domain\_name](#input\_domain\_name) | Domain for accessing the Weights & Biases UI. | `string` | `null` | no |
Expand Down
8 changes: 7 additions & 1 deletion examples/public-dns-with-cloud-dns/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@ module "wandb" {
domain_name = var.domain
subdomain = var.subdomain

wandb_version = var.wandb_version
wandb_image = var.wandb_image

create_redis = true
use_internal_queue = true

deletion_protection = false
}

Expand All @@ -38,4 +44,4 @@ output "url" {

output "address" {
value = module.wandb.address
}
}
14 changes: 13 additions & 1 deletion examples/public-dns-with-cloud-dns/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,16 @@ variable "subdomain" {

variable "license" {
type = string
}
}

variable "wandb_version" {
description = "The version of Weights & Biases local to deploy."
type = string
default = "latest"
}

variable "wandb_image" {
description = "Docker repository of to pull the wandb image from."
type = string
default = "wandb/local"
}
16 changes: 16 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,19 @@ module "database" {
depends_on = [module.project_factory_project_services]
}

module "redis" {
count = var.create_redis ? 1 : 0
source = "./modules/redis"
namespace = var.namespace
memory_size_gb = 4
network = module.networking.network

}

locals {
redis_connection_string = var.create_redis ? "redis://${module.redis.0.connection_string}?tls=true&ttlInSeconds=60" : null
}

module "gke_app" {
source = "wandb/wandb/kubernetes"
version = "1.0.2"
Expand All @@ -94,6 +107,8 @@ module "gke_app" {
bucket = "gs://${module.file_storage.bucket_name}"
bucket_queue = "pubsub:/${module.file_storage.bucket_queue_name}"
database_connection_string = "mysql://${module.database.connection_string}"
redis_connection_string = local.redis_connection_string


oidc_client_id = var.oidc_client_id
oidc_issuer = var.oidc_issuer
Expand All @@ -106,6 +121,7 @@ module "gke_app" {
# still spinning up
depends_on = [
module.database,
module.redis,
module.file_storage,
module.app_gke
]
Expand Down
9 changes: 4 additions & 5 deletions modules/redis/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@ resource "google_redis_instance" "default" {
display_name = "${var.namespace} W&B Instance"
tier = "STANDARD_HA"
memory_size_gb = var.memory_size_gb
auth_enabled = true

location_id = google_compute_zones.available.names.0
alternative_location_id = google_compute_zones.available.names.1
location_id = data.google_compute_zones.available.names.0
alternative_location_id = data.google_compute_zones.available.names.1

authorized_network = var.network.id

redis_version = "REDIS_6_X"
reserved_ip_range = "10.10.30.0/24"
reserved_ip_range = "10.30.0.0/16"

transit_encryption_mode = "SERVER_AUTHENTICATION"
connect_mode = "DIRECT_PEERING"

labels = var.labels
}
}
3 changes: 3 additions & 0 deletions modules/redis/outputs.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
output "connection_string" {
value = "${google_redis_instance.default.host}:${google_redis_instance.default.port}"
}
9 changes: 9 additions & 0 deletions variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,12 @@ variable "database_version" {
error_message = "We only support MySQL: \"MYSQL_5_7\"; \"MYSQL_8_0\"."
}
}

##########################################
# Redis #
##########################################
variable "create_redis" {
type = bool
description = "Boolean indicating whether to provision an redis instance (true) or not (false)."
default = false
}

0 comments on commit 1022cd6

Please sign in to comment.