Fairing on Azure
This page documents how to run the Fairing prediction examplenotebook on in a notebook hosted on Kubeflow.
Before you configure and use the Kubeflow Fairing Python SDK, you must have aKubeflow environment installed. The example notebook does in-cluster training.The example notebook has been tested to work in a cluster with 2 nodes andvirtual machines with Standard_D4_v3 size. It is not recommended to use thesmallest size virtual machines.
- If you do not have a Kubeflow installation on Azure, follow the installationguide.
- You must have the command line interface installed and configuredto use the Kubernetes cluster where Kubeflow is installed. In the aboveinstallation guide, the command
az aks get-credentials
configureskubectl
to access your Kubernetes cluster.
Create Azure Container Registry and Storage
The example notebook uses Azure Container Registry (ACR) to host dockerimages for deployment and Azure Storage (Storage) is used as build context forin-cluster building.
You can re-use existing ACR and Storage resources or create new ones. For moreinformation, see the documentation for ACR and.
After you have created your ACR and Storage resources, you must configure aservice principal with access to these resources. If you want to use the sameservice principal as your AKS cluster, you can get the service principal IDwith the following command:
The above command has output like this:
"clientId": "<id>"
},
The role you grant must have at least read and write permissions to ACR andStorage.
To learn more about how to grant the service principal access, follow theAzure role-based authentication documentation.
Run the following commands to set up your credentials as a Kubernetes secret.
- Set environment variables to use in the following commands.
- AZ_CLIENT_ID: The service principal client ID. You can get the
client_id
property from ~/.azure/aksServicePrincipal.json. - AZ_CLIENT_SECRET: The service principal secret. You can get the
client_secret
property from ~/.azure/aksServicePrincipal.json. - AZ_TENANT_ID: The Azure Tenant ID of your account. You can get theTenant ID from the field in the output of
az account show
. - AZ_SUBSCRIPTION: The Azure Subscription ID of your account. You canget the Subscription ID from the
id
field in the output ofaz accountshow
. - TARGET_NAMESPACE: Specify the namespace that your Notebook Server isin. For example, this guide recommends using
kubeflow-anonymous
. - ACR_NAME: The name of an ACR that the service principal can access.
kubectl create secret generic -n ${TARGET_NAMESPACE} azcreds \
--from-literal=AZ_CLIENT_ID=${AZ_CLIENT_ID} \
--from-literal=AZ_CLIENT_SECRET=${AZ_CLIENT_SECRET} \
--from-literal=AZ_SUBSCRIPTION_ID=${AZ_SUBSCRIPTION_ID}
- Use the following command to create a secret that Kubeflow can use to accessACR.
Creating a Notebook Server in Kubeflow
To create a notebook server, use your Web browser to access the KubeflowCentral Dashboard and select the Notebook Servers panel from the menu.
First, select the target namespace in which you want to host the server. In thedefault Kubeflow installation, there should be a namespace kubeflow-anonymous
available in the namespace drop-down menu.
After the target namespace is selected, click NEW SERVER and fill in themandatory fields. The fields with default values can all be left as theyare and do not have to be modified to run the example notebook.
After launching the server, wait for the CONNECT button to appear and clickCONNECT to launch your Notebook Server. It may take up to a minute for theserver to be ready for connections.
Clone the Kubeflow Fairing repository to download the files used in this example.
Connect to your notebook server, then click the new terminal optionlike in the screenshot below:
Run the following command to clone the Kubeflow Fairing project:
git clone https://github.com/kubeflow/fairing.git
You can now close the terminal window, and you should now see the fairing
folderin your notebooks server’s Files tab. Navigate to the example notebooks atfairing/examples/prediction/xgboost-high-level-apis.ipynb
.
Executing the notebook
Before running the cells, read the following to learn how to configure Fairingto use your Azure resources.
In the xgboost-high-level-apis.ipynb
notebook, find the cell tagged withparameters
and update this cell to use Azure. Update following values toconfigure Fairing to use your Azure backend and Storage.
After the above steps have been completed, you can run the example notebook.
You can also have a look at the that runs theexample notebook in AKS for steps involved to accomplish a successful runprogrammatically.
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please .