Skip to content

Commit

Permalink
Make deploying a container registry on Azure opt-in
Browse files Browse the repository at this point in the history
  • Loading branch information
sgibson91 committed Sep 19, 2024
1 parent af0b629 commit 5569750
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 8 deletions.
15 changes: 8 additions & 7 deletions terraform/azure/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -80,26 +80,27 @@ resource "azurerm_subnet" "node_subnet" {

# ref: https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/container_registry
resource "azurerm_container_registry" "container_registry" {
count = var.create_container_registry ? 1 : 0

name = var.global_container_registry_name
resource_group_name = azurerm_resource_group.jupyterhub.name
location = azurerm_resource_group.jupyterhub.location
sku = "Premium"
admin_enabled = true
}


locals {
registry_creds = {
"imagePullSecret" = {
"username" : azurerm_container_registry.container_registry.admin_username,
"password" : azurerm_container_registry.container_registry.admin_password,
"registry" : "https://${azurerm_container_registry.container_registry.login_server}"
}
"imagePullSecret" = try({
"username" : azurerm_container_registry.container_registry[0].admin_username,
"password" : azurerm_container_registry.container_registry[0].admin_password,
"registry" : "https://${azurerm_container_registry.container_registry[0].login_server}"
}, null)
}
storage_threshold = var.storage_size * var.fileshare_alert_available_fraction
}

output "registry_creds_config" {
value = jsonencode(local.registry_creds)
value = var.create_container_registry ? jsonencode(local.registry_creds) : null
sensitive = true
}
11 changes: 10 additions & 1 deletion terraform/azure/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,19 @@ variable "k8s_version_prefixes" {
EOT
}

variable "create_container_registry" {
type = bool
default = false
description = <<-EOT
Create a container registry for image storage, e.g., for binder deployments.
EOT
}

variable "global_container_registry_name" {
type = string
default = null
description = <<-EOT
Name of container registry to use for our image.
Name of container registry to use for image storage.
This needs to be globally unique across all of Azure (ugh?)
and not contain dashes or underscores.
Expand Down

0 comments on commit 5569750

Please sign in to comment.