Skip to content
This repository was archived by the owner on Nov 16, 2023. It is now read-only.

Commit 7ca9e53

Browse files
authored
Merge pull request #106 from NealAnalyticsLLC/mlflow-on-azure-stack
Mlflow on azure stack
2 parents 65abce6 + 3b48d56 commit 7ca9e53

File tree

19 files changed

+631
-110
lines changed

19 files changed

+631
-110
lines changed
Lines changed: 7 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
# MLflow and Kubeflow Installation On Kubernetes
22

3-
This guide demonstrates how to install a remote MLflow Tracking Server on Kubernetes. The instructions below demonstrate how to install using a Cloud Native Application Bundle (CNAB). Please see the document referenced below for manual installation instructions.
3+
This guide demonstrates how to install a remote MLflow Tracking Server & Kubeflow on Kubernetes. The instructions below demonstrate how to install using a Cloud Native Application Bundle (CNAB). Please see the document referenced below for manual installation instructions.
44

55
**Reference Material:**
6-
- [Manual Installation Instructions](./docs/manual_installation.md)
6+
- [Manual Installation Instructions for Mlflow](./docs/manual_installation.md)
7+
- [Manual Installation Instructions for Kubeflow](/Research/kubeflow-on-azure-stack/Readme.md)
78

89
**Prerequisite:**
910
- Will need the k8 cluster ".kubeconfig" file on your local machine to execute commands on the k8 cluster
@@ -17,95 +18,8 @@ Make sure you have Porter installed. You can find the installation instructions
1718

1819
**NOTE:** be sure to add porter to your PATH so it can find the binaries
1920

21+
## Step 2 : Install CNAB Packages
22+
We have CNAB packages for Kubeflow & MLFlow, use any of the below link to install
2023

21-
## Step 2: Build Porter CNAB
22-
First you will need to navigate to porter directory in the repository. For example
23-
24-
```sh
25-
cd ./research/mlflow-on-azure-stack/porter
26-
```
27-
Change the file permissions
28-
29-
```sh
30-
chmod 777 mlflow.sh
31-
chmod 777 kubeflow.sh
32-
```
33-
Next, you will build the porter CNAB
34-
35-
```sh
36-
porter build
37-
```
38-
39-
## Step 3: Generate Credentials
40-
This step is needed to connect to your Kubernetes cluster
41-
42-
```sh
43-
porter credentials generate
44-
```
45-
Enter path to your kubeconfig file when prompted
46-
47-
Validate that your credential is present by running the below command. You should see something like the below output.
48-
```sh
49-
porter credentials list
50-
```
51-
52-
![List Porter Credentials](./docs/img/porter-credentials-validate.png)
53-
54-
55-
## Step 4: Use Porter CNAB
56-
Run one of the below commands to interact with the CNAB
57-
58-
```sh
59-
porter install --cred MLServicesInstaller
60-
porter upgrade --cred MLServicesInstaller
61-
porter uninstall --cred MLServicesInstaller
62-
```
63-
### Step 5: Check for pods and services
64-
After the installation each of the services gets installed into its own namespace, try below commands to look for pods and services:
65-
66-
```sh
67-
kubectl get pods -n mlflow
68-
kubectl get pods -n kubeflow
69-
```
70-
### Step 6: Opening Kubeflow dashboard
71-
To access the dashboard using external connection, replace "type: NodePort" with "type: LoadBalancer" using the patch command:
72-
73-
```sh
74-
$ kubectl patch svc/istio-ingressgateway -p '{"spec":{"type": "LoadBalancer"}}' -n istio-system
75-
service/istio-ingressgateway patched
76-
```
77-
Then the EXTERNAL-IP will become available from:
78-
79-
```sh
80-
$ kubectl get -w -n istio-system svc/istio-ingressgateway
81-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
82-
istio-ingressgateway LoadBalancer 10.0.123.210 12.34.56.78 15020:30397/TCP,80:31380/TCP,.. 7m27s
83-
```
84-
![Kubeflow dashboard](./docs/img/kubeflow_dashboard1.png)
85-
86-
Use external-ip to open it in your browser, and make sure your firewall rules allow HTTP port 80.
87-
88-
You can monitor Kubeflow cluster by looking at the Kubernetes status, you might need to wait to let the pods create containers and start.
89-
90-
For more information see [Installing Kubeflow on Azure](https://www.kubeflow.org/docs/azure/deploy/install-kubeflow/)
91-
92-
### Step 7: Opening MLflow dashboard
93-
To access the dashboard using external connection, first we need to get the external-ip:
94-
95-
```sh
96-
$ kubectl get svc -n mlflow
97-
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
98-
mlflow-service LoadBalancer 10.0.176.78 52.250.47.209 5000:31148/TCP 19m
99-
```
100-
Use external-ip to open it in your browser, and make sure your firewall rules allow HTTP port 5000.
101-
102-
![MLflow dashboard](./docs/img/mlflow_dashboard.png)
103-
104-
### Step 8: Creating a Notebook Server
105-
106-
From the Kubeflow dashboard select "Notebook Servers". Pick the namespace you want to create the server under and select "+ New Server".
107-
108-
Enter the desired specs for your server. Make sure the "Custom Image" checkbox is select and input `naedwebs/jupyter-mlflow` in the text field for this option. Click "Launch".
109-
### Step 9: Upload a Notebook
110-
111-
Once your server is running click "Connect". A Jupyter Notebook landing page should load on a new tab. On the right hand side of this page push the "Upload" button and select the MLflow_Tutorial notebook found in the notebooks folder in this repository and hit open. Click the blue "Upload" button that has just appeard. Select the notebook to run it.
24+
- [Link to Kubeflow](https://github.com/NealAnalyticsLLC/azure-intelligent-edge-patterns/blob/mlflow-on-azure-stack/Research/mlflow-on-azure-stack/porter/kubeflow/Readme.md)
25+
- [Link to MLFlow](https://github.com/NealAnalyticsLLC/azure-intelligent-edge-patterns/blob/mlflow-on-azure-stack/Research/mlflow-on-azure-stack/porter/mlflow/Readme.md)

Research/mlflow-on-azure-stack/notebooks/MLflow_Tutorial.ipynb

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,8 @@
8383
" - scikit-learn=0.19.1\n",
8484
" - pip\n",
8585
" - pip:\n",
86-
" - mlflow"
86+
" - mlflow\n",
87+
" - pysftp"
8788
]
8889
},
8990
{
@@ -364,8 +365,6 @@
364365
" return rmse, mae, r2\n",
365366
"\n",
366367
"if __name__ == \"__main__\":\n",
367-
" remote_server_uri = \"http://mlflow-service.mlflow:5000\" # set to your server URI\n",
368-
" mlflow.set_tracking_uri(remote_server_uri)\n",
369368
" mlflow.set_experiment(\"demo-experiment\")\n",
370369
" diabetes = datasets.load_diabetes()\n",
371370
" X = diabetes.data\n",
@@ -393,7 +392,6 @@
393392
" print(\" MAE: %s\" % mae)\n",
394393
" print(\" R2: %s\" % r2)\n",
395394
"\n",
396-
" start_run()\n",
397395
" set_tag(\"author\", \"name\")\n",
398396
" set_tag(\"description\", \"tutorial data based on the diabetes data set using an elastic net model\")\n",
399397
" log_param(\"alpha\", alpha)\n",
@@ -406,8 +404,7 @@
406404
" eps = 5e-3 # the smaller it is the longer is the path\n",
407405
"\n",
408406
" print(\"Computing regularization path using the elastic net.\")\n",
409-
" alphas_enet, coefs_enet, _ = enet_path(X, y, eps=eps, l1_ratio=l1_ratio, fit_intercept=False)\n",
410-
" mlflow.end_run()"
407+
" alphas_enet, coefs_enet, _ = enet_path(X, y, eps=eps, l1_ratio=l1_ratio, fit_intercept=False)"
411408
]
412409
},
413410
{
@@ -452,19 +449,30 @@
452449
]
453450
},
454451
{
455-
"cell_type": "markdown",
452+
"cell_type": "code",
453+
"execution_count": null,
456454
"metadata": {},
455+
"outputs": [],
457456
"source": [
458-
"# STOP HERE - CODE BELOW IS STILL IN DEVELOPMENT"
457+
"%env MLFLOW_TRACKING_URI=http://mlflow-service.mlflow:5000"
459458
]
460459
},
461460
{
462-
"cell_type": "markdown",
461+
"cell_type": "code",
462+
"execution_count": null,
463463
"metadata": {},
464+
"outputs": [],
464465
"source": [
465466
"%%bash\n",
466467
"\n",
467-
"mlflow run . -P alpha=0.6"
468+
"mlflow run . -P alpha=0.6 --experiment-name demo-experiment"
469+
]
470+
},
471+
{
472+
"cell_type": "markdown",
473+
"metadata": {},
474+
"source": [
475+
"# STOP HERE - CODE BELOW IS STILL IN DEVELOPMENT"
468476
]
469477
},
470478
{
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# MLflow and Kubeflow Installation On Kubernetes
2+
3+
This guide demonstrates how to install a remote MLflow Tracking Server & Kubeflow on Kubernetes. The instructions below demonstrate how to install using a Cloud Native Application Bundle (CNAB). Please see the document referenced below for manual installation instructions.
4+
5+
**Reference Material:**
6+
- [Manual Installation Instructions for Mlflow](./docs/manual_installation.md)
7+
- [Manual Installation Instructions for Kubeflow](/Research/kubeflow-on-azure-stack/Readme.md)
8+
9+
**Prerequisite:**
10+
- Will need the k8 cluster ".kubeconfig" file on your local machine to execute commands on the k8 cluster
11+
- Below instructions are not intended to be run from the master node, but from another Linux dev environment
12+
- Clone the github repo at "/home/user/" path
13+
14+
## Step 1: Install Porter
15+
Make sure you have Porter installed. You can find the installation instructions for your OS at the link provided below.
16+
17+
[Porter Installation Instructions](https://porter.sh/install/)
18+
19+
**NOTE:** be sure to add porter to your PATH so it can find the binaries
20+
21+
## Step 2 : Install CNAB Packages
22+
We have CNAB packages for Kubeflow & MLFlow, use any of the below link to install
23+
24+
- [Link to Kubeflow](https://github.com/NealAnalyticsLLC/azure-intelligent-edge-patterns/blob/mlflow-on-azure-stack/Research/mlflow-on-azure-stack/porter/kubeflow/Readme.md)
25+
- [Link to MLFlow](https://github.com/NealAnalyticsLLC/azure-intelligent-edge-patterns/blob/mlflow-on-azure-stack/Research/mlflow-on-azure-stack/porter/mlflow/Readme.md)

Research/mlflow-on-azure-stack/porter/kubeflow.sh renamed to Research/mlflow-on-azure-stack/porter/MLflow & Kubeflow/kubeflow.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ uninstall() {
5353
wget ${KF_CONFIG_URI}
5454
ls -la
5555
cat $KF_CONFIG_FILENAME
56-
$KF_CTL_DIR/kfctl delete -f ${KF_DIR}/${KF_CONFIG_FILENAME}
56+
$KF_CTL_DIR/kfctl delete -f ${KF_DIR}/${KF_CONFIG_FILENAME} --force-deletion
5757
}
5858

5959
# Call the requested function and pass the arguments as-is

Research/mlflow-on-azure-stack/porter/porter.yaml renamed to Research/mlflow-on-azure-stack/porter/MLflow & Kubeflow/porter.yaml

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# This is the configuration for Porter
22

3-
name: MLServicesInstaller
3+
name: MLServiceInstaller
44
version: 1.0
55
description: "Installer for ML Services on Azure Stack. Installs Kubeflow and MLflow"
66
# TODO: update the registry to your own, e.g. myregistry/porter-mlflow:v1.0
@@ -13,6 +13,10 @@ mixins:
1313
- exec
1414
- kubernetes
1515

16+
credentials:
17+
- name: kubeconfig
18+
path: /root/.kube/config
19+
1620
parameters:
1721
- name: kf_ctl_dir
1822
type: string
@@ -46,10 +50,6 @@ parameters:
4650
type: string
4751
default: "https://raw.githubusercontent.com/kubeflow/manifests/v1.0-branch/kfdef/kfctl_k8s_istio.v1.0.2.yaml"
4852

49-
credentials:
50-
- name: kubeconfig
51-
path: /root/.kube/config
52-
5353
install:
5454
- exec:
5555
description: "Install mlflow"
@@ -80,8 +80,9 @@ uninstall:
8080
command: ./mlflow.sh
8181
arguments:
8282
- "uninstall"
83+
8384
- exec:
8485
description: "Uninstall Kubeflow"
8586
command: ./kubeflow.sh
8687
arguments:
87-
- "uninstall"
88+
- "uninstall"
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
FROM debian:stretch
2+
ARG BUNDLE_DIR
3+
RUN apt-get update && apt-get install -y ca-certificates
4+
RUN apt-get install -y wget
5+
# Use the BUNDLE_DIR build argument to copy files into the bundle
6+
COPY . $BUNDLE_DIR
7+
RUN apt-get update && \
8+
apt-get install -y apt-transport-https curl && \
9+
curl -o kubectl https://storage.googleapis.com/kubernetes-release/release/v1.15.5/bin/linux/amd64/kubectl && \
10+
mv kubectl /usr/local/bin && \
11+
chmod a+x /usr/local/bin/kubectl
12+
13+
# exec mixin has no buildtime dependencies
14+
15+
RUN rm -fr $BUNDLE_DIR/.cnab
16+
COPY .cnab /cnab
17+
COPY porter.yaml $BUNDLE_DIR/porter.yaml
18+
WORKDIR $BUNDLE_DIR
19+
CMD ["/cnab/app/run"]
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
FROM debian:stretch
2+
ARG BUNDLE_DIR
3+
RUN apt-get update && apt-get install -y ca-certificates
4+
RUN apt-get install -y wget
5+
# Use the BUNDLE_DIR build argument to copy files into the bundle
6+
COPY . $BUNDLE_DIR

0 commit comments

Comments
 (0)