Skip to content

Instantly share code, notes, and snippets.

@chgeuer
Created February 16, 2018 11:03
Show Gist options
  • Save chgeuer/5f4f60e9e9fb32c899f231783ebd4903 to your computer and use it in GitHub Desktop.
Save chgeuer/5f4f60e9e9fb32c899f231783ebd4903 to your computer and use it in GitHub Desktop.

Spin up a container registry

az acr create \
    --name="${acr_name}" \
    --resource-group="${RGNAME}" \
    --location="${K8SLOCATION}" \
    --sku="Basic" \
    --admin-enabled=true

fetch ACS password from Azure

acr_pass=$(az acr credential show --name $acr_name | jq -r .passwords[0].value)

inject imagePullSecret to k8s

kubectl create secret docker-registry "${acr_name}.azurecr.io" \
    --docker-server="https://${acr_name}.azurecr.io" \
    --docker-username="${acr_name}" \
    --docker-password="${acr_pass}" \
    --docker-email="root@${acr_name}"

If you're in the mood, you can even re-fetch password from k8s

acr_pass2=$( \
    kubectl get secret "${acr_name}.azurecr.io" --output=json | \
    jq -r '.data[".dockercfg"]' |  \
    base64 -d |  \
    jq -r ".[\"https://${acr_name}.azurecr.io\"].password" \
    )

On the laptop, login your docker to your ACR

docker login "${acr_name}.azurecr.io" \
    --username $acr_name \
    --password $acr_pass
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment