I have an on-premise K8s cluster that is connected to Azure via Arc. Also have a machine learning workspace that has this as an attached cluster. In my workspace, I have a model created. I created an endpoint in the workspace. Now I want to deploy to this endpoint to provision a scoring endpoint on-premise. But the deployment doesnt go anywhere.
Below is the code for endpoint creation which succeeded
from azure.ai.ml.entities import (
KubernetesOnlineEndpoint,
KubernetesOnlineDeployment,
Model,
Environment,
)
online_endpoint_name = "mnist-test-endpoint"
# create an online endpoint
endpoint = KubernetesOnlineEndpoint(
name=online_endpoint_name,
compute="onpremk8scompute",
description="mnist_test_endpoint",
auth_mode="key",
)
endpoint = ml_client.online_endpoints.begin_create_or_update(endpoint).result()
print(f"Endpoint {endpoint.name} provisioning state: {endpoint.provisioning_state}")
And the code for deployment to the end point
from azure.ai.ml.entities import (
KubernetesOnlineEndpoint,
KubernetesOnlineDeployment,
Model,
Environment,
CodeConfiguration,
ResourceRequirementsSettings,
ResourceSettings
)
model = ml_client.models.get("mnist_model_test", version=1)
model
deployment = KubernetesOnlineDeployment(
name="mnist-deployment-v1",
endpoint_name=online_endpoint_name,
model=model,
environment=Environment(
conda_file="08_conda_env.yml",
image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04",
),
code_configuration=CodeConfiguration(
code="./inference_script", scoring_script="score.py"
),
resources=ResourceRequirementsSettings(
requests=ResourceSettings(
cpu="100m",
memory="0.5Gi",
),
),
instance_count=1,
)
ml_client.begin_create_or_update(deployment).result()
This does not work. I also dont find any resources in the on-premise K8s namespace designated for this.
Ideas?
This might be due to the Kubernetes cluster being improperly set up to function with Azure Machine Learning.
Check the endpoint logs using the below commands
The above command will take a look at the deployment's logs to see whether there are errors or issues. restricting it from succeeding.
Also, check the status of deployment using the below command:
As a workaround, I followed this Document to create an online endpoint and deployments through python sdk for Kubernetes deployment.
You can use this Python code to attach an arc.
Code:
You can use the below code to create an online endpoint and deployments.
Code:
Output:
Portal:
Reference: Introduction to Kubernetes compute target in Azure Machine Learning - Azure Machine Learning | Microsoft Learn