Skip to content
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

Support redis url secret #279

Merged
merged 2 commits into from
Apr 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ module "deployment" {

media_storage = var.media_storage

cache_url = var.cache_url
django_admins = var.django_admins
django_additional_allowed_hosts = var.django_additional_allowed_hosts
django_default_from_email = var.django_default_from_email
Expand All @@ -82,5 +83,5 @@ module "deployment" {
extra_config_values = var.extra_config_values
extra_secret_values = var.extra_secret_values

additional_secrets = var.use_redis ? ["database-url", "cache-url"] : ["database-url"]
additional_secrets = var.use_redis ? ["database-url", "redis-url"] : ["database-url"]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
variable "cache_url" {
type = string
description = "A Django cache URL override."
default = ""
sensitive = true
}

variable "digitalocean_token" {
description = "The Digital Ocean access token."
type = string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +132,11 @@ resource "kubernetes_deployment_v1" "main" {
name = var.service_slug
resources {
limits = {
cpu = var.service_limits_cpu
cpu = var.service_limits_cpu
memory = var.service_limits_memory
}
requests = {
cpu = var.service_requests_cpu
cpu = var.service_requests_cpu
memory = var.service_requests_memory
}
}
Expand Down Expand Up @@ -169,6 +169,10 @@ resource "kubernetes_deployment_v1" "main" {
}
}
}
env {
name = "CACHE_URL"
value = coalesce(var.cache_url, "$(REDIS_URL)?key_prefix=${var.environment_slug}")
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,13 @@ variable "additional_secrets" {
default = []
}

variable "cache_url" {
type = string
description = "A Django cache URL override."
default = ""
sensitive = true
}

variable "django_additional_allowed_hosts" {
type = string
description = "Additional entries of the DJANGO_ALLOWED_HOSTS environment variable ('127.0.0.1', 'localhost', the service slug and the project host are included by default)."
Expand Down
3 changes: 2 additions & 1 deletion {{cookiecutter.project_dirname}}/terraform/other-k8s/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ module "deployment" {

media_persistent_volume_claim_name = var.media_storage == "local" ? kubernetes_persistent_volume_claim_v1.media[0].metadata[0].name : ""

cache_url = var.cache_url
django_admins = var.django_admins
django_additional_allowed_hosts = var.django_additional_allowed_hosts
django_default_from_email = var.django_default_from_email
Expand All @@ -118,5 +119,5 @@ module "deployment" {
extra_config_values = var.extra_config_values
extra_secret_values = var.extra_secret_values

additional_secrets = var.use_redis ? ["database-url", "cache-url"] : ["database-url"]
additional_secrets = var.use_redis ? ["database-url", "redis-url"] : ["database-url"]
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
variable "cache_url" {
type = string
description = "A Django cache URL override."
default = ""
sensitive = true
}

variable "django_additional_allowed_hosts" {
type = string
description = "Additional entries of the DJANGO_ALLOWED_HOSTS environment variable ('127.0.0.1', 'localhost', the service slug and the project host are included by default)."
Expand Down