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

Getting it work with ACR (Azure Container Registry) #54

Open
zdraganov opened this issue Aug 25, 2017 · 1 comment
Open

Getting it work with ACR (Azure Container Registry) #54

zdraganov opened this issue Aug 25, 2017 · 1 comment

Comments

@zdraganov
Copy link

zdraganov commented Aug 25, 2017

I've tried to setup it as Docker Registry (using minikube addons configure registry-creds), but I think it's not supported for other reasons. Anyone using ACR have managed to do this?

@hasusuf
Copy link

hasusuf commented Mar 10, 2019

I was able to make it work by creating service principal and treating its creds as Private Docker Registry. I will provide the necessary terraform scripts for it. Use the outputted command to create the secret and add dpr-secret to imagePullSecrets in your deployment.

resource "azurerm_container_registry" "acr" {
  name                = "${var.name}"
  resource_group_name = "${var.resource_group}"
  location            = "${var.location}"
  sku                 = "Premium"
  admin_enabled       = false
}

resource "azuread_application" "acr_app" {
  name = "acr-app"
}

resource "azuread_service_principal" "acr_sp" {
  application_id = "${azuread_application.acr_app.application_id}"
}

resource "random_string" "acr_sp_password" {
  length  = 16
  special = true

  keepers = {
    service_principal = "${azuread_service_principal.acr_sp.id}"
  }
}

resource "azuread_service_principal_password" "acr_sp_password" {
  service_principal_id = "${azuread_service_principal.acr_sp.id}"
  value                = "${random_string.acr_sp_password.result}"
  end_date             = "${timeadd(timestamp(), "8760h")}"

  lifecycle {
    ignore_changes = ["end_date"]
  }

  provisioner "local-exec" {
    command = "sleep 30"
  }
}

resource "azurerm_role_assignment" "acr_assignment" {
  scope                = "${azurerm_container_registry.acr.id}"
  role_definition_name = "Contributor"
  principal_id         = "${azuread_service_principal_password.acr_sp_password.service_principal_id}"
}

output "docker" {
  value = "kubectl --context <CONTEXT> create secret generic registry-creds-dpr --from-literal DOCKER_PRIVATE_REGISTRY_SERVER=${azurerm_container_registry.acr.login_server} DOCKER_PRIVATE_REGISTRY_USER=${azuread_service_principal.acr_sp.application_id} DOCKER_PRIVATE_REGISTRY_PASSWORD=${azuread_service_principal_password.acr_sp_password.value} --dry-run -o yaml"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants