diff --git a/.github/workflows/database-copy.yml b/.github/workflows/database-copy.yml new file mode 100644 index 00000000..4e2b0699 --- /dev/null +++ b/.github/workflows/database-copy.yml @@ -0,0 +1,18 @@ +name: Copy PAAS databases to AKS + +on: + workflow_dispatch: + schedule: + - cron: "0 2 * * *" # 02:00 UTC + +jobs: + restore_db: + name: Restore DB + strategy: + matrix: + environment: [dev] + max-parallel: 1 + uses: ./.github/workflows/restore-paas-db-to-aks.yml + with: + environment: ${{ matrix.environment }} + secrets: inherit diff --git a/.github/workflows/restore-paas-db-to-aks.yml b/.github/workflows/restore-paas-db-to-aks.yml index 36839ecb..a593409b 100644 --- a/.github/workflows/restore-paas-db-to-aks.yml +++ b/.github/workflows/restore-paas-db-to-aks.yml @@ -1,6 +1,10 @@ name: Backup and restore Postgres DB from PAAS to AKS on: + workflow_call: + inputs: + environment: + type: string workflow_dispatch: inputs: environment: diff --git a/terraform/aks/application.tf b/terraform/aks/application.tf index 20f2d635..8f290050 100644 --- a/terraform/aks/application.tf +++ b/terraform/aks/application.tf @@ -13,7 +13,7 @@ module "web_application" { is_web = true namespace = var.namespace - environment = var.app_environment + environment = local.environment service_name = local.service_name cluster_configuration_map = module.cluster_data.configuration_map @@ -33,7 +33,7 @@ module "application_configuration" { source = "./vendor/modules/aks//aks/application_configuration" namespace = var.namespace - environment = var.app_environment + environment = local.environment azure_resource_prefix = var.azure_resource_prefix service_short = var.service_short config_short = var.config_short @@ -41,3 +41,20 @@ module "application_configuration" { secret_variables = local.app_secrets secret_key_vault_short = "app" } + +module "worker_application" { + source = "./vendor/modules/aks//aks/application" + name = "worker" + is_web = false + namespace = var.namespace + environment = local.environment + service_name = local.service_name + cluster_configuration_map = module.cluster_data.configuration_map + kubernetes_config_map_name = module.application_configuration.kubernetes_config_map_name + kubernetes_secret_name = module.application_configuration.kubernetes_secret_name + docker_image = var.paas_app_docker_image + command = ["bundle", "exec", "sidekiq", "-C", "./config/sidekiq.yml"] + probe_command = ["pgrep", "-f", "sidekiq"] + max_memory = var.worker_memory_max + replicas = var.worker_replicas +} diff --git a/terraform/aks/variables.tf b/terraform/aks/variables.tf index fd684ce4..5f783a21 100644 --- a/terraform/aks/variables.tf +++ b/terraform/aks/variables.tf @@ -67,6 +67,17 @@ variable "memory_max" { description = "Max memory size" } +variable "worker_replicas" { + default = 1 + type = number +} + +variable "worker_memory_max" { + default = "1Gi" + type = string + description = "Max memory size of worker" +} + variable "gov_uk_host_names" { default = [] type = list(any)