Skip to content

Commit

Permalink
Merge pull request #4843 from sgibson91/tf-azure/opt-in-container-reg…
Browse files Browse the repository at this point in the history
…istry

Make deploying a container registry on Azure opt-in
  • Loading branch information
sgibson91 authored Sep 19, 2024
2 parents af0b629 + 71a51d8 commit 7a2f91a
Show file tree
Hide file tree
Showing 4 changed files with 20 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
}
1 change: 1 addition & 0 deletions terraform/azure/projects/pchub.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
tenant_id = "f1123d69-0c31-44db-ab9f-fa856d721d49"
subscription_id = "4ca0b08a-26e1-482f-bca6-f4eb0926124a"
resourcegroup_name = "2i2c-pchub"
create_container_registry = true
global_container_registry_name = "2i2cpchub"
global_storage_account_name = "2i2cpchub"
location = "westeurope"
Expand Down
1 change: 1 addition & 0 deletions terraform/azure/projects/utoronto.tfvars
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
tenant_id = "78aac226-2f03-4b4d-9037-b46d56c55210"
subscription_id = "ead3521a-d994-4a44-a68d-b16e35642d5b"
resourcegroup_name = "2i2c-utoronto-cluster"
create_container_registry = true
global_container_registry_name = "2i2cutorontohubregistry"
global_storage_account_name = "2i2cutorontohubstorage"
location = "canadacentral"
Expand Down
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 7a2f91a

Please sign in to comment.