PUSHING AN EXISTING APPLICATION TO AZURE CONTAINER REGISTRY

You can find Azure Kubernetes Service -Part 1 from the link here.

In this part of the demo, we will do the following:

  • Login to your Azure Account
  • Create a Resource Group and Create an Azure Container Registry in the Resource Group
  • Connect to the newly created Azure Container Registry
  • Get details of your newly created ACR
  • Tag your image
  • Push image to the ACR
  • Validate the uploaded image and the image tag

Azure Container Registry (ACR) is a private registry for container images. A private container registry lets you securely build and deploy your applications and custom code.

Login to the Azure portal using the command az login.

  • To create an Azure Container Registry, you first need a resource group.
  • An Azure resource group is a logical container into which Azure resources are deployed and managed.

Create a resource group with the az group create command. In the following example, a resource group named myResourceGroup is created in the eastus region:
az group create –name myResourceGroup –location eastus

Create an Azure Container Registry instance with the az acr create command and provide your own registry name. The registry name must be unique within Azure, and contain 5-50 alphanumeric characters. Provide your own unique registry name. The Basic SKU is a cost-optimized entry point for development purposes that provides a balance of storage and throughput.
az acr create –resource-group myResourceGroup –name ktACR1 –sku Basic

To use the ACR instance, you must first log in. Use the az acr login command and provide the unique name given to the container registry in the previous step. The command returns a Login Succeeded message once completed.
az acr login –name ktACR1

To see a list of your current local images, use the docker images command:

  • To use the azure-vote-frontcontainer image with ACR, the image needs to be tagged with the login server address of your registry.
  • This tag is used for routing when pushing container images to an image registry.

To get the login server address, use the az acr list command and query for the loginServer as follows:
Command: az acr list –resource-group myResourceGroup –query “[].{acrLoginServer:loginServer}” –output table

Now, tag your local azure-vote-front image with the acrloginServer address of the container registry. To indicate the image version, add :v1 to the end of the image name:
docker tag azure-vote-front ktacr1.azurecr.io/azure-vote-front:v1

To verify the tags are applied, run docker images again. An image is tagged with the ACR instance address and a version number.

With your image built and tagged, push the azure-vote-front image to your ACR instance. Use docker push and provide your own acrLoginServer address for the image name as follows:
docker push ktacr1.azurecr.io/azure-vote-front:v1

To return a list of images that have been pushed to your ACR instance, use the az acr repository listcommand. Provide your own acrName as follows.
az acr repository list –name ktACR1 –output table

To see the tags for a specific image, use the az acr repository show-tags command as follows:
az acr repository show-tags –name ktACR1 –repository azure-vote-front –output table

  • You now have a container image that is stored in a private Azure Container Registry instance.
  • This image is deployed from ACR to a Kubernetes cluster in the next part of the demo.

To go the part three of the demo, click here.