Terraform code for deploying an application.
For the list of requirement, inputs, outputs, resources... check the terraform module documentation.
module "web_application" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/application?ref=stable"
name = "web"
is_web = true
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.docker_image
}
module "worker_application" {
source = "git::https://github.com/DFE-Digital/terraform-modules.git//aks/application?ref=stable"
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.docker_image
command = ["bundle", "exec", "sidekiq"]
}
For web applications, the default probe_path
is set to /healthcheck
. The probe can be turned off by setting the variable to null
.
A simple one-line health check for a Rails application can be added to the routes.rb
file:
get "/healthcheck", to: proc { [200, {}, ['OK']] }
For more complex health checks, the OkComputer Gem provides some advanced functionality, for example:
OkComputer.mount_at = "healthcheck"
OkComputer::Registry.register "database", OkComputer::ActiveRecordCheck.new
A simple one-line health check for an ASP.NET application can be added to the endpoints:
endpoints.MapGet("/healthcheck", async context => {
await context.Response.WriteAsync("OK");
});
For more complex health checks, the ASP.NET Core Health Checks Middleware can be used, for example:
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHealthChecks();
var app = builder.Build();
app.MapHealthChecks("/healthcheck/all");
If azure_enable_monitoring
is true
, it’s expected that the following resources already exist:
- A resource group named
${azure_resource_prefix}-${service_short}-mn-rg
(wheremn
stands for monitoring andrg
stands for resource group). - A monitor action group named
${azure_resource_prefix}-${service_name}
within the above resource group.
If enable_prometheus_monitoring
is true
then custom metrics are scraped for the application
The hostname of the deployed application.
The URL of the deployed application.
The URL of the deployed application combined with the probe path.