Kubernetes Registry for Azure Container Instances (ACI)

JFrog ArtifactoryIntegrated in Microsoft ACI

What is an Azure Container Instance?

Microsoft Azure Container Instances (ACI) offers users a fast and simple way to deploy container applications in the cloud without provisioning virtual machines or having to adopt a higher-level service. Using ACI, you can scale and orchestrate operations by deploying a Docker container that pulls a Docker image from JFrog Artifactory, while providing the advantages of fast startup and billing granularity of one second.

ACI, like all container runtimes,requires a container registryto pull from. When trying to understand the provenance and security of the containers you’re running, JFrog Artifactory can help as yourKubernetes Registry. Artifactory serves as a single access point for organizing all your binary resources. Having a single source of truth for repositories eliminates the complexity associated with managing multiple repositories for your builds, open source libraries, and other 3rd party components.This blog post shows how to integrate Artifactory with ACI.

Why Use Artifactory as Your Kubernetes Registry?

JFrog Artifactorydelivers your software quickly with confidence as it supports:

Integrating Artifactory with Azure Container Instances

To demonstrate the integration of ACI and Artifactory, we will:

  • Use Jenkins to build an NPM package of a simpleNode.jsapp
  • Build the NPM into a Docker image and push to alocal Docker repository managed by Artifactory
  • Deploy the container to ACI by pulling the Docker image from the virtual Docker repository using the Azure CLI.

Prerequisites: Get Jenkins and Artifactory up and running

You can skip these steps if you already have Jenkins and Artifactory.

  1. Get Jenkins running with thisgetting started, and then configure your firstnpm pipelinefor practice.
  2. Start an Artifactory trial and chooseAzure(Cloud), orget a trial license并安装它自己。

Step 1: Create a Jenkins job to build a node app

Follow the steps in this tutorialtoconfigure a Jenkins jobto build a sample Node.js app. This application starts simple node servers and displays a page that displays the package version.

Build a sample Node.js app

Step 2: Configure Artifactory to serve as a Docker registry

To learn more about usingArtifactoryas a Docker Registry, clickhere.

Create the following Docker repositories in Artifactory:

3: Create a Jenkins pipeline

Create a Jenkins pipeline to build and push the Docker image to Artifactory.

1.Log in to Jenkins by using your Jenkins credentials.

2.Add the following parameters:

  • ART_SERVER_URL: Artifactory Server URL
  • ART_DOCKER_REGISTRY: Artifactory Docker Registry name
  • CREDENTIAL_ID: Artifactory Credentials ID

3. Create a new Jenkins pipeline job.

4.Copy theJenkins filefrom theGitHub example repoto the pipeline script, and clickBuild Now.

5.Check your newly published Docker image in Artifactory.

Push Docker Image to Artifactory

Step 4: Deploy the Docker Image to Azure ACI

1.Install Azure CLI.

2. Create a resource group.

az group create --name myResourceGroup --location eastus

The command creates a group namedmyResourceGroupat theeastuslocation.

View the output.

Location Name-------------------eastus myResourceGroup


3. Deploy the container to ACI by pulling the Docker image from Artifactory.

az container create --name mycontainer --imagejfrogtraining-docker-dev.jfrog.io/node-version:latest --registry-login-server jfrogtraining-docker-dev.jfrog.io --registry-password $ARTIFACTORY_PASSWORD --registry-username jainishs --resource-group myResourceGroup --ip-address public --port 3000 --memory 1


4. Get the container public IP address.

az container show --name mycontainer --resource-group myResourceGroup --query ipAddress.ip

View the output.

Result -------------40.71.201.235


5. Access the
mycontainercontainer using the IP address provided in the output of step 4. In our example, we usedhttps://40.71.201.235:3000.
6. View the running container logs.

az container logs --name mycontainer --resource-group myResourceGroup

View the output.

> node-version@2.2.13 start /usr/src/app > node ./bin/www GET / 200 158.680 ms - 260 GET /stylesheets/style.css 200 4.370 ms - 111 GET /images/images.png 200 1.803 ms - 6146 GET /favicon.ico 404 22.916 ms - 970p


Congratulations!

You now have a simple pipeline that builds aNode.jsapp, manages the NPM package in Artifactory, and then builds a Docker container stored in Artifactory, with traceability between the packages. This allows you to run the container quickly in an Azure Container Instance with confidence while knowing what it includes and whence it came.