update kubeflow dip-catalog

This commit is contained in:
ChanghoWoo
2025-01-13 02:31:27 +00:00
parent 1dc1181a03
commit 5451f16d72
1959 changed files with 602337 additions and 0 deletions
+23
View File
@@ -0,0 +1,23 @@
BENTOML_YATAI_IMAGE_BUILDER_VERSION ?= 1.2.28
BENTOML_YATAI_DEPLOYMENT_VERSION ?= 1.1.21
BENTOML_HELM_CHART_REPO ?= https://bentoml.github.io/helm-charts
.PHONY: bentoml-yatai-stack/bases
bentoml-yatai-stack/bases: clean-kustomize
mkdir -p bentoml-yatai-stack/bases/yatai-image-builder
cd bentoml-yatai-stack/bases/yatai-image-builder && helm template --skip-tests yatai-image-builder-crds yatai-image-builder-crds --repo ${BENTOML_HELM_CHART_REPO} --namespace kubeflow --version ${BENTOML_YATAI_IMAGE_BUILDER_VERSION} > resources.yaml
cd bentoml-yatai-stack/bases/yatai-image-builder && helm template --skip-tests -f ../../../sources/yatai-image-builder-values.yaml yatai-image-builder yatai-image-builder --repo ${BENTOML_HELM_CHART_REPO} --namespace kubeflow --version ${BENTOML_YATAI_IMAGE_BUILDER_VERSION} >> resources.yaml
cp sources/kustomization-template.yaml bentoml-yatai-stack/bases/yatai-image-builder/kustomization.yaml
mkdir -p bentoml-yatai-stack/bases/yatai-deployment
cd bentoml-yatai-stack/bases/yatai-deployment && helm template --skip-tests yatai-deployment-crds yatai-deployment-crds --repo ${BENTOML_HELM_CHART_REPO} --namespace kubeflow --version ${BENTOML_YATAI_DEPLOYMENT_VERSION} > resources.yaml
cd bentoml-yatai-stack/bases/yatai-deployment && helm template --skip-tests -f ../../../sources/yatai-deployment-values.yaml yatai-deployment yatai-deployment --repo ${BENTOML_HELM_CHART_REPO} --namespace kubeflow --version ${BENTOML_YATAI_DEPLOYMENT_VERSION} >> resources.yaml
cp sources/kustomization-template.yaml bentoml-yatai-stack/bases/yatai-deployment/kustomization.yaml
.PHONY: clean-kustomize
clean-kustomize:
rm -rf bentoml-yatai-stack/bases
.PHONY: test
test:
./test.sh
+3
View File
@@ -0,0 +1,3 @@
approvers:
- yubozhao
- juliusvonkohout
+86
View File
@@ -0,0 +1,86 @@
# BentoML on Kubeflow
Starting with the release of Kubeflow 1.7, BentoML provides a native integration with Kubeflow through [Yatai](https://github.com/bentoml/yatai-deployment). This integration allows you to package models trained in Kubeflow Notebooks or Pipelines as [Bentos](https://docs.bentoml.org/en/latest/concepts/bento.html), and deploy them as microservices in a Kubernetes cluster through BentoML's cloud native components and custom resource definitions (CRDs). This documentation provides a comprehensive guide on how to use BentoML and Kubeflow together to streamline the process of deploying models at scale.
## Requirements
* Kubernetes 1.20 - 1.25
## Installation
Run the following command to install BentoML Yatai. Note that the YAML assumes you will install in kubeflow namespace.
```bash
kustomize build bentoml-yatai-stack/default | kubectl apply -n kubeflow --server-side -f -
```
## Customizations
You can customize the container repository configurations and credentials for the `yatai-image-builder` operator to push Bento images to a container registry of your choice.
WARNING: The `yatai-image-builder` operator requires root privileges because it needs to access the Docker daemon, which requires elevated permissions. Granting root privileges can potentially be dangerous, as it can give a user unrestricted access to the underlying operating system.
```
dockerRegistry:
bentoRepositoryName: yatai-bentos
inClusterServer: docker-registry.kubeflow.svc.cluster.local:5000
password: ""
secure: false
server: 127.0.0.1:5000
username: ""
```
You can also supply AWS credentials for the `bento-image-builder` operator to download the Bento specified in the BentoRequest resource from S3.
```
aws:
accessKeyID: ''
secretAccessKey: ''
secretAccessKeyExistingSecretName: ''
secretAccessKeyExistingSecretKey: ''
```
Update the resources with the following command.
```bash
make bentoml-yatai-stack/bases
```
Re-install and apply resources.
```bash
kustomize build bentoml-yatai-stack/default | kubectl apply -n kubeflow --server-side -f -
```
## Upgrading
See [UPGRADE.md](UPGRADE.md)
## Why BentoML
[BentoML](https://github.com/bentoml/BentoML) is an open-source platform for building, shipping, and scaling AI applications.
- Building
- Unifies ML frameworks to run inference with any pre-trained models or bring your own
- Multi-model Inference graph support for complex AI solutions
- Python first framework that integrates with any ecosystem tooling
- Shipping
- Any environment, batch inference, streaming, or real-time serving
- Any public cloud for on-prem deployment
- Kubenetes native deployment
- Scaling
- Efficient resource utilization with autoscaling
- Adaptive batching for higher efficiency and throughput
- Distributed microservice architecture to run services on the most optimal hardware
## Workflow on Kubeflow Notebook
In this example, we will train three fraud detection models using the Kubeflow notebook and the [Kaggle IEEE-CIS Fraud Detection dataset](https://www.kaggle.com/c/ieee-fraud-detection). We will then create a BentoML service that can simultaneously invoke all three models and return a decision on whether a transaction is fraudulent and build it into a Bento. We will showcase two deployment workflows using BentoML's Kubernetes operators: deploying directly from the Bento, and deploying from an OCI image built from the Bento.
![image](https://raw.githubusercontent.com/bentoml/BentoML/main/docs/source/_static/img/kubeflow-fraud-detection.png)
See the [Fraud Detection Example](https://github.com/bentoml/BentoML/tree/main/examples/kubeflow) for a detailed workflow from model training to end-to-end deployment on Kubernetes.
## Workflow on Kubeflow Pipeline
This option will be available in Kubeflow release 1.8.
@@ -0,0 +1,35 @@
# Upgrading Documentation
## Updating manifests
In order to update manifests make sure you are running the commands in linux.
If you are running in another OS, please make sure to update the Makefile commands.
You can refresh the configuration by running:
```
make bentoml-yatai-stack/base
```
## Updating to specific version
Upgrading the version can be done by setting the `BENTOML_YATAI_STACK_VERSION` environment variable, such as:
```
# Set the desired version
export BENTOML_YATAI_IMAGE_BUILDER_VERSION=1.1.0
export BENTOML_YATAI_DEPLOYMENT_VERSION=1.1.0
# Rebuild the kustomize bases
make bentoml-yatai-stack/bases
# Run new manifests against cluster
kustomize build bentoml-yatai-stack/default | kubectl apply -f -
```
## Instructions for breaking changes
The [Yatai upgrading docs](https://docs.bentoml.org/projects/yatai) provide step by step overview of breaking changes across minor and patch versions.
@@ -0,0 +1,2 @@
resources:
- resources.yaml
@@ -0,0 +1,2 @@
resources:
- resources.yaml
@@ -0,0 +1,6 @@
# Adds namespace to all resources.
namespace: kubeflow
bases:
- ../bases/yatai-image-builder
- ../bases/yatai-deployment
@@ -0,0 +1,97 @@
apiVersion: resources.yatai.ai/v1alpha1
kind: Bento
metadata:
name: fraud-detection
namespace: kubeflow
spec:
image: docker.io/bentoml/fraud_detection:o5smnagbncigycvj
runners:
- name: ieee-fraud-detection-0
runnableType: XGBoost
- name: ieee-fraud-detection-1
runnableType: XGBoost
- name: ieee-fraud-detection-2
runnableType: XGBoost
tag: fraud_detection:o5smnagbncigycvj
---
apiVersion: serving.yatai.ai/v2alpha1
kind: BentoDeployment
metadata:
name: fraud-detection
namespace: kubeflow
spec:
autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
bento: fraud-detection
ingress:
enabled: false
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
runners:
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-0
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-1
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-2
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
@@ -0,0 +1,94 @@
apiVersion: resources.yatai.ai/v1alpha1
kind: BentoRequest
metadata:
name: fraud-detection
namespace: kubeflow
spec:
bentoTag: fraud_detection:o5smnagbncigycvj
downloadUrl: s3://bentoml.com/kubeflow/fraud_detection.bento
runners:
- name: ieee-fraud-detection-0
- name: ieee-fraud-detection-1
- name: ieee-fraud-detection-2
---
apiVersion: serving.yatai.ai/v2alpha1
kind: BentoDeployment
metadata:
name: fraud-detection
namespace: kubeflow
spec:
autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
bento: fraud-detection
ingress:
enabled: false
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
runners:
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-0
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-1
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
- autoscaling:
maxReplicas: 2
metrics:
- resource:
name: cpu
target:
averageUtilization: 80
type: Utilization
type: Resource
minReplicas: 1
name: ieee-fraud-detection-2
resources:
limits:
cpu: 1000m
memory: 1024Mi
requests:
cpu: 100m
memory: 200Mi
@@ -0,0 +1,2 @@
resources:
- resources.yaml
@@ -0,0 +1,20 @@
yataiSystem:
namespace: "kubeflow"
yatai:
endpoint: ''
layers:
network:
ingressClass: nginx
ingressAnnotations: {}
ingressPath: /
ingressPathType: ImplementationSpecific
domainSuffix: ''
automaticDomainSuffixGeneration: false
bentoDeploymentNamespaces: ["kubeflow"]
@@ -0,0 +1,13 @@
yataiSystem:
namespace: "kubeflow"
yatai:
endpoint: ''
dockerRegistry:
bentoRepositoryName: yatai-bentos
inClusterServer: docker-registry.kubeflow.svc.cluster.local:5000
password: ""
secure: false
server: 127.0.0.1:5000
username: ""
+440
View File
@@ -0,0 +1,440 @@
#!/bin/bash
set -xe
kubectl create ns kubeflow || echo "namespace kubeflow already exists"
kustomize build bentoml-yatai-stack/default | kubectl apply --server-side -f -
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/yatai-image-builder
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/yatai-deployment
sleep 5
kubectl apply -n kubeflow -f deployment_from_bento.yaml
sleep 5
kubectl -n kubeflow logs deploy/yatai-deployment
sleep 5
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/fraud-detection
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/fraud-detection-runner-0
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/fraud-detection-runner-1
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/fraud-detection-runner-2
kubectl -n kubeflow port-forward svc/fraud-detection 3333:3000 &
PID=$!
function trap_handler {
kill $PID
kubectl -n kubeflow logs -l yatai.ai/bento-deployment=fraud-detection --tail=100
kubectl -n kubeflow delete -f deployment_from_bento.yaml
kustomize build bentoml-yatai-stack/default | kubectl delete -f -
}
trap trap_handler EXIT
sleep 5
# FIXME: getting AttributeError: 'ColumnTransformer' object has no attribute '_name_to_fitted_passthrough'
# output=$(curl --fail -X 'POST' \
# 'http://localhost:3333/is_fraud' \
# -H 'accept: application/json' \
# -H 'Content-Type: application/json' \
# -d '[
# {
# "TransactionID": 2987000,
# "TransactionDT": 86400,
# "TransactionAmt": 68.5,
# "ProductCD": "W",
# "card1": 13926,
# "card2": null,
# "card3": 150,
# "card4": "discover",
# "card5": 142,
# "card6": "credit",
# "addr1": 315,
# "addr2": 87,
# "dist1": 19,
# "dist2": null,
# "P_emaildomain": null,
# "R_emaildomain": null,
# "C1": 1,
# "C2": 1,
# "C3": 0,
# "C4": 0,
# "C5": 0,
# "C6": 1,
# "C7": 0,
# "C8": 0,
# "C9": 1,
# "C10": 0,
# "C11": 2,
# "C12": 0,
# "C13": 1,
# "C14": 1,
# "D1": 14,
# "D2": null,
# "D3": 13,
# "D4": null,
# "D5": null,
# "D6": null,
# "D7": null,
# "D8": null,
# "D9": null,
# "D10": 13,
# "D11": 13,
# "D12": null,
# "D13": null,
# "D14": null,
# "D15": 0,
# "M1": "T",
# "M2": "T",
# "M3": "T",
# "M4": "M2",
# "M5": "F",
# "M6": "T",
# "M7": null,
# "M8": null,
# "M9": null,
# "V1": 1,
# "V2": 1,
# "V3": 1,
# "V4": 1,
# "V5": 1,
# "V6": 1,
# "V7": 1,
# "V8": 1,
# "V9": 1,
# "V10": 0,
# "V11": 0,
# "V12": 1,
# "V13": 1,
# "V14": 1,
# "V15": 0,
# "V16": 0,
# "V17": 0,
# "V18": 0,
# "V19": 1,
# "V20": 1,
# "V21": 0,
# "V22": 0,
# "V23": 1,
# "V24": 1,
# "V25": 1,
# "V26": 1,
# "V27": 0,
# "V28": 0,
# "V29": 0,
# "V30": 0,
# "V31": 0,
# "V32": 0,
# "V33": 0,
# "V34": 0,
# "V35": null,
# "V36": null,
# "V37": null,
# "V38": null,
# "V39": null,
# "V40": null,
# "V41": null,
# "V42": null,
# "V43": null,
# "V44": null,
# "V45": null,
# "V46": null,
# "V47": null,
# "V48": null,
# "V49": null,
# "V50": null,
# "V51": null,
# "V52": null,
# "V53": 1,
# "V54": 1,
# "V55": 1,
# "V56": 1,
# "V57": 0,
# "V58": 0,
# "V59": 0,
# "V60": 0,
# "V61": 1,
# "V62": 1,
# "V63": 0,
# "V64": 0,
# "V65": 1,
# "V66": 1,
# "V67": 1,
# "V68": 0,
# "V69": 0,
# "V70": 0,
# "V71": 0,
# "V72": 0,
# "V73": 0,
# "V74": 0,
# "V75": 1,
# "V76": 1,
# "V77": 1,
# "V78": 1,
# "V79": 0,
# "V80": 0,
# "V81": 0,
# "V82": 0,
# "V83": 0,
# "V84": 0,
# "V85": 0,
# "V86": 1,
# "V87": 1,
# "V88": 1,
# "V89": 0,
# "V90": 0,
# "V91": 0,
# "V92": 0,
# "V93": 0,
# "V94": 0,
# "V95": 0,
# "V96": 1,
# "V97": 0,
# "V98": 0,
# "V99": 0,
# "V100": 0,
# "V101": 0,
# "V102": 1,
# "V103": 0,
# "V104": 0,
# "V105": 0,
# "V106": 0,
# "V107": 1,
# "V108": 1,
# "V109": 1,
# "V110": 1,
# "V111": 1,
# "V112": 1,
# "V113": 1,
# "V114": 1,
# "V115": 1,
# "V116": 1,
# "V117": 1,
# "V118": 1,
# "V119": 1,
# "V120": 1,
# "V121": 1,
# "V122": 1,
# "V123": 1,
# "V124": 1,
# "V125": 1,
# "V126": 0,
# "V127": 117,
# "V128": 0,
# "V129": 0,
# "V130": 0,
# "V131": 0,
# "V132": 0,
# "V133": 117,
# "V134": 0,
# "V135": 0,
# "V136": 0,
# "V137": 0,
# "V138": null,
# "V139": null,
# "V140": null,
# "V141": null,
# "V142": null,
# "V143": null,
# "V144": null,
# "V145": null,
# "V146": null,
# "V147": null,
# "V148": null,
# "V149": null,
# "V150": null,
# "V151": null,
# "V152": null,
# "V153": null,
# "V154": null,
# "V155": null,
# "V156": null,
# "V157": null,
# "V158": null,
# "V159": null,
# "V160": null,
# "V161": null,
# "V162": null,
# "V163": null,
# "V164": null,
# "V165": null,
# "V166": null,
# "V167": null,
# "V168": null,
# "V169": null,
# "V170": null,
# "V171": null,
# "V172": null,
# "V173": null,
# "V174": null,
# "V175": null,
# "V176": null,
# "V177": null,
# "V178": null,
# "V179": null,
# "V180": null,
# "V181": null,
# "V182": null,
# "V183": null,
# "V184": null,
# "V185": null,
# "V186": null,
# "V187": null,
# "V188": null,
# "V189": null,
# "V190": null,
# "V191": null,
# "V192": null,
# "V193": null,
# "V194": null,
# "V195": null,
# "V196": null,
# "V197": null,
# "V198": null,
# "V199": null,
# "V200": null,
# "V201": null,
# "V202": null,
# "V203": null,
# "V204": null,
# "V205": null,
# "V206": null,
# "V207": null,
# "V208": null,
# "V209": null,
# "V210": null,
# "V211": null,
# "V212": null,
# "V213": null,
# "V214": null,
# "V215": null,
# "V216": null,
# "V217": null,
# "V218": null,
# "V219": null,
# "V220": null,
# "V221": null,
# "V222": null,
# "V223": null,
# "V224": null,
# "V225": null,
# "V226": null,
# "V227": null,
# "V228": null,
# "V229": null,
# "V230": null,
# "V231": null,
# "V232": null,
# "V233": null,
# "V234": null,
# "V235": null,
# "V236": null,
# "V237": null,
# "V238": null,
# "V239": null,
# "V240": null,
# "V241": null,
# "V242": null,
# "V243": null,
# "V244": null,
# "V245": null,
# "V246": null,
# "V247": null,
# "V248": null,
# "V249": null,
# "V250": null,
# "V251": null,
# "V252": null,
# "V253": null,
# "V254": null,
# "V255": null,
# "V256": null,
# "V257": null,
# "V258": null,
# "V259": null,
# "V260": null,
# "V261": null,
# "V262": null,
# "V263": null,
# "V264": null,
# "V265": null,
# "V266": null,
# "V267": null,
# "V268": null,
# "V269": null,
# "V270": null,
# "V271": null,
# "V272": null,
# "V273": null,
# "V274": null,
# "V275": null,
# "V276": null,
# "V277": null,
# "V278": null,
# "V279": 0,
# "V280": 0,
# "V281": 0,
# "V282": 1,
# "V283": 1,
# "V284": 0,
# "V285": 0,
# "V286": 0,
# "V287": 0,
# "V288": 0,
# "V289": 0,
# "V290": 1,
# "V291": 1,
# "V292": 1,
# "V293": 0,
# "V294": 1,
# "V295": 0,
# "V296": 0,
# "V297": 0,
# "V298": 0,
# "V299": 0,
# "V300": 0,
# "V301": 0,
# "V302": 0,
# "V303": 0,
# "V304": 0,
# "V305": 1,
# "V306": 0,
# "V307": 117,
# "V308": 0,
# "V309": 0,
# "V310": 0,
# "V311": 0,
# "V312": 0,
# "V313": 0,
# "V314": 0,
# "V315": 0,
# "V316": 0,
# "V317": 117,
# "V318": 0,
# "V319": 0,
# "V320": 0,
# "V321": 0,
# "V322": null,
# "V323": null,
# "V324": null,
# "V325": null,
# "V326": null,
# "V327": null,
# "V328": null,
# "V329": null,
# "V330": null,
# "V331": null,
# "V332": null,
# "V333": null,
# "V334": null,
# "V335": null,
# "V336": null,
# "V337": null,
# "V338": null,
# "V339": null
# }
# ]')
# echo "output: '${output}'"
# if [[ $output != *'false'* ]]; then
# echo "Test failed"
# exit 1
# fi