Create a private, highly available container registry: Part 2

C.J. Shields
3 min readAug 5, 2020

Azure Kubernetes Service Workshop

This project is a continuation of my project “Deploy Kubernetes with Azure Kubernetes Service” : Part 1

Part 3- Coming soon

Create a container registry

First thing we’ll need to do is create a container registry name.

ACR_NAME=acr$RANDOM

Next we’ll use the az acr create command to create command to create the registry in the same resource group and region as our AKS cluster.

az acr create \
— resource-group $RESOURCE_GROUP \
— location $REGION_NAME \
— name $ACR_NAME \
— sku Standard

Build the ratings-api image

git clone https://github.com/MicrosoftDocs/mslearn-aks-workshop-ratings-api.git

Changed directories with cd

cd mslearn-aks-workshop-ratings-api

Next we’ll build the container image using our Dockerfile. This will push the image to the container registry

az acr build \
— resource-group $RESOURCE_GROUP \
— registry $ACR_NAME \
— image ratings-api:v1 .

Build the ratings-web image

These next steps, I used to create my ratings-web image.

cd ~

Next clone the ratings-web repo from github

git clone https://github.com/MicrosoftDocs/mslearn-aks-workshop-ratings-web.git

Change into the newly cloned directory.

cd mslearn-aks-workshop-ratings-web

Run az acr build. This command builds a container image by using the Dockerfile. Then it pushes the resulting image to the container registry.

Verify our images

Next we will run this following command in Cloud Shell to verify that the images were created.

az acr repository list \
— name $ACR_NAME \
— output table

Configure the AKS cluster to authenticate to the container registry

Last, we’ll use this command to integrate the container registry with the existing AKS cluster.

az aks update \
— name $AKS_CLUSTER_NAME \
— resource-group $RESOURCE_GROUP \
— attach-acr $ACR_NAME

--

--