Skip to content

Commit

Permalink
feat: add bentoml yatai stack contrib
Browse files Browse the repository at this point in the history
  • Loading branch information
yetone committed Dec 22, 2022
1 parent 610f970 commit 7f4cd86
Show file tree
Hide file tree
Showing 19 changed files with 14,010 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/bentoml_kind_test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Build & Apply BentoML Yatai Stack manifests in KinD
on:
pull_request:
paths:
- contrib/bentoml/**

jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Install KinD
run: ./tests/gh-actions/install_kind.sh

- name: Create KinD Cluster
run: kind create cluster --config tests/gh-actions/kind-cluster-1-24.yaml

- name: Install kustomize
run: ./tests/gh-actions/install_kustomize.sh

- name: Install cert-manager
run: ./tests/gh-actions/install_cert_manager.sh

- name: Build & Apply manifests
run: |
cd contrib/bentoml/
make test
38 changes: 38 additions & 0 deletions contrib/bentoml/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
BENTOML_YATAI_IMAGE_BUILDER_VERSION ?= 1.1.0-d12
BENTOML_YATAI_DEPLOYMENT_VERSION ?= 1.1.0-d12

.PHONY: bentoml-yatai-stack/bases
bentoml-yatai-stack/bases: clean-kustomize
mkdir -p bentoml-yatai-stack/bases/docker-registry
cd bentoml-yatai-stack/bases/docker-registry && helm template docker-registry docker-registry --repo https://helm.twun.io --namespace kubeflow > resources.yaml
cp sources/docker-registry-kustomization-template.yaml bentoml-yatai-stack/bases/docker-registry/kustomization.yaml
cp sources/docker-private-registry-proxy.yaml bentoml-yatai-stack/bases/docker-registry/
mkdir -p bentoml-yatai-stack/bases/yatai-image-builder
cd bentoml-yatai-stack/bases/yatai-image-builder && helm template --skip-tests --include-crds -f ../../../sources/yatai-image-builder-values.yaml yatai-image-builder yatai-image-builder --repo https://bentoml.github.io/helm-charts-devel --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 --include-crds -f ../../../sources/yatai-deployment-values.yaml yatai-deployment yatai-deployment --repo https://bentoml.github.io/helm-charts-devel --namespace kubeflow --version ${BENTOML_YATAI_DEPLOYMENT_VERSION} > resources.yaml
sed -i "s/namespace: 'yatai-deployment'/namespace: kubeflow/" bentoml-yatai-stack/bases/yatai-deployment/resources.yaml
sed -i "s/cert-manager.io\/inject-ca-from: 'yatai-deployment\/yatai-deployment-serving-cert'/cert-manager.io\/inject-ca-from: 'kubeflow\/yatai-deployment-serving-cert'/" bentoml-yatai-stack/bases/yatai-deployment/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:
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 example.yaml
sleep 5
kubectl -n kubeflow logs deploy/yatai-deployment
sleep 5
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/test-yatai
kubectl -n kubeflow wait --for=condition=available --timeout=600s deploy/test-yatai-runner-0
kubectl delete -n kubeflow -f example.yaml
kustomize build bentoml-yatai-stack/default | kubectl delete -f -

3 changes: 3 additions & 0 deletions contrib/bentoml/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
approvers:
- yetone
- yubozhao
19 changes: 19 additions & 0 deletions contrib/bentoml/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# BentoML Yatai Stack

[BentoML Yatai Stack](https://github.com/bentoml/yatai-deployment) is a series of components for deploying models/bentos to Kubernetes at scale

## Requirements

* Kubernetes 1.20 - 1.24

## Installation

* The yaml assumes you will install in kubeflow namespace

```bash
kustomize build bentoml-yatai-stack/default | kubectl apply -n kubeflow --server-side -f -
```

## Upgrating

See [UPGRADE.md](UPGRADE.md)
35 changes: 35 additions & 0 deletions contrib/bentoml/UPGRADE.md
Original file line number Diff line number Diff line change
@@ -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.


Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
apiVersion: apps/v1
kind: DaemonSet
metadata:
name: docker-private-registry-proxy
namespace: kubeflow
labels:
app: docker-private-registry-proxy
spec:
selector:
matchLabels:
app: docker-private-registry-proxy
template:
metadata:
creationTimestamp: null
labels:
app: docker-private-registry-proxy
spec:
containers:
- args:
- tcp
- "5000"
- docker-registry.kubeflow.svc.cluster.local
image: quay.io/bentoml/proxy-to-service:v2
name: tcp-proxy
ports:
- containerPort: 5000
hostPort: 5000
name: tcp
protocol: TCP
resources:
limits:
cpu: 100m
memory: 100Mi

Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
resources:
- resources.yaml
- docker-private-registry-proxy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
---
# Source: docker-registry/templates/secret.yaml
apiVersion: v1
kind: Secret
metadata:
name: docker-registry-secret
namespace: kubeflow
labels:
app: docker-registry
chart: docker-registry-2.2.2
heritage: Helm
release: docker-registry
type: Opaque
data:
haSharedSecret: "bFJTRTJISnFuU1lDOWRGOA=="
proxyUsername: ""
proxyPassword: ""
---
# Source: docker-registry/templates/configmap.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: docker-registry-config
namespace: kubeflow
labels:
app: docker-registry
chart: docker-registry-2.2.2
heritage: Helm
release: docker-registry
data:
config.yml: |-
health:
storagedriver:
enabled: true
interval: 10s
threshold: 3
http:
addr: :5000
debug:
addr: :5001
prometheus:
enabled: false
path: /metrics
headers:
X-Content-Type-Options:
- nosniff
log:
fields:
service: registry
storage:
cache:
blobdescriptor: inmemory
version: 0.1
---
# Source: docker-registry/templates/service.yaml
apiVersion: v1
kind: Service
metadata:
name: docker-registry
namespace: kubeflow
labels:
app: docker-registry
chart: docker-registry-2.2.2
release: docker-registry
heritage: Helm
spec:
type: ClusterIP
ports:
- port: 5000
protocol: TCP
name: http-5000
targetPort: 5000
selector:
app: docker-registry
release: docker-registry
---
# Source: docker-registry/templates/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: docker-registry
namespace: kubeflow
labels:
app: docker-registry
chart: docker-registry-2.2.2
release: docker-registry
heritage: Helm
spec:
selector:
matchLabels:
app: docker-registry
release: docker-registry
replicas: 1
minReadySeconds: 5
template:
metadata:
labels:
app: docker-registry
release: docker-registry
annotations:
checksum/config: 58d8ffb95f9da2a14cf64910da49c8a9a0e3c38502b6d644b1349b354a474dbd
checksum/secret: 07f91c662e4b1b82ebd33b33ded9a2960c1ac7d4eb5c12755587bef661dc428c
spec:
securityContext:
fsGroup: 1000
runAsUser: 1000
containers:
- name: docker-registry
image: "registry:2.8.1"
imagePullPolicy: IfNotPresent
command:
- /bin/registry
- serve
- /etc/docker/registry/config.yml
ports:
- containerPort: 5000
livenessProbe:
httpGet:
path: /
port: 5000
readinessProbe:
httpGet:
path: /
port: 5000
resources:
{}
env:
- name: REGISTRY_HTTP_SECRET
valueFrom:
secretKeyRef:
name: docker-registry-secret
key: haSharedSecret
- name: REGISTRY_STORAGE_FILESYSTEM_ROOTDIRECTORY
value: "/var/lib/registry"
volumeMounts:
- name: "docker-registry-config"
mountPath: "/etc/docker/registry"
- name: data
mountPath: /var/lib/registry/
volumes:
- name: docker-registry-config
configMap:
name: docker-registry-config
- name: data
emptyDir: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- resources.yaml
Loading

0 comments on commit 7f4cd86

Please sign in to comment.