Home

Awesome

Author: Hong Ooi

Real-time model deployment with R using Azure Container Registry and Azure Kubernetes Service

Overview

This repository hosts deployment artifacts for the reference architecture "Real-time model deployment with R". You can use these artifacts to deploy a containerised predictive service in Azure.

Design

The workflow in this repository builds a sample machine learning model: a random forest for housing prices, using the Boston housing dataset that ships with R. It then builds a Docker image with the components to host a predictive service:

This image is pushed to a Docker registry hosted in Azure, and then deployed to a Kubernetes cluster, also in Azure.

Prerequisites

To use this repository, you will need the following:

Setup

Edit the file resource_specs.R to contain the following:

Deployment steps

Building the model image

The script 00_train_model.R trains a simple model (a random forest for house prices, using the Boston dataset), and saves the model object to a .RDS file. This step is optional, as the repository already contains a suitable model object.

Creating the Azure resources

The script 01_create_resources.R creates the necessary Azure resources for the deployment. Note that creating an AKS cluster can take several minutes.

Installing an ingress controller

The script 02_install_ingress.R installs the Traefik reverse proxy on the Kubernetes cluster and sets the cluster's domain name.

Deploying the service

The script 03_deploy_service.R pushes the model image to Azure, and deploys the predictive service.

Testing the service

The script 04_test_service.R tests that the service works properly, by sending a request to the API endpoint; you can check that the responses are as expected.